-
Notifications
You must be signed in to change notification settings - Fork 186
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
[DTO-5100] BpkChipGroup #3198
[DTO-5100] BpkChipGroup #3198
Conversation
This comment was marked as duplicate.
This comment was marked as duplicate.
export type SingleSelectChipItem = { | ||
text: string; | ||
accessibilityLabel?: string; | ||
leadingAccessoryView?: ReactNode; | ||
className?: string; | ||
[rest: string]: any; // Inexact rest. See decisions/inexact-rest.md | ||
}; | ||
|
||
export type ChipItem = { | ||
component?: (props: BpkSelectableChipProps) => ReactElement; | ||
onClick?: (selected: boolean, index: number) => void; | ||
selected?: boolean; | ||
} & SingleSelectChipItem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shape of this is a bit different to the figma at the moment but I've tried to keep it as close as possible: https://www.figma.com/file/irZ3YBx8vOm16ICkAr7mB3/Backpack?node-id=30119%3A42328&mode=dev
Currently differs by:
icon
replaced byleadingAccessoryView
as this is the prop in BpkSelectableChipProps, although this could be renamed to icon for this prop if preferred.component
instead oftype
but could be made to use an enum to choose fromselectable
,dropdown
anddismissable
chips.
Since these just passed through to a BpkChip component then a ...rest
param seemed sensible at the time, although may not be neccessary now I'm looking back.
Following on the conversation from slack: https://skyscanner.slack.com/archives/C0JHPDSSU/p1706274673682399?thread_ts=1706259605.819169&cid=C0JHPDSSU I’m thinking that the composable pattern is better, as the prop is a hard coupling, however, we could make it looser by the eg there would be no need for the custom stickyChip code, the composition would be enough I think?
The dismissed example becomes a lot more concise:
Semantically, the I can think of future requirements/designs that "clumps" chips together or seperate them. Having this api allows easy extensibility & no change to
or
|
I'm interested in |
Finding: https://react-spectrum.adobe.com/react-spectrum/ActionGroup.html & how similar it is to this component, it might be worth taking a look and doing a contrast and compare to their solution - particularly around the whole api approach and how they manage it. |
This conversation continued on slack a bit, the main reason for having the ChipItems is to give us more control over the BpkChip components which I think we lose if they become composable? See:
I understand this would mean it's harder to migrate to using this component though so if there's a potential middle ground where we still can have control over the props we need but with this pattern that might be ideal. Although I don't know if that's possible? |
Yes, so there are two main types
These two components are not stateful so a consumer should use these if they want to manage the chip states themselves. Then there are also stateful versions of both of these which wrap the stateless ones and make them stateful, simplifying the job of the consumer if their use case is simple. The stateful ones weren't included in the design but I needed to write them for testing anyway so it seemed like a good idea to include them. If we'd rather not though I can take them out or refactor them to use a wrapping pattern like this:
The storybook contains examples of both single and multi select (stateful). |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
Visit https://backpack.github.io/storybook-prs/3198 to see this build running in a browser. |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
Visit https://backpack.github.io/storybook-prs/3198 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/3198 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/3198 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/3198 to see this build running in a browser. |
Co-authored-by: Ollie Curtis <8831547+olliecurtis@users.noreply.github.com>
Visit https://backpack.github.io/storybook-prs/3198 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/3198 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/3198 to see this build running in a browser. |
Figma link
The BpkChipGroup is used to group a list of chips (bpk-component-chip) in either a wrapped layout or rail (single row with scroll. See image above or Figma or all examples.
Changes
Remember to include the following changes:
[KOA-123][BpkButton] Updating the colour
README.md
(If you have created a new component)README.md