import { Meta, Title, Subtitle, ColorPalette, ColorItem, } from '@storybook/blocks' import { tokens as allTokens } from '../styles/colors' import {capitalizeFirstLetter} from '../utils' export const data = Object.entries(allTokens).reduce((acc, curr) => { const [name, value] = curr const nameParts = name.split('-') if (nameParts.length == 2) { if (!acc['color']) { acc['color'] = {} } nameParts.unshift('color') } const title = nameParts[0].toLowerCase() const subtitle = nameParts[1].toLowerCase() const token = nameParts[2].toLowerCase() if (!acc[title]) { acc[title] = {} } if (!acc[title][subtitle]) { acc[title][subtitle] = {} } acc[title][subtitle][token] = value return acc }, {})
{ Object.keys(data).map(t => { if (t === 'color') { return null } return ( <> {capitalizeFirstLetter(t)} { Object.keys(data[t]).map(s => { return ( <> {capitalizeFirstLetter(s)} { (typeof data[t][s] === 'string') ? null : ( { Object.keys(data[t][s]).map(v => { return ( ) }) } ) } ) }) } ) }) }