|
| 1 | +import type { StoryObj } from '@storybook/react'; |
| 2 | +import React from 'react'; |
| 3 | +import { Section } from '../../../../src'; |
| 4 | +import filterTokens from '../../../util/filterTokens'; |
| 5 | +import { ColorList } from '../../ColorList/ColorList'; |
| 6 | + |
| 7 | +export default { |
| 8 | + title: 'Design Tokens/Tier 2: Usage/Colors', |
| 9 | + parameters: { |
| 10 | + axe: { |
| 11 | + // For documentation purposes only |
| 12 | + skip: true, |
| 13 | + }, |
| 14 | + }, |
| 15 | +}; |
| 16 | + |
| 17 | +const getListItems = ({ |
| 18 | + filterTerm, |
| 19 | + figmaTokenHeader, |
| 20 | + tailwindClassHeader, |
| 21 | +}: { |
| 22 | + filterTerm: string; |
| 23 | + figmaTokenHeader: string; |
| 24 | + tailwindClassHeader: string; |
| 25 | +}) => |
| 26 | + filterTokens(filterTerm).map(({ name, value }) => { |
| 27 | + const specifier = name.slice( |
| 28 | + name.indexOf(filterTerm) + filterTerm.length + 1, |
| 29 | + ); |
| 30 | + return { |
| 31 | + name, |
| 32 | + value, |
| 33 | + figmaToken: figmaTokenHeader + '/' + specifier, |
| 34 | + tailwindClass: tailwindClassHeader + '-' + specifier, |
| 35 | + }; |
| 36 | + }); |
| 37 | + |
| 38 | +export const Text: StoryObj = { |
| 39 | + render: () => ( |
| 40 | + <div> |
| 41 | + <Section title="Text Colors"> |
| 42 | + <ColorList |
| 43 | + listItems={getListItems({ |
| 44 | + filterTerm: 'eds-theme-color-text', |
| 45 | + figmaTokenHeader: 'text', |
| 46 | + tailwindClassHeader: 'text', |
| 47 | + })} |
| 48 | + /> |
| 49 | + </Section> |
| 50 | + </div> |
| 51 | + ), |
| 52 | +}; |
| 53 | + |
| 54 | +export const Icon: StoryObj = { |
| 55 | + render: () => ( |
| 56 | + <div> |
| 57 | + <Section title="Icon Colors"> |
| 58 | + <ColorList |
| 59 | + listItems={getListItems({ |
| 60 | + filterTerm: 'eds-theme-color-icon', |
| 61 | + figmaTokenHeader: 'icon', |
| 62 | + tailwindClassHeader: 'text-icon', |
| 63 | + })} |
| 64 | + /> |
| 65 | + </Section> |
| 66 | + </div> |
| 67 | + ), |
| 68 | +}; |
| 69 | + |
| 70 | +export const Background: StoryObj = { |
| 71 | + render: () => ( |
| 72 | + <div> |
| 73 | + <Section title="Background Colors"> |
| 74 | + <ColorList |
| 75 | + listItems={getListItems({ |
| 76 | + filterTerm: 'eds-theme-color-background', |
| 77 | + figmaTokenHeader: 'background', |
| 78 | + tailwindClassHeader: 'bg', |
| 79 | + })} |
| 80 | + /> |
| 81 | + </Section> |
| 82 | + </div> |
| 83 | + ), |
| 84 | +}; |
| 85 | + |
| 86 | +export const Border: StoryObj = { |
| 87 | + render: () => ( |
| 88 | + <div> |
| 89 | + <Section title="Border Colors"> |
| 90 | + <ColorList |
| 91 | + listItems={getListItems({ |
| 92 | + filterTerm: 'eds-theme-color-border', |
| 93 | + figmaTokenHeader: 'border', |
| 94 | + tailwindClassHeader: 'border', |
| 95 | + })} |
| 96 | + /> |
| 97 | + </Section> |
| 98 | + </div> |
| 99 | + ), |
| 100 | +}; |
0 commit comments