-
Notifications
You must be signed in to change notification settings - Fork 63
feat(component): add separators on pill tabs #1632
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
base: main
Are you sure you want to change the base?
Conversation
|
ec3bd6b to
f8dc221
Compare
| export interface PillTabItem { | ||
| id: string; | ||
| title: string; | ||
| separator?: boolean; |
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.
I think we could improve this interface, right now:
- Clients are responsible for deciding when a stylistic element should be used (the separator)
- Clients have an explicit concept of groups, but this is only implicit within our props
Imagine instead something more like:
// as it was before
export interface PillTabItem {
id: string;
title: string;
}
// a new concept for grouping PillTabItems
export interface PillTabGroup {
title: string; // could be optional, to be used for accessibility, e.g. the title of a fieldset
items: PillTabItem[];
}
export interface PillTabsProps {
items: PillTabItem[] | PillTabGroup[]; // the component accepts an array of one or the other
activePills: string[];
onPillClick: (itemId: string) => void;
}Usage:
const itemGroups = [
{ items: [{ title: 'All', id: 'all' }] },
{
title: 'Standard filters',
items: [
{ title: 'Featured', id: 'featured' },
{ title: 'Free shipping', id: 'free-shipping' },
],
},
{
title: 'Custom views',
items: [
{ title: 'Custom view 1', id: 'custom-view-1' },
{ title: 'Custom view 2', id: 'custom-view-2' },
],
},
];
render(<TestComponent activePills={[]} items={itemGroups} onPillClick={onClick} />);Now:
- BigDesign is solely responsible for the aesthetics of how a group of items is delineated (e.g. should we move from a separating line to something else, the client is not impacted)
- The props API explicitly embodies the concept of groups, which is closer to how clients will be thinking of them
- (Bonus) we can something like a
fieldsetto wrap these now explicit groups to provide an accessible (as well as aesthetic) concept of grouping
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.
This makes sense, in fact that was my first idea. I guess then the pill tab group would show a prepended separator only if it's not the first group within a set.
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.
yeah, and the nice thing is that that logic is now being handled inside the component
these union types:
items: PillTabItem[] | PillTabGroup[];can make implementation less straight forward, so let me know if you need a hand with that
f2bf435 to
802dc12
Compare
What?
Adding separator on pill tabs to diversify pill tab groups
Why?
When working with pill tabs, in the use case for filtering datasets, there may be filters that are provided by default by the app, but there's also the possibility for the user to add custom filter criteria and save it. In order to differentiate the diverse groups of pill tabs, we are introducing a pill separator that would suggest diverse groups of pills.
Screenshots/Screen Recordings
Testing/Proof
dev.tsxcode