diff --git a/packages/react-components/.storybook/preview.js b/packages/react-components/.storybook/preview.js index 5d949a3ff..87a3c797e 100644 --- a/packages/react-components/.storybook/preview.js +++ b/packages/react-components/.storybook/preview.js @@ -1,6 +1,7 @@ import '../src/themes/legacy.scss'; import '../src/themes/light.scss'; import '../src/themes/dark.scss'; +import '../src/foundations/spacing.css'; export const parameters = { actions: { argTypesRegex: '^on[A-Z].*' }, diff --git a/packages/react-components/package.json b/packages/react-components/package.json index 7d43d5939..604948947 100644 --- a/packages/react-components/package.json +++ b/packages/react-components/package.json @@ -21,7 +21,7 @@ "dev:styles": "npm run build:styles -- --watch", "build": "run-s build:*", "build:lib": "tsc && vite build", - "build:styles": "sass src/themes:dist/themes", + "build:styles": "sass src/themes:dist/themes; sass src/foundations:dist/spacing", "build-storybook": "build-storybook", "chromatic": "dotenv -e ../../.env chromatic -- --exit-zero-on-changes", "lint": "eslint src --ext js,jsx,ts,tsx", diff --git a/packages/react-components/src/foundations/spacing-token.ts b/packages/react-components/src/foundations/spacing-token.ts new file mode 100644 index 000000000..c06d010b1 --- /dev/null +++ b/packages/react-components/src/foundations/spacing-token.ts @@ -0,0 +1,16 @@ +export const SpacingToken = { + Spacing0: '--spacing-0', + Spacing05: '--spacing-05', + Spacing1: '--spacing-1', + Spacing2: '--spacing-2', + Spacing3: '--spacing-3', + Spacing4: '--spacing-4', + Spacing5: '--spacing-5', + Spacing6: '--spacing-6', + Spacing8: '--spacing-8', + Spacing12: '--spacing-12', + Spacing16: '--spacing-16', + Spacing18: '--spacing-18', + Spacing20: '--spacing-20', + Spacing24: '--spacing-24', +}; diff --git a/packages/react-components/src/foundations/spacing.css b/packages/react-components/src/foundations/spacing.css new file mode 100644 index 000000000..c3d56e490 --- /dev/null +++ b/packages/react-components/src/foundations/spacing.css @@ -0,0 +1,16 @@ +:root { + --spacing-0: 0; + --spacing-05: 2px; + --spacing-1: 4px; + --spacing-2: 8px; + --spacing-3: 12px; + --spacing-4: 16px; + --spacing-5: 20px; + --spacing-6: 24px; + --spacing-8: 32px; + --spacing-12: 48px; + --spacing-16: 64px; + --spacing-18: 72px; + --spacing-20: 80px; + --spacing-24: 96px; +} diff --git a/packages/react-components/src/index.scss b/packages/react-components/src/index.scss index 730976e38..9619d69dc 100644 --- a/packages/react-components/src/index.scss +++ b/packages/react-components/src/index.scss @@ -1,4 +1,7 @@ @use './themes/legacy'; +@use './themes/light'; +@use './themes/dark'; +@use './foundations/spacing'; *[class^='lc-'] { box-sizing: border-box; diff --git a/packages/react-components/src/index.ts b/packages/react-components/src/index.ts index 98dc74688..df0382bbe 100644 --- a/packages/react-components/src/index.ts +++ b/packages/react-components/src/index.ts @@ -1,6 +1,7 @@ import './index.scss'; -export { DesignTokens } from './themes/designTokens'; +export { DesignToken } from './themes/design-token'; +export { SpacingToken } from './foundations/spacing-token'; export * from './components/Alert'; export * from './components/Badge'; diff --git a/packages/react-components/src/stories/Spacing.stories.mdx b/packages/react-components/src/stories/Spacing.stories.mdx new file mode 100644 index 000000000..51c4f0275 --- /dev/null +++ b/packages/react-components/src/stories/Spacing.stories.mdx @@ -0,0 +1,28 @@ +import { Meta, Canvas, ArgsTable } from '@storybook/addon-docs'; + +import { Spacing } from './components/Spacing'; +import { SpacingExamples } from './components/SpacingExamples'; + + + +# Spacing + + + +## Examples + + \ No newline at end of file diff --git a/packages/react-components/src/stories/components/ColorTokens.tsx b/packages/react-components/src/stories/components/ColorTokens.tsx index 75d3755e2..7ac46f6bb 100644 --- a/packages/react-components/src/stories/components/ColorTokens.tsx +++ b/packages/react-components/src/stories/components/ColorTokens.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { DesignTokens } from '../../themes/designTokens'; +import { DesignToken } from '../../themes/design-token'; import { Text } from '../../components/Typography'; interface TokensGroup { @@ -20,7 +20,7 @@ type TokenGroupName = | 'decor'; const Tokens: TokensGroup = Object.values( - DesignTokens as { [key: string]: string } + DesignToken as { [key: string]: string } ).reduce( (acc: TokensGroup, value) => { const groupName = value.split('-').filter(Boolean)[0] as TokenGroupName; diff --git a/packages/react-components/src/stories/components/Spacing.css b/packages/react-components/src/stories/components/Spacing.css new file mode 100644 index 000000000..cd558b604 --- /dev/null +++ b/packages/react-components/src/stories/components/Spacing.css @@ -0,0 +1,23 @@ +table { + border-collapse: collapse; + width: 100%; +} + +table th, +table td { + border-bottom: 1px solid var(--border-default); + padding: 15px 0; + text-align: left; +} + +table td { + font-size: 14px; +} + +.first-column { + width: 20%; +} + +.second-column { + width: 15%; +} diff --git a/packages/react-components/src/stories/components/Spacing.tsx b/packages/react-components/src/stories/components/Spacing.tsx new file mode 100644 index 000000000..ef2ebf20a --- /dev/null +++ b/packages/react-components/src/stories/components/Spacing.tsx @@ -0,0 +1,100 @@ +import * as React from 'react'; + +import './Spacing.css'; + +export const Spacing = (): React.ReactElement => { + return ( +
Token | +Size | +Usage | +
---|---|---|
--spacing-0 | +0px | +When objects are not separated | +
--spacing-05 | +2px | +Use for really small spaces, where every pixel counts | +
--spacing-1 | +4px | +Use for really small spaces, where every pixel counts | +
--spacing-2 | +8px | +Use for small spaces, where every pixel counts | +
--spacing-3 | +12px | ++ Use for inner paddings in smaller components, for example tooltips + | +
--spacing-4 | +16px | ++ Use for inner paddings in medium components, for example cards or as + margins on mobile devices + | +
--spacing-5 | +20px | ++ Use for inner paddings in larger components, for example modals + | +
--spacing-6 | +24px | ++ Use to separate the content, for examples sections in settings, or + for margins on desktop + | +
--spacing-8 | +32px | ++ Use to separate the content where space is not limiting you, or when + you need more obvious distincion between components + | +
--spacing-12 | +48px | +Use for larger margins for example in empty states | +
--spacing-16 | +64px | +Use to represent additional data | +
--spacing-18 | +72px | +Use to represent additional data | +
--spacing-20 | +80px | +Use to represent additional data | +
--spacing-24 | +96px | +Use to represent additional data | +