Skip to content

Commit 85c4842

Browse files
add labelColor
1 parent f002fca commit 85c4842

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

docs/storybook/stories/Color/Patterns/AllPatterns.stories.tsx

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {ColorTokenSwatch} from '../../StorybookComponents/ColorTokenSwatch/Color
55
import {DataTable, Table} from '@primer/react/experimental'
66
import {InlineCode} from '../../StorybookComponents/InlineCode/InlineCode'
77
import {getTokensByName} from '../../utilities/getTokensByName'
8+
import {Box, Token} from '@primer/react'
89

910
export default {
1011
title: 'Color/Patterns',
@@ -884,3 +885,80 @@ export const ContributionGraph = () => {
884885
</Table.Container>
885886
)
886887
}
888+
889+
export const Label = () => {
890+
const data = getTokensByName(colorTokens, 'label').map(token => {
891+
return {
892+
id: token.name,
893+
...token,
894+
}
895+
})
896+
const colors = [...new Set(data.map(({id}) => id.replace(/label-([a-zA-Z0-9]+)-.*/, '$1')))]
897+
898+
return (
899+
<>
900+
<h1 id="label">Labels</h1>
901+
<Box paddingBottom={5} sx={{gap: 2, display: 'flex'}}>
902+
{colors.map(color => (
903+
<Token
904+
text={color}
905+
sx={{
906+
backgroundColor: `var(--label-${color}-bgColor-rest)`,
907+
color: `var(--label-${color}-fgColor-rest)`,
908+
borderColor: 'transparent',
909+
'&:hover': {
910+
backgroundColor: `var(--label-${color}-bgColor-hover)`,
911+
color: `var(--label-${color}-fgColor-hover)`,
912+
cursor: 'pointer',
913+
},
914+
'&:active': {
915+
backgroundColor: `var(--label-${color}-bgColor-active)`,
916+
color: `var(--label-${color}-fgColor-active)`,
917+
cursor: 'pointer',
918+
},
919+
}}
920+
/>
921+
))}
922+
</Box>
923+
<Table.Container>
924+
<DataTable
925+
aria-labelledby="label"
926+
data={data}
927+
columns={[
928+
{
929+
header: 'Sample',
930+
field: 'name',
931+
rowHeader: true,
932+
renderCell: row => {
933+
return (
934+
<ColorTokenSwatch
935+
bgColor={row.name.includes('bgColor') || row.name.includes('iconColor') ? row.name : undefined}
936+
textColor={row.name.includes('fgColor') ? row.name : undefined}
937+
shadowColor={row.name.includes('shadow') ? row.name : undefined}
938+
borderColor={row.name.includes('borderColor') ? row.name : undefined}
939+
/>
940+
)
941+
},
942+
},
943+
{
944+
header: 'Token',
945+
field: 'name',
946+
rowHeader: true,
947+
renderCell: row => {
948+
return <InlineCode value={row.name} copyClipboard cssVar />
949+
},
950+
},
951+
{
952+
header: 'Output value',
953+
field: 'value',
954+
rowHeader: true,
955+
renderCell: row => {
956+
return <p>{row.value}</p>
957+
},
958+
},
959+
]}
960+
/>
961+
</Table.Container>
962+
</>
963+
)
964+
}

0 commit comments

Comments
 (0)