diff --git a/lib/stories/borders.stories.tsx b/lib/stories/borders.stories.tsx index a85c985d3..f7a836c07 100644 --- a/lib/stories/borders.stories.tsx +++ b/lib/stories/borders.stories.tsx @@ -1,13 +1,11 @@ import type { Meta, StoryObj } from '@storybook/react'; import React from 'react'; -import { Box } from '../components/Box'; import { Heading } from '../components/Heading'; import { tokens } from '../themes/base/tokens'; -import { BorderWidthScale } from '../themes/tokens'; -import { Stack } from './helpers'; -import { labels, swatch, titles } from './styles.css'; +import { Box, Stack, type Sprinkles } from './helpers'; +import { labels, titles } from './helpers/styles.css'; const widthItems = Object.keys(tokens.border.width); const radiusItems = Object.keys(tokens.border.radius); @@ -22,11 +20,12 @@ const Widths = () => { {widthItems.map((width) => (

{width}

@@ -45,11 +44,10 @@ const Radius = () => { {radiusItems.sort().map((radius) => ( ; +type FilteredAttributes = Pick; +type ComponentProps

= React.PropsWithChildren

; + +export const Box = ({ + children, + className, + style, + ...props +}: ComponentProps) => ( +

+ {children} +
+); + export const Stack = ({ children, + className, + style, ...props -}: RecipeStackProps & { children: React.ReactNode }) => ( -
{children}
+}: ComponentProps) => ( +
+ {children} +
+); + +type ColourSwatchProps = ComponentProps< + Omit & VariantColourSwatchProps +>; +export const ColourSwatch = ({ shape, size, ...props }: ColourSwatchProps) => ( + ); + +export { type Sprinkles } from '../../styles/sprinkles.css'; diff --git a/lib/stories/helpers/styles.css.ts b/lib/stories/helpers/styles.css.ts new file mode 100644 index 000000000..6ad067b78 --- /dev/null +++ b/lib/stories/helpers/styles.css.ts @@ -0,0 +1,45 @@ +import { style } from '@vanilla-extract/css'; +import { recipe, type RecipeVariants } from '@vanilla-extract/recipes'; + +import { themeContractVars as vars } from '../../themes/theme.css'; + +export const titles = style({ + marginTop: '11px', +}); + +export const labels = style({ + textTransform: 'capitalize', +}); + +export const hexPill = style({ + backgroundColor: 'hsl(0 0 100 / 75%)', + borderRadius: '100px', + display: 'inline-block', + fontSize: '11px', + padding: '1px 8px', + position: 'absolute', + textTransform: 'uppercase', + top: '5px', +}); + +export const variantColourSwatch = recipe({ + base: { position: 'relative' }, + variants: { + size: { + sm: { height: vars.space[7], width: vars.space[7] }, + md: { height: vars.space[8], width: vars.space[8] }, + lg: { height: vars.space[9], width: vars.space[9] }, + }, + shape: { + circle: { borderRadius: '100%' }, + }, + }, + defaultVariants: { + size: 'md', + shape: 'circle', + }, +}); + +export type VariantColourSwatchProps = NonNullable< + RecipeVariants +>; diff --git a/lib/stories/palette.stories.tsx b/lib/stories/palette.stories.tsx index c6e3a843e..6942ff8e6 100644 --- a/lib/stories/palette.stories.tsx +++ b/lib/stories/palette.stories.tsx @@ -7,8 +7,8 @@ import { sprinkles } from '../styles/sprinkles.css'; import { baseThemeColours } from '../themes/base/tokens'; import type { ColourGamut, ColourValue } from '../themes/tokens'; -import { Stack } from './helpers'; -import { labels, hexPill, swatch } from './styles.css'; +import { ColourSwatch, Stack } from './helpers'; +import { labels, hexPill } from './helpers/styles.css'; interface SwatchProps { colour: ColourGamut; @@ -24,17 +24,9 @@ const Swatch = ({ colour, hex, hue }: SwatchProps) => ( position: 'relative', }} > -
+
{hex}
-
+ {hue && colour.replace(hue, '')} ); diff --git a/lib/stories/styles.css.ts b/lib/stories/styles.css.ts deleted file mode 100644 index 9e518f4ab..000000000 --- a/lib/stories/styles.css.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { style } from '@vanilla-extract/css'; - -import { themeContractVars as vars } from '../themes/theme.css'; - -export const swatch = style({ - width: vars.space[9], - height: vars.space[9], - position: 'relative', -}); - -export const titles = style({ - marginTop: '11px', -}); - -export const labels = style({ - textTransform: 'capitalize', -}); - -export const hexPill = style({ - backgroundColor: 'hsl(0 0 100 / 75%)', - borderRadius: '100px', - display: 'inline-block', - fontSize: '11px', - padding: '1px 8px', - position: 'absolute', - textTransform: 'uppercase', - top: '5px', -}); diff --git a/lib/stories/theme.stories.tsx b/lib/stories/theme.stories.tsx index ecb96ab93..ade4e1886 100644 --- a/lib/stories/theme.stories.tsx +++ b/lib/stories/theme.stories.tsx @@ -5,7 +5,7 @@ import { Heading } from '../components/Heading'; import { themeContractVars } from '../themes/theme.css'; import { Stack } from './helpers'; -import { labels, swatch } from './styles.css'; +import { labels, variantColourSwatch } from './helpers/styles.css'; const ThemeSwatch = ({ label, cssVar }) => (
( style={{ display: 'flex', gap: '10px', alignItems: 'center' }} >
{label}
@@ -28,8 +28,8 @@ const SemanticSwatches = ({ vars }: { vars: Record }) => ( style={{ display: 'flex', gap: '10px', alignItems: 'center' }} >
{colour} @@ -79,7 +79,7 @@ export const ThemeColours: Story = { return (
- Themed Colours + Theme Colours

Use the theme selection menu options in the top bar to view alternate colour mappings. @@ -97,6 +97,10 @@ export const ThemeColours: Story = { vars={themeContractVars.colours.background} /> + + Border + + Intentional colour sets diff --git a/lib/styles/sprinkles.css.ts b/lib/styles/sprinkles.css.ts index 242441b31..acd53b1d2 100644 --- a/lib/styles/sprinkles.css.ts +++ b/lib/styles/sprinkles.css.ts @@ -1,18 +1,20 @@ import { createSprinkles, defineProperties } from '@vanilla-extract/sprinkles'; import { tokens } from '../themes/base/tokens'; +const { border, colours, space } = tokens; +const { none, ...spaceWithoutNone } = space; const responsiveProperties = defineProperties({ properties: { - gap: tokens.space, - marginBottom: tokens.space, - marginLeft: tokens.space, - marginRight: tokens.space, - marginTop: tokens.space, - paddingBottom: tokens.space, - paddingLeft: tokens.space, - paddingRight: tokens.space, - paddingTop: tokens.space, + gap: space, + marginBottom: space, + marginLeft: space, + marginRight: space, + marginTop: space, + paddingBottom: space, + paddingLeft: space, + paddingRight: space, + paddingTop: space, }, shorthands: { margin: ['marginTop', 'marginBottom', 'marginLeft', 'marginRight'], @@ -26,38 +28,51 @@ const responsiveProperties = defineProperties({ const borderProperties = defineProperties({ properties: { - borderRadius: { ...tokens.border.radius }, - borderWidth: { ...tokens.border.width }, + borderColor: { ...border.colours }, + borderRadius: { ...border.radius }, + borderStyle: ['solid', 'dotted', 'dashed'], + borderWidth: { ...border.width }, }, }); -const flexProperties = defineProperties({ +const displayProperties = defineProperties({ properties: { display: ['none', 'block', 'flex'], flexDirection: ['row', 'column'], flexWrap: ['nowrap', 'wrap', 'wrap-reverse'], alignItems: ['stretch', 'flex-start', 'center', 'flex-end'], justifyContent: ['stretch', 'flex-start', 'center', 'flex-end'], - width: ['100%', 'auto'], + height: { + ...spaceWithoutNone, + '100%': '100%', + auto: 'auto', + }, + width: { + ...spaceWithoutNone, + '100%': '100%', + auto: 'auto', + }, }, shorthands: { placeItems: ['justifyContent', 'alignItems'], + size: ['width', 'height'], }, }); const gamutProperties = defineProperties({ properties: { - color: tokens.colours.gamut, - background: tokens.colours.gamut, - borderColor: tokens.colours.gamut, - fill: tokens.colours.gamut, - stroke: tokens.colours.gamut, + color: colours.gamut, + background: colours.gamut, + fill: colours.gamut, + stroke: colours.gamut, }, }); export const sprinkles = createSprinkles( responsiveProperties, borderProperties, - flexProperties, + displayProperties, gamutProperties, ); + +export type Sprinkles = Parameters[0];