-
Notifications
You must be signed in to change notification settings - Fork 23
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
Multiple links in InfoBanner #335
Comments
IMO the last two should not be valid options. The first option as it is will introduce a breaking change so I'd propose to accept WDYT? |
Yeah, totally agree with your point of view, just wanted to offer some alternatives. 👍 Just not sure what you mean in last paragraph with the breaking change, where you would accept the |
I agree with Leo as well, I think he means that having only one prop would be a breaking change (since we would be changing the props that users currently rely on), so we should introduce a new prop (e.g. We could consider using a discriminating union and the |
I'm totally against the "pass array of links" approach. Today we need to allow a list of links. Tomorrow, we'll need to pass a subtitle. This will quickly fall into the mess of unrelated props we need to support. We can keep the current level of granularity of the present component, and provide a more granular level API aside. We can do so by exposing a lower level components (e.g. In Jan's special case, he can recreate the behaviour from the constructing blocks, but the main component will still have maximum visibility: import { InfoBannerBlocks } from '@freenow/wave/InfoBanner/blocks'
const JanBanner = () => {
return <InfoBannerBlocks.Card>
<InfoBannerBlocks.Header>Hello</InfoBannerBlocks.Header/>
{links.map(link => <InfoBannerBlocks.Link href={link.href}>{link.text}</InfoBannerBlocks.Link>)}
</InfoBannerBlocks.Card>
} This way we can keep the style consistent but enable this escape hatch for custom uses |
I hadn't thought of exposing a compound component like Nik suggests, but I really like the idea, we'd be keeping the "default" component simple but at the same time allow our users to compose their own variations without losing our styles and without us having to make changes to support a specific use case. |
I love the idea of having compound components, Kent C Dodds has a few videos about how he structured his library with this strategy and it's very nice and flexible, up to also exposing the hooks to have better control of these components. Would we add a new set of components to be exported keeping the default one available to be exported, in order to avoid breaking changes, right? |
Thanks for the input guys, yeah I like Nik's idea too a lot, I will set up building blocks for the container Card, Header, Description and Links and come back with a link to MR 👍 |
Describe the feature you'd like
Hello team, we currently have a need to render multiple links inside
<InfoBanner />
for the purposes of document cross-checking automation on DMT validation flow. Example below.Describe alternatives you've considered
Imo we have 3 options here:
<InfoBanner>
component to accept an array of links to render below the banner description.{ linkUrl: string, linkLabel: string }[]
<InfoBanner>
component to pass JSX with list of links setup via children prop<InfoBanner>
in our component libraryThe text was updated successfully, but these errors were encountered: