You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I checked the code, button component is already sufficient to handle render of anchor or button based on the href prop, so just I need to add the optional href in the badge prop and add it to the button . @cchaos please correct me if I m going wrong.
The EuiButton component does correclty handle this situation, but we essentially need to translate that same type of code to EuiBadge to handle it as well since EuiBadge does not extend EuiButton.
Hi @cchaos , I was looking at the EuiButton component and was wondering what does exclusive union does? export type Props = ExclusiveUnion<EuiButtonPropsForAnchor,EuiButtonPropsForButton>;
The idea is that we needed a way for a component with multiple potential element targets to ensure that the attributes for those discrete elements don't get mixed. For instance, a simple union of HTMLAnchorElement | HTMLButtonElement might allow for anhref attribute to be passed to a <button />, which is invalid and something we want to avoid. ExclusiveUnion is our method of requiring that consumers pass props from eitherHTMLAnchorElementorHTMLButtonElement, but not a combination of the two.
The EuiButton component does correclty handle this situation, but we essentially need to translate that same type of code to EuiBadge to handle it as well since EuiBadge does not extend EuiButton.
The idea is that we needed a way for a component with multiple potential element targets to ensure that the attributes for those discrete elements don't get mixed. For instance, a simple union of HTMLAnchorElement | HTMLButtonElement might allow for anhref attribute to be passed to a <button />, which is invalid and something we want to avoid. ExclusiveUnion is our method of requiring that consumers pass props from eitherHTMLAnchorElementorHTMLButtonElement, but not a combination of the two.
#2954 Cleaned up EuiButton code nicely, but it didn't address this issue. EuiBadge is a completely separate component that needs the same implementation as EuiButton. It does not re-use EuiButton or logic.
Activity
cchaos commentedon Feb 19, 2020
Hi @aryamanpuri , yes please do! Essentially the component needs to accept an
hrefprop and then output the right html element.hrefthe component should render as link tag<a>onClickthe component should render as a button tag<button>You can essentially look at how EuiButton handles the render:
eui/src/components/button/button.tsx
Lines 168 to 195 in f11ea60
And we have two helper services for the TS types you can reuse similar to EuiButton here:
eui/src/components/button/button.tsx
Lines 79 to 96 in f11ea60
Be sure to check the whole file as not everything was captured in those permalinks.
Thanks!
shakti97 commentedon Feb 21, 2020
may I work on this?
shakti97 commentedon Feb 21, 2020
I checked the code, button component is already sufficient to handle render of anchor or button based on the href prop, so just I need to add the optional href in the badge prop and add it to the button .
@cchaos please correct me if I m going wrong.
cchaos commentedon Feb 21, 2020
The EuiButton component does correclty handle this situation, but we essentially need to translate that same type of code to EuiBadge to handle it as well since EuiBadge does not extend EuiButton.
RisingGeek commentedon Feb 21, 2020
Hi @cchaos , I was looking at the EuiButton component and was wondering what does exclusive union does?
export type Props = ExclusiveUnion<EuiButtonPropsForAnchor,EuiButtonPropsForButton>;thompsongl commentedon Feb 21, 2020
@RisingGeek There's a good, full description of
ExclusiveUnionin the code comments. (And another for the specific case you mention)The idea is that we needed a way for a component with multiple potential element targets to ensure that the attributes for those discrete elements don't get mixed. For instance, a simple union of
HTMLAnchorElement | HTMLButtonElementmight allow for anhrefattribute to be passed to a<button />, which is invalid and something we want to avoid.ExclusiveUnionis our method of requiring that consumers pass props from eitherHTMLAnchorElementorHTMLButtonElement, but not a combination of the two.shakti97 commentedon Feb 21, 2020
okay will try to do that
RisingGeek commentedon Feb 21, 2020
Got it. Thanks
Mallik813 commentedon Feb 22, 2020
@cchaos
Is this issue not closed yet? It's been 16 days since it was open? If it is not closed yet, can I take up this issue?
Thanks
shakti97 commentedon Feb 22, 2020
Hi @Mallik813 , I'm currently working on this. Could you please check some other issue
Mallik813 commentedon Feb 22, 2020
@shakti97 sure!
anishagg17 commentedon Feb 27, 2020
@shakti97 May I take over this issue?
anishagg17 commentedon Feb 28, 2020
@chandlerprall may i take this issue now?
chandlerprall commentedon Feb 29, 2020
@anishagg17 Go ahead
cchaos commentedon Mar 2, 2020
#2954 Cleaned up EuiButton code nicely, but it didn't address this issue. EuiBadge is a completely separate component that needs the same implementation as EuiButton. It does not re-use EuiButton or logic.
anishagg17 commentedon Mar 2, 2020
@cchaos can I go for cleaning badge groups too??
cchaos commentedon Mar 2, 2020
EuiBadgeGroup doesn't actually contain any EuiBadge's. Only EuiBadge needs to be addressed by this issue.
anishagg17 commentedon Mar 2, 2020
OKay , I would like to work on it @cchaos