Skip to content

Commit

Permalink
Feature request: specify which tabs to display #122
Browse files Browse the repository at this point in the history
  • Loading branch information
acherkashin committed Nov 12, 2023
1 parent 5bee027 commit e257d41
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion addon/src/hooks/useTokenTabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,25 @@ export function useTokenTabs(config?: Config) {
new Set(categories.map((category) => category?.name))
);

return categoryNames.map((name) => ({
let tabs = categoryNames.map((name) => ({
label: name,
categories: categories.filter(
(category) => category?.name === name
) as Category[],
}));

if ((config?.tabs ?? []).length !== 0) {
tabs = tabs.filter(tab => config.tabs.includes(tab.label))
}

return tabs;
}, [
cssCategories,
lessCategories,
scssCategories,
svgIconCategories,
imageCategories,
config
]);

useEffect(() => {
Expand Down
11 changes: 10 additions & 1 deletion addon/src/stories/Button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,14 @@ export const Primary: Story = {
args: {
primary: true,
label: "Button",
},
},
};

export const ColorsOnly: Story = {
args: { ...Primary.args },
parameters: {
designToken: {
tabs: ['Colors']
}
}
}
1 change: 1 addition & 0 deletions addon/src/types/config.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Config {
styleInjection?: string;
pageSize?: number;
presenters?: PresenterMapType;
tabs?: string[];
}

export interface File {
Expand Down

0 comments on commit e257d41

Please sign in to comment.