diff --git a/scss/_maps.scss b/scss/_maps.scss index 790c7bd744..92f82e804b 100644 --- a/scss/_maps.scss +++ b/scss/_maps.scss @@ -147,7 +147,7 @@ $ouds-icon-sizes: ("small", "medium", "large") !default; // scss-docs-start ouds-maps-opacities $ouds-opacities: ( "invisible": $ouds-opacity-invisible, - "weakest": $ouds-opacity-weakest, + "weakest": $ouds-opacity-weakest, "weaker": $ouds-opacity-weaker, "weak": $ouds-opacity-weak, "disabled": $ouds-opacity-disabled, diff --git a/site/data/sidebar-foundation.yml b/site/data/sidebar-foundation.yml index 9581006bcc..52fb3bf48f 100644 --- a/site/data/sidebar-foundation.yml +++ b/site/data/sidebar-foundation.yml @@ -5,7 +5,6 @@ - title: Approach - title: Options - title: Tokens - coming_soon: true - title: Colors - title: Color modes - title: CSS variables diff --git a/site/src/components/header/Navigation.astro b/site/src/components/header/Navigation.astro index f75ad54923..074fd60088 100644 --- a/site/src/components/header/Navigation.astro +++ b/site/src/components/header/Navigation.astro @@ -93,8 +93,8 @@ const { addedIn, layout, title } = Astro.props Components Utilities diff --git a/site/src/content/docs/foundation/tokens.mdx b/site/src/content/docs/foundation/tokens.mdx index c7ae3b7029..ea750948c8 100644 --- a/site/src/content/docs/foundation/tokens.mdx +++ b/site/src/content/docs/foundation/tokens.mdx @@ -6,4 +6,70 @@ aliases: toc: true --- - +## Figma tokens + +Figma tokens (or design tokens) provide a shared language and mutual understanding of the design system between designers and developers. They also serve as a single source of truth for the design system, which is crucial for its maintenance and evolution. We have structured them into a three-tier architecture: raw scope, semantic scope, and component scope. For more information, please refer to the [design guidelines on design tokens](https://r.orange.fr/r/S-ouds-doc-token-intro). + + + We provide a file to import them all: `@ouds/web-[[config:brand]]/scss/tokens/_index.scss`. So in a Sass context `@import "@ouds/web-[[config:brand]]/scss/tokens";` will import all the tokens. + + Only [semantic](#semantic-tokens) and [composite tokens](#composite-tokens) should be used directly in projects. When possible, it is recommended to use these tokens via [utility classes]([[docsref:/utilities#using-our-utilities]]). All other tokens are intended for internal use by other tokens or by our components. + + +### Raw tokens + +The [`@ouds/web-[[config:brand]]/scss/tokens/_raw.scss`]([[config:repo]]/blob/v[[config:current_version]]-ouds-web/packages/[[config:brand]]/scss/tokens/_raw.scss) file aggregates all raw tokens. While these tokens don’t carry semantic meaning and aren’t meant to be used directly in projects, they are the foundation of the Orange Unified Design System. Their primary purpose is to be used by [semantic tokens](#semantic-tokens), and occasionally, by [component tokens](#component-tokens). + +### Semantic tokens + +The [`@ouds/web-[[config:brand]]/scss/tokens/_semantic.scss`]([[config:repo]]/blob/v[[config:current_version]]-ouds-web/packages/[[config:brand]]/scss/tokens/_semantic.scss) file contains all the semantic tokens. Unlike [raw tokens](#raw-tokens), these tokens can be used directly in projects (check the [cheatsheet for their recommended usage]([[docsref:/utilities#using-our-utilities]])). They are derived from raw tokens and add semantic meaning through media queries or specific contexts. Most of these tokens are available in our utilities or used within our components. The colors tokens should not be used directly but via their custom properties version, [see below](#semantic-colors-with-css-variables). + +#### Semantic colors with CSS variables + +The [`@ouds/web-[[config:brand]]/scss/tokens/_semantic-colors-custom-props.scss`]([[config:repo]]/blob/v[[config:current_version]]-ouds-web/packages/[[config:brand]]/scss/tokens/_semantic-colors-custom-props.scss) file contains all the usable semantic color tokens custom properties. They are built on [semantic tokens](#semantic-tokens) switching the color depending on the [color mode]([[docsref:/foundation/color-modes]]). Most of these tokens are already used in utilities or directly within our components. We also provide equivalence for Sass variables. For more information, check out our [colors documentation]([[docsref:/foundation/colors]]). + +### Composite tokens + +The [`@ouds/web-[[config:brand]]/scss/tokens/_composite.scss`]([[config:repo]]/blob/v[[config:current_version]]-ouds-web/packages/[[config:brand]]/scss/tokens/_composite.scss) file contains all the composite tokens. They are aggregations of several [semantic tokens](#semantic-tokens) or brand-specific icons. These tokens are already used either in utilities or directly within our components. Apart from the icons, these are shadows tokens and typographic definition. + +### Component tokens + +The [`@ouds/web-[[config:brand]]/scss/tokens/_component.scss`]([[config:repo]]/blob/v[[config:current_version]]-ouds-web/packages/[[config:brand]]/scss/tokens/_component.scss) file is dedicated to component tokens. These tokens are used exclusively within components, often relying on [semantic tokens](#semantic-tokens) and [composite tokens](#composite-tokens), though they may occasionally reference [raw tokens](#raw-tokens). Unless you’re sure of what you’re doing, you should avoid using these tokens in your codebase, as they are defined for a specific component. + +## Variables + + + Checkout our [utilities cheatsheet]([[docsref:/utilities]]) to learn the recommended usage for tokens and variables + + +### Sass variables + +Almost every token provided in the design specification and potentially needed in various contexts is represented in our codebase as a Sass variable. However, as explained in the [the previous section](#figma-tokens), not all tokens should be used directly in your codebase. + +We build our Sass variables following the architecture of the Figma tokens: +- [Raw tokens](#raw-tokens): `$core-{ouds|[[config:brand]]}-{border|color|dimension|effect|elevation|font|grid|opacity}-{token-name}`. + - They shouldn’t be used. + - Ex: `core/ouds/color/functional/black` becomes `$core-ouds-color-functional-black`. +- [Semantic tokens](#semantic-tokens): `$ouds-{border|color|dimension|effect|elevation|font|grid|opacity|size|space}-{token-name}`. + - Our scaled spacing, font and icon sizes tokens don’t have a Sass variable, please refer to the [CSS variables](#css-variables) or to the [utilities]([[docsref:/utilities#using-our-utilities]]) instead. + - Colors and elevation colors also have their versions using suffixes `*-light` and `*-dark`. + - Ex: `ouds/color/content/on/brand-primary` becomes `$ouds-color-content-on-brand-primary`, `ouds/elevation/blur/emphasized` becomes `$ouds-elevation-blur-emphasized`. +- [Composite tokens](#composite-tokens): `$ouds-elevation-{token-name}` + - Ex: `ouds/elevation/**/emphasized` are aggregated via `$ouds-elevation-emphasized`. + - Our font tokens are aggregated in a mixin [`get-font-size()`]([[docsref:/foundation/typography/#text-style-for-custom-components]]) that takes the font reference name as a parameter. So `ouds/font/**/body-large` are aggregated via `get-font-size("body-large")`. +- [Component tokens](#component-tokens): `$ouds-{component-name}-{token-name}` + - Ex: `ouds/button/color/bg/minimal/hover` becomes `$ouds-button-color-bg-minimal-hover`. + +### CSS variables + +All the colors and the tokens suffixed by `*-mobile`, `*-tablet`, or `*-desktop` are available as CSS variables. + +We build our CSS variables following the architecture of the Figma tokens: +- [Raw tokens](#raw-tokens): We don’t have any raw token transformed into a CSS variable. +- [Semantic tokens](#semantic-tokens): `--bs-{color|elevation|font|icon|space}-{token-name}`. + - Our scaled spacing are only declared as CSS variables `--bs-space-scaled-{size}`. It’s equivalent to `ouds/space/scaled/{size}` in Figma. Prefer using our [utilities]([[docsref:/utilities#using-our-utilities]]) when possible. + - Our colors and elevation colors are declared as CSS variables `--bs-color-{token-name}`. It’s equivalent to `ouds/color/{token-name}` in Figma. Prefer using our [utilities]([[docsref:/utilities#using-our-utilities]]) when possible. + - Our icon sizes are declared as CSS variables `--bs-icon-{size}`. It’s equivalent to `ouds/size/icon/{size}` in Figma. Prefer using our [utilities]([[docsref:/utilities#using-our-utilities]]) when possible. + - Our font tokens are aggregated in a mixin [`get-font-size()`]([[docsref:/foundation/typography/#text-style-for-custom-components]]) that takes the font reference name as a parameter. So `ouds/font/**/body-large` are aggregated via `get-font-size("body-large")`. Don’t use our CSS variables for font alone. +- [Composite tokens](#composite-tokens): We don’t have any composite token transformed into a CSS variable, but they are available as [Sass variables](#sass-variables). +- [Component tokens](#component-tokens): We don’t have any component token transformed into a CSS variable. The only CSS variables that we have for components are the ones that we need to build the component internally. diff --git a/site/src/content/docs/utilities.mdx b/site/src/content/docs/utilities.mdx new file mode 100644 index 0000000000..c87c318c6a --- /dev/null +++ b/site/src/content/docs/utilities.mdx @@ -0,0 +1,62 @@ +--- +title: Utilities +description: All OUDS utilities at a glance. +aliases: + - "/utilities/" + - "/docs/utilities/" + - "/docs/[[config:docs_version]]/utilities/" +toc: true +--- + +## General usage + +Our utilities are built on top of our [semantic tokens]([[docsref:/foundation/tokens#semantic-tokens]]) and our [composite tokens]([[docsref:/foundation/tokens#composite-tokens]]). They are the preferred way to use our tokens. When a token is used on Figma side, you should check if there is a utility class available for it. + +We build our CSS variables following the architecture of the Figma tokens: +- [Raw tokens]([[docsref:/foundation/tokens#raw-tokens]]): No raw token is available as a utility. +- [Semantic tokens]([[docsref:/foundation/tokens#semantic-tokens]]): Semantic tokens are all [available as utilities](#using-our-utilities). +- [Composite tokens]([[docsref:/foundation/tokens#composite-tokens]]): Composite tokens are all [available as utilities](#using-our-utilities). +- [Component tokens]([[docsref:/foundation/tokens#component-tokens]]): No component token is available as a utility. + +## Using our utilities + +To [integrate a Figma design](https://youtu.be/EnGJE0jZLPU?t=200), you will have to use tokens that are defined as `ouds/**`. This page gives you some directions on how to use these tokens within your codebase. + + + +When a token is used on Figma side, you should check if there is a utility class available for it. If there is, you should use it. This way, you will be sure that the token is applied correctly, and that it will be updated automatically when the token value changes. + + + | On Figma I see | Used token | Utility classes | Utility link | + | -------------- | ---------- | --------------- | ------------ | + | A color for a background, a border or a content, used depending on a user action `ouds/color/action/*`. | `ouds/color/action/pressed` | `--bs-color-action-pressed` |

This case is a bit special and you should read about [our color page]([[docsref:/foundation/colors]]).

| + | A background color using a standard token `ouds/color/{bg\|surface}/*`. | `ouds/color/bg/secondary`
`ouds/color/surface/brand-primary` | `.bg-secondary`
`.bg-surface-brand-primary` | [Background]([[docsref:/utilities/background]]) | + | A border using a standard token `ouds/color/border/*` or `ouds/border/*`. | `ouds/color/border/default`
`ouds/border/radius/small`
`ouds/border/width/thick` | `.border-default`
`.rounded-small`
`.border-thick` | [Border]([[docsref:/utilities/border]]) | + | A content using a standard color token `ouds/color/content/*`. | `ouds/color/content/muted`
`ouds/color/content/on/brand-primary` | `.text-muted`
`.text-on-brand-primary` | [Color]([[docsref:/utilities/color]]) | + | An opacity using a standard token `ouds/opacity/*`. Be careful where the token is applied. | `ouds/opacity/medium` | `.opacity-medium` | [Opacity]([[docsref:/utilities/opacity]]) | + | A shadow using an aggregated reference. Having a token shaped like `ouds/elevation/*` is a good sign that this reference has been used or should have been. | `ouds/elevation/**/emphasized` | `.shadow-emphasized` | [Shadow]([[docsref:/utilities/shadow]]) | + | A spacing using a standard token `ouds/space/{scaled\|fixed}/*` or `ouds/space/{column-gap\|row-gap}/*`. | `ouds/space/scaled/2xlarge`
`ouds/space/fixed/medium`
`ouds/space/row-gap/none` | `.p-scaled-2xlarge`
`.p-medium`
`.row-gap-none` | [Spacing]([[docsref:/utilities/spacing]]) | + | A text using an aggregated reference. Having a token shaped like `ouds/font/*` or `font-ref/size/weight` is a good sign that this reference has been used or should have been. | `ouds/font/**/body-large`
`Body/Large/Strong` | `.fs-bl`
`.fs-bl.fw-bold` | [Typography]([[docsref:/utilities/text#font-size]]) | + | A spacing using a grid token `ouds/grid/*` | `ouds/grid/column-gap`
`ouds/grid/margin` | `.gap-gridgap`
`.px-gridmargin` | [Spacing]([[docsref:/utilities/spacing#grid-measures]]) | +
+ +## Using our variables + + + This method should only be use if there is no utility class available for the token you want to use, or if you need to apply the token on a pseudo element, or if you are creating a custom component. If you use this method, you will need to check that the token value is applied correctly, and that it will be updated automatically when the token value changes. + + +Variables names can be easily inferred from token names, [this is explained in the tokens documentation]([[docsref:/foundation/tokens#variables]]). + + + | On Figma I see | Used token | Associated CSS variables | Associated Sass variables | + | -------------- | ---------- | --------------- | --------------- | + | A background color using a standard token `ouds/color/*`. | `ouds/color/bg/secondary`
`ouds/color/surface/brand-primary`
`ouds/color/action/hover` | `--bs-color-bg-secondary`
`--bs-color-surface-brand-primary`
`--bs-color-action-hover` | `$ouds-color-bg-secondary`
`$ouds-color-surface-brand-primary`
`$ouds-color-action-hover` | + | A border using a standard token `ouds/color/border/*` or `ouds/border/*`. | `ouds/color/border/default`
`ouds/border/radius/small`
`ouds/border/width/thick` | `--bs-color-border-default`
`none`
`none` | `$ouds-color-border-default`
`$ouds-border-radius-small`
`$ouds-border-width-thick` | + | A content using a standard color token `ouds/color/content/*`. | `ouds/color/content/muted`
`ouds/color/content/on/brand-primary`
`ouds/color/content/on/action/hover` | `--bs-color-content-muted`
`--bs-color-content-on-brand-primary`
`--bs-color-content-on-action-hover` | `$ouds-color-content-muted`
`$ouds-color-content-on-brand-primary`
`$ouds-color-content-on-action-hover` | + | An opacity using a standard token `ouds/opacity/*`. Be careful where the token is applied. | `ouds/opacity/medium` | `none` | `$ouds-opacity-medium` | + | A shadow using an aggregated reference. Having a token shaped like `ouds/elevation/*` is a good sign that this reference has been used or should have been. | `ouds/elevation/**/emphasized` | `none` | `$ouds-elevation-emphasized` | + | A spacing using a standard token `ouds/space/{scaled\|fixed}/*` or `ouds/space/{column-gap\|row-gap}/*`. | `ouds/space/scaled/2xlarge`
`ouds/space/fixed/medium`
`ouds/space/row-gap/none` | `--bs-space-scaled-2xlarge`
`none`
`none` | `none`
`$ouds-space-fixed-medium`
`$ouds-space-row-gap-none` | + | A text using an aggregated reference. Having a token shaped like `ouds/font/*` or `font-ref/size/weight` is a good sign that this reference has been used or should have been. | `ouds/font/**/body-large`
`Body/Large/Strong` | `get-font-size("body-large")`
`none`
As you can see, this one is a bit special and calls a mixin [`get-font-size()`]([[docsref:/foundation/typography/#text-style-for-custom-components]]). | `none`
`$ouds-font-weight-web-body-strong` | + | A spacing using a grid token `ouds/grid/*` | `ouds/grid/column-gap`
`ouds/grid/margin` | `--bs-grid-gap`
`--bs-grid-margin` | `none`
`none` | +
diff --git a/site/src/content/docs/utilities/api.mdx b/site/src/content/docs/utilities/api.mdx index 17d6576b56..c7b67167d4 100644 --- a/site/src/content/docs/utilities/api.mdx +++ b/site/src/content/docs/utilities/api.mdx @@ -2,9 +2,6 @@ title: Utility API description: The utility API is a Sass-based tool to generate utility classes. aliases: - - "/utilities/" - - "/docs/utilities/" - - "/docs/[[config:docs_version]]/utilities/" - "/docs/utilities/api/" toc: true --- diff --git a/site/src/content/docs/utilities/link.mdx b/site/src/content/docs/utilities/link.mdx deleted file mode 100644 index 6fcb61fdc2..0000000000 --- a/site/src/content/docs/utilities/link.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: Link -description: Link utilities are used to stylize your anchors to adjust their color, opacity, underline offset, underline color, and more. -aliases: - - "/docs/utilities/link/" -toc: true ---- - - diff --git a/site/src/scss/_content.scss b/site/src/scss/_content.scss index 3873334ef1..7d80f7ec1a 100644 --- a/site/src/scss/_content.scss +++ b/site/src/scss/_content.scss @@ -37,7 +37,7 @@ // Prevent breaking of code th, - td:first-child > code { // stylelint-disable-line selector-max-compound-selectors + code { white-space: nowrap; } }