diff --git a/packages/gamut-docs/astro.config.mjs b/packages/gamut-docs/astro.config.mjs index 5a29b58baf..298994bb85 100644 --- a/packages/gamut-docs/astro.config.mjs +++ b/packages/gamut-docs/astro.config.mjs @@ -159,7 +159,19 @@ export default defineConfig({ // needs an explicit label instead of a bare autogenerate. label: 'System props', items: [ - { autogenerate: { directory: 'foundations/system-props' } }, + { slug: 'foundations/system-props' }, + { + label: 'Prop groups', + items: [ + { + autogenerate: { + directory: 'foundations/system-props/prop-groups', + }, + }, + ], + }, + { slug: 'foundations/system-props/compose-and-variants' }, + { slug: 'foundations/system-props/responsive-properties' }, ], }, { slug: 'foundations/themes' }, diff --git a/packages/gamut-docs/src/components/SystemPropTable.astro b/packages/gamut-docs/src/components/SystemPropTable.astro new file mode 100644 index 0000000000..2f66411cdb --- /dev/null +++ b/packages/gamut-docs/src/components/SystemPropTable.astro @@ -0,0 +1,145 @@ +--- +/** + * The Starlight counterpart of Storybook's system prop `TokenTable` (see + * styleguide's `Foundations/shared/elements.tsx`): one row per prop in a + * system prop group, with its CSS properties, scale, and transform. + * + * Rows are read from `variance/config.ts` at build time — the same source + * Storybook uses — so the table can't drift from the props themselves. That + * file isn't part of `@skillsoft/gamut-styles`' public exports, so it's + * imported by path, as Storybook does. + * + * Storybook resolves a prop's properties for whichever logical-properties mode + * its toolbar is set to. A static page has no toggle, so a prop whose physical + * and logical properties differ lists both. + */ +import * as ALL_PROPS from '../../../gamut-styles/src/variance/config'; + +type Group = keyof typeof ALL_PROPS; +type Mode = 'physical' | 'logical'; + +interface PropConfig { + property: string | Record; + properties?: readonly string[] | Record; + scale?: string; + transform?: (...args: never[]) => unknown; + resolveProperty?: (useLogicalProperties: boolean) => Mode; +} + +interface Props { + /** A system prop group exported from `variance/config.ts`, e.g. "color" */ + group: Group; +} + +const { group } = Astro.props; + +const toKebab = (value: string) => + value.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`); + +const resolveProperties = ( + { property, properties }: PropConfig, + mode: Mode +): string[] => { + const resolved = typeof property === 'string' ? property : property[mode]; + if (!properties) return [resolved]; + if (Array.isArray(properties)) return [...properties]; + return [...(properties as Record)[mode]]; +}; + +const rows = Object.entries( + ALL_PROPS[group] as Record +).map(([id, config]) => { + // Without `resolveProperty`, a prop always renders its physical properties. + const physical = resolveProperties(config, 'physical'); + const logical = config.resolveProperty + ? resolveProperties(config, 'logical') + : physical; + const modesDiffer = physical.join() !== logical.join(); + + return { + id, + propertySets: modesDiffer + ? [ + { label: 'Logical', properties: logical }, + { label: 'Physical', properties: physical }, + ] + : [{ label: undefined, properties: physical }], + scale: config.scale, + transforms: [config.transform?.name, config.resolveProperty?.name].filter( + Boolean + ), + }; +}); + +// Hand-authored hrefs in components aren't rewritten by the markdown base-URL +// plugin in astro.config.mjs, so the base has to be applied here. +const scaleHref = `${import.meta.env.BASE_URL.replace(/\/$/, '')}/foundations/design-tokens/`; +--- + +
+ + + + + + + + + + + { + rows.map(({ id, propertySets, scale, transforms }) => ( + + + + + + + )) + } + +
PropPropertiesScaleTransform
+ {id} + + {propertySets.map(({ label, properties }) => ( +
+ {label && {label}: } + {properties.map((prop, index) => ( + <> + {index > 0 && ' '} + + {toKebab(prop)} + + + ))} +
+ ))} +
{scale && {scale}} + {transforms.map((name, index) => ( + <> + {index > 0 && ' '} + {name} + + ))} +
+
+ + diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups.md b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups.md deleted file mode 100644 index 71dd781d0c..0000000000 --- a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -title: Prop groups -description: Every system prop group and what it covers. ---- - -Each group below is one example of what it covers, not an exhaustive prop list. For every individual prop in a group — its exact CSS properties, its scale, and its transform — open that group's own page in Storybook (for example, [Layout](https://gamut.codecademy.com/?path=/docs/foundations-system-props-layout--docs)) and see its prop table; that table is generated live from `variance/config.ts`, so it can't drift out of sync the way a static copy here would. - -## Layout - -Layout props control the visual structure and dimensions of elements — how components take up space, their display behavior, and how they align within their containers. - -```tsx -const LayoutExample = styled.div(system.layout); - -; -``` - -## Space - -Space props apply margin and padding consistently, referencing the theme's spacing scale — including responsive array syntax. - -```tsx -const SpaceExample = styled.div(system.space); - -; -``` - -## Typography - -Typography props connect to the theme's font family, size, weight, and line-height scales, alongside text transforms and decorations. - -```tsx -const TextExample = styled.p(system.typography); - -; -``` - -## Color - -Color props control foreground, background, and border colors, restricted to the theme's color palette. `bg` is a shorthand for background color. - -```tsx -const ColorExample = styled.div(system.color); - -; -``` - -## Border - -Border props add and style borders on any side of an element, with directional props and horizontal/vertical shorthands. `borderRadius` references the theme's `borderRadii` scale. - -```tsx -const BorderExample = styled.div(system.border); - -; -``` - -## Flex - -Flex props control flexbox layouts end to end — container behavior and individual item properties alike. - -```tsx -const FlexExample = styled.div(system.flex); - -; -``` - -## Grid - -Grid props control CSS Grid layouts — templates, auto-placement, and gaps between items. - -```tsx -const GridExample = styled.div(system.grid); - -; -``` - -## Background - -Background props control background images and patterns — sizing, positioning, and repetition. For solid background colors, use the color props instead. - -```tsx -const BackgroundExample = styled.div(system.background); - -; -``` - -## Positioning - -Positioning props control how an element is placed within its parent and its stacking order — `position`, the individual edge props (or the `inset` shorthand for all four at once), and `zIndex`. - -```tsx -const PositioningExample = styled.div(system.positioning); - -; -``` - -## Shadow - -Shadow props add box and text shadows, using standard CSS shadow syntax. - -```tsx -const ShadowExample = styled.div(system.shadow); - -; -``` - -## List - -List props adjust bullet styles, positioning, and custom marker images when a component renders as a `ul` or `ol`. For richer list features, see [List](/components/data-display/list-and-tables/list/list/). - -```tsx -const ListExample = styled.div(system.list); - - - a list item -; -``` - -`border`, `color`, `positioning`, and `space` props all support both physical and logical CSS properties, resolved by `useLogicalProperties` on `GamutProvider` — see [Migrating to logical properties](/guides/migrating-to-logical-properties/). diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/background.md b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/background.md new file mode 100644 index 0000000000..3222d5e958 --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/background.md @@ -0,0 +1,16 @@ +--- +title: Background +description: System props for background images and patterns. +sidebar: + order: 8 +--- + +Background props control background images and patterns — sizing, positioning, and repetition. For solid background colors, use the [color props](/foundations/system-props/prop-groups/color/) instead. + +```tsx +const BackgroundExample = styled.div(system.background); + +; +``` + +For every prop in this group — its CSS properties, scale, and transform — see the [Background prop table](https://gamut.codecademy.com/?path=/docs/foundations-system-props-background--docs) in Storybook. diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/border.md b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/border.md new file mode 100644 index 0000000000..0d75108ad3 --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/border.md @@ -0,0 +1,23 @@ +--- +title: Border +description: System props for border width, style, and radius on any side. +sidebar: + order: 5 +--- + +Border props add and style borders on any side of an element, with directional props and horizontal/vertical shorthands. `borderRadius` references the theme's `borderRadii` scale. + +```tsx +const BorderExample = styled.div(system.border); + +; +``` + +These props support both physical and logical CSS properties, resolved by `useLogicalProperties` on `GamutProvider` — see [Migrating to logical properties](/guides/migrating-to-logical-properties/). + +For every prop in this group — its CSS properties, scale, and transform — see the [Border prop table](https://gamut.codecademy.com/?path=/docs/foundations-system-props-border--docs) in Storybook. diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/color.mdx b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/color.mdx new file mode 100644 index 0000000000..8b4720e01d --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/color.mdx @@ -0,0 +1,22 @@ +--- +title: Color +description: System props for foreground, background, and border colors. +sidebar: + order: 4 +--- + +import SystemPropTable from '~/components/SystemPropTable.astro'; + +Color props control foreground, background, and border colors, restricted to the theme's color palette. `bg` is a shorthand for background color. + +```tsx +const ColorExample = styled.div(system.color); + +; +``` + +These props support both physical and logical CSS properties, resolved by `useLogicalProperties` on `GamutProvider` — see [Migrating to logical properties](/guides/migrating-to-logical-properties/). + +## Props + + diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/flex.md b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/flex.md new file mode 100644 index 0000000000..7ff7728535 --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/flex.md @@ -0,0 +1,16 @@ +--- +title: Flex +description: System props for flexbox containers and items. +sidebar: + order: 6 +--- + +Flex props control flexbox layouts end to end — container behavior and individual item properties alike. + +```tsx +const FlexExample = styled.div(system.flex); + +; +``` + +For every prop in this group — its CSS properties, scale, and transform — see the [Flex prop table](https://gamut.codecademy.com/?path=/docs/foundations-system-props-flex--docs) in Storybook. diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/grid.md b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/grid.md new file mode 100644 index 0000000000..9e6e42baee --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/grid.md @@ -0,0 +1,19 @@ +--- +title: Grid +description: System props for grid templates, placement, and gaps. +sidebar: + order: 7 +--- + +Grid props control CSS Grid layouts — templates, auto-placement, and gaps between items. + +```tsx +const GridExample = styled.div(system.grid); + +; +``` + +For every prop in this group — its CSS properties, scale, and transform — see the [Grid prop table](https://gamut.codecademy.com/?path=/docs/foundations-system-props-grid--docs) in Storybook. diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/index.md b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/index.md new file mode 100644 index 0000000000..4ce82ca286 --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/index.md @@ -0,0 +1,21 @@ +--- +title: Prop groups +description: Every system prop group and what it covers. +sidebar: + label: Overview + order: 0 +--- + +System props are grouped by the kind of styling they control. Import a group from `system` in `@skillsoft/gamut-styles`, or combine several with [compose](/foundations/system-props/compose-and-variants/). + +- [Layout](/foundations/system-props/prop-groups/layout/) — dimensions, display, and alignment. +- [Space](/foundations/system-props/prop-groups/space/) — margin and padding on the spacing scale. +- [Typography](/foundations/system-props/prop-groups/typography/) — font family, size, weight, and line height. +- [Color](/foundations/system-props/prop-groups/color/) — foreground, background, and border colors. +- [Border](/foundations/system-props/prop-groups/border/) — border width, style, and radius on any side. +- [Flex](/foundations/system-props/prop-groups/flex/) — flexbox containers and items. +- [Grid](/foundations/system-props/prop-groups/grid/) — grid templates, placement, and gaps. +- [Background](/foundations/system-props/prop-groups/background/) — background images and patterns. +- [Positioning](/foundations/system-props/prop-groups/positioning/) — position, edges, and stacking order. +- [Shadow](/foundations/system-props/prop-groups/shadow/) — box and text shadows. +- [List](/foundations/system-props/prop-groups/list/) — list markers and their position. diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/layout.mdx b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/layout.mdx new file mode 100644 index 0000000000..ac4162b0eb --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/layout.mdx @@ -0,0 +1,27 @@ +--- +title: Layout +description: System props for dimensions, display, and alignment. +sidebar: + order: 1 +--- + +import SystemPropTable from '~/components/SystemPropTable.astro'; + +Layout props control the visual structure and dimensions of elements — how components take up space, their display behavior, and how they align within their containers. + +```tsx +const LayoutExample = styled.div(system.layout); + +; +``` + +These props support both physical and logical CSS properties, resolved by `useLogicalProperties` on `GamutProvider` — see [Migrating to logical properties](/guides/migrating-to-logical-properties/). + +## Props + + diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/list.md b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/list.md new file mode 100644 index 0000000000..f89be4211b --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/list.md @@ -0,0 +1,23 @@ +--- +title: List +description: System props for list markers and their position. +sidebar: + order: 11 +--- + +List props adjust bullet styles, positioning, and custom marker images when a component renders as a `ul` or `ol`. For richer list features, see [List](/components/data-display/list-and-tables/list/list/). + +```tsx +const ListExample = styled.div(system.list); + + + a list item +; +``` + +For every prop in this group — its CSS properties, scale, and transform — see the [List prop table](https://gamut.codecademy.com/?path=/docs/foundations-system-props-list--docs) in Storybook. diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/positioning.md b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/positioning.md new file mode 100644 index 0000000000..3b1bd45578 --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/positioning.md @@ -0,0 +1,18 @@ +--- +title: Positioning +description: System props for position, edges, and stacking order. +sidebar: + order: 9 +--- + +Positioning props control how an element is placed within its parent and its stacking order — `position`, the individual edge props (or the `inset` shorthand for all four at once), and `zIndex`. + +```tsx +const PositioningExample = styled.div(system.positioning); + +; +``` + +These props support both physical and logical CSS properties, resolved by `useLogicalProperties` on `GamutProvider` — see [Migrating to logical properties](/guides/migrating-to-logical-properties/). + +For every prop in this group — its CSS properties, scale, and transform — see the [Positioning prop table](https://gamut.codecademy.com/?path=/docs/foundations-system-props-positioning--docs) in Storybook. diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/shadow.md b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/shadow.md new file mode 100644 index 0000000000..832d5385e4 --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/shadow.md @@ -0,0 +1,19 @@ +--- +title: Shadow +description: System props for box and text shadows. +sidebar: + order: 10 +--- + +Shadow props add box and text shadows, using standard CSS shadow syntax. + +```tsx +const ShadowExample = styled.div(system.shadow); + +; +``` + +For every prop in this group — its CSS properties, scale, and transform — see the [Shadow prop table](https://gamut.codecademy.com/?path=/docs/foundations-system-props-shadow--docs) in Storybook. diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/space.mdx b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/space.mdx new file mode 100644 index 0000000000..1ff1094a9c --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/space.mdx @@ -0,0 +1,22 @@ +--- +title: Space +description: System props for margin and padding on the spacing scale. +sidebar: + order: 2 +--- + +import SystemPropTable from '~/components/SystemPropTable.astro'; + +Space props apply margin and padding consistently, referencing the theme's spacing scale — including responsive array syntax. + +```tsx +const SpaceExample = styled.div(system.space); + +; +``` + +These props support both physical and logical CSS properties, resolved by `useLogicalProperties` on `GamutProvider` — see [Migrating to logical properties](/guides/migrating-to-logical-properties/). + +## Props + + diff --git a/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/typography.mdx b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/typography.mdx new file mode 100644 index 0000000000..087a9b61e5 --- /dev/null +++ b/packages/gamut-docs/src/content/docs/foundations/system-props/prop-groups/typography.mdx @@ -0,0 +1,20 @@ +--- +title: Typography +description: System props for font family, size, weight, and line height. +sidebar: + order: 3 +--- + +import SystemPropTable from '~/components/SystemPropTable.astro'; + +Typography props connect to the theme's font family, size, weight, and line-height scales, alongside text transforms and decorations. + +```tsx +const TextExample = styled.p(system.typography); + +; +``` + +## Props + + diff --git a/packages/gamut-docs/src/content/docs/getting-started/using-this-site.md b/packages/gamut-docs/src/content/docs/getting-started/using-this-site.md index a2a3b30e0d..a7c76fa38a 100644 --- a/packages/gamut-docs/src/content/docs/getting-started/using-this-site.md +++ b/packages/gamut-docs/src/content/docs/getting-started/using-this-site.md @@ -29,6 +29,6 @@ Every component page follows the same section order, so once you know the patter Sections 2–4 are explanation and how-to material; section 5 is reference, and always lives in Storybook rather than being retyped here — the embed is the source of truth. If you're deciding whether to use the component at all, start at Usage; if you just need to see what a prop looks like, skip straight to the bottom. -## This site is a work in progress +## Contributing to documentation -Gamut's documentation is migrating here from a Storybook-based styleguide. Pages that haven't been migrated yet are marked as such and link back to their current location. If you spot a gap, the [Contributing guide](/guides/contributing-to-gamut/) covers how to add or fix a page. +If you spot a gap, the [Contributing guide](/guides/contributing-to-gamut/) covers how to add or fix a page. diff --git a/packages/gamut-docs/src/content/docs/guides/contributing-to-gamut.md b/packages/gamut-docs/src/content/docs/guides/contributing-to-gamut.md index c59f11540d..34132f5a02 100644 --- a/packages/gamut-docs/src/content/docs/guides/contributing-to-gamut.md +++ b/packages/gamut-docs/src/content/docs/guides/contributing-to-gamut.md @@ -7,10 +7,9 @@ description: How to propose, build, and document changes to Gamut. We track planned work for Gamut components in the [Gamut Board](https://skillsoftdev.atlassian.net/jira/software/c/projects/GMT/boards/3655/backlog) on JIRA. -- If there's a ticket there you want to take on, send a Slack message to `#gamut-team` or come to Gamut Office Hours to talk it through. -- If the work you'd like to do isn't captured in a JIRA ticket, talk to us first and we'll help create one. -- To request work be done, discuss it with us on Slack or during Gamut Office Hours. -- To pitch a change to the design system, attend Gamut Crit, come to Gamut Office Hours, or message `#gamut-team`. +- If there's a ticket there you want to take on, send a Slack message to `#gamut-team` +- If the work you'd like to do isn't captured in a JIRA ticket, talk to us first and we'll help create one +- To pitch a change to the design system, attend Gamut Crit, or message `#gamut-team`. ## Writing components @@ -129,4 +128,4 @@ If your PR has breaking changes affecting at least one downstream repository — 4. Once the new Gamut package publishes, update the downstream PRs to use it. 5. Merge and deploy those PRs as soon as possible. -If a breaking change might affect other users beyond those you've already coordinated with, mention it in `#frontend` too. +If a breaking change might affect other users beyond those you've already coordinated with, mention it in `#gamut-team` too and tag any relevant teams. diff --git a/packages/gamut-docs/src/content/docs/guides/creating-a-custom-theme.md b/packages/gamut-docs/src/content/docs/guides/creating-a-custom-theme.md index 96163436ad..c354d8f341 100644 --- a/packages/gamut-docs/src/content/docs/guides/creating-a-custom-theme.md +++ b/packages/gamut-docs/src/content/docs/guides/creating-a-custom-theme.md @@ -5,7 +5,7 @@ description: Build a custom theme with gamut-styles' createTheme builder. ## When to reach for this -Most apps should [choose an existing theme](/guides/theming-your-app/) rather than build a new one — reach for a custom theme only for a genuinely new product surface that doesn't fit Core, Admin, LX Studio, Percipio, or Platform. +Most apps should [choose an existing theme](/guides/theming-your-app/) rather than build a new one — reach for a custom theme only for a genuinely new product surface that doesn't fit Core, Admin, LX Studio, Percipio, or Platform. If you're unsure, check with your team first — a designer should have signed off on this new theme prior to implementation. ## The `createTheme` builder diff --git a/packages/gamut-docs/src/content/docs/guides/index.md b/packages/gamut-docs/src/content/docs/guides/index.md index 88f28cf7e8..24c2a49f91 100644 --- a/packages/gamut-docs/src/content/docs/guides/index.md +++ b/packages/gamut-docs/src/content/docs/guides/index.md @@ -3,7 +3,7 @@ title: Overview description: Task-oriented recipes for things you already know you need to build. --- -How-to guides for cross-cutting tasks that don't have a home under a single component. +How-to guides for common tasks that users might encounter. - [Theming your app](/guides/theming-your-app/) - [Creating a custom theme](/guides/creating-a-custom-theme/)