Currently it only accepts onClick but badges can also link to other pages as well. It should accept href similar to EuiButton.
Hi @aryamanpuri , yes please do! Essentially the component needs to accept an href prop and then output the right html element.
href the component should render as link tag <a>onClick the component should render as a button tag <button>You can essentially look at how EuiButton handles the render:
https://github.com/elastic/eui/blob/f11ea608c8d864e04f2841751ec1f02511ba73ee/src/components/button/button.tsx#L168-L195
And we have two helper services for the TS types you can reuse similar to EuiButton here:
Be sure to check the whole file as not everything was captured in those permalinks.
Thanks!
may I work on this?
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>;
@RisingGeek There's a good, full description of ExclusiveUnion in 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 | 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 _either_ HTMLAnchorElement _or_ HTMLButtonElement, 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.
okay will try to do that
@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 _either_HTMLAnchorElement_or_HTMLButtonElement, but not a combination of the two.
Got it. Thanks
@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
Hi @Mallik813 , I'm currently working on this. Could you please check some other issue
@shakti97 sure!
@shakti97 May I take over this issue?
@chandlerprall may i take this issue now?
@anishagg17 Go ahead
@cchaos can I go for cleaning badge groups too??
EuiBadgeGroup doesn't actually contain any EuiBadge's. Only EuiBadge needs to be addressed by this issue.
OKay , I would like to work on it @cchaos
Most helpful comment
@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 _either_HTMLAnchorElement_or_HTMLButtonElement, but not a combination of the two.