Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS updates #34

Conversation

thompsongl
Copy link

disabled is not available on a and label, but it looks like the styling is handled. I didn't visually test, though

@cchaos
Copy link
Owner

cchaos commented Jul 13, 2020

Ahhh... hmmm.

So I was hoping that EuiButtonDisplay would try to be as element agnostic as possible so that the consuming component, EuiButton, would be passing the appropriate combination of props, ie disabled to a <button>. Is it possible to move the logic you added primarily to EuiButton instead? That way then element could easily be changed to just string.

@thompsongl
Copy link
Author

I can take another pass move the logic around.
But I think at some point there will have to be a check to see what kind of element element is so that the ref can be correctly cast.

@cchaos
Copy link
Owner

cchaos commented Jul 13, 2020

Yeah I think the ref is the main trouble spot too.

@thompsongl
Copy link
Author

Yeah I think the ref is the main trouble spot too.

Looking again, if element needs to be even more generic, I'm not sure we can actually type it correctly and would // @ts-ignore the return. That's what happens inEuiFlexItem where we do the same kind of thing.

@thompsongl
Copy link
Author

At some point ref does need to be cast, so the choices are either define a set of elements and use logic to pass the correct props, or allow any element and ignore the type check.

@cchaos
Copy link
Owner

cchaos commented Jul 13, 2020

Since EuiButtonDisplay is an internal component only, I'd say let's TS ignore the ref/return in THAT component, but then ensure that EuiButton is appropriately assigning props to HTML element

@@ -102,7 +102,7 @@ export interface EuiButtonProps extends CommonProps {
}

export interface EuiButtonDisplayProps extends EuiButtonProps {
element: 'a' | 'button' | 'label';
element: keyof JSX.IntrinsicElements;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what is this/does this mean?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, would React.createElement help here in any way?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keyof JSX.IntrinsicElements

It will allow for basically any HTML element

Also, would React.createElement help here in any way?

That's an interesting idea. Let me try it out; I'm not actually sure what TS will do it.

@cchaos cchaos merged commit dd949b8 into cchaos:chore/decouple_button_content Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants