+
I am a text on top of a danger-500 background 👋
>
diff --git a/packages/react/src/docs/customization.mdx b/packages/react/src/docs/customization.mdx
index 06d5c5c..5fbc4bf 100644
--- a/packages/react/src/docs/customization.mdx
+++ b/packages/react/src/docs/customization.mdx
@@ -14,7 +14,7 @@ Design tokens are the fundamental variables defining the precise behavior and re
For example it could be:
-- The primary color of a text element
+- The brand color
- The standard spacing between two elements
- The border radius of a button
- ...
@@ -36,9 +36,9 @@ import { DefaultTokens } from "@openfun/cunningham-react";
const config: DefaultTokens = {
themes: {
default: {
- theme: {
+ globals: {
colors: {
- "primary-500": "purple",
+ "brand-500": "purple",
},
},
},
@@ -58,9 +58,9 @@ Or if you prefer Javascript, create a file named `cunningham.cjs` at the root of
module.exports = {
themes: {
default: {
- theme: {
+ globals: {
colors: {
- "primary-500": "purple",
+ "brand-500": "purple",
},
},
},
@@ -103,7 +103,7 @@ import { DefaultTokens } from "@openfun/cunningham-react";
const config: DefaultTokens = {
themes: {
default: {
- theme: {
+ globals: {
...
},
components: {
@@ -143,7 +143,7 @@ import { defaultTokens, DefaultTokens } from "@openfun/cunningham-react";
const config: DefaultTokens = {
themes: {
default: {
- theme: {
+ globals: {
...
},
components: {
@@ -161,7 +161,7 @@ export default config;
> Be careful, `DefaultTokens` with a capital `D` is the type of the default tokens, while `defaultTokens` with a lowercase `d` is the object containing the default tokens.
-You can also use more global design tokens from `defaultTokens.theme`, like that:
+You can also use more global design tokens from `defaultTokens.globals` and `defaultTokens.contextuals`, like that:
+
+# Objective
+
+The Cunningham color system has been revised with a methodical approach focused on modularity and accessibility. This revision enables the systematic generation of coherent themes, the automatic implementation of display modes (light/dark), the constant maintenance of contrast ratios independently of the selected theme, and the structured allocation of colors according to their role (background, content, border).
+
+An algorithm (available soon) has been developed to facilitate the rapid generation and adaptation of color palettes, producing a JSON file compatible with the existing infrastructure and natively supporting both light and dark display modes. This algorithmic solution optimizes Cunningham's adaptability to a wide range of user environments.
+
+
+
+# Structure
+
+The color system is structured around two complementary, interdependent palettes:
+
+1. The "Color Primitive" palette is the exhaustive repository of color values specific to a given theme, defining all available shades.
+2. The "Color Contextual" palette establishes a functional interface between primitive values and user interface components via a semantic abstraction layer.
+
+This two-tier architecture facilitates the systematic propagation of changes: any alteration to the primitive palette is automatically reflected in all interface elements without the need for additional adjustments (see Figure 1).
+
+
+
+
+ Figure 1. Changing the color primitive palette automatically updates the color contextual palette while maintaining contrast ratios inside components.
+
+
+A **theme** is a comprehensive color configuration derived from a brand's visual identity. It constitutes a specific implementation of the "Color Primitive" palette with predetermined color values. The Cunningham theme is provided as the default reference.
+
+A **mode** represents a systematic modulation of luminance and contrast parameters from an established theme, executed through the "Color Contextual" palette. This parametric adjustment accommodates diverse usage contexts while preserving the fundamental chromatic identity. Standard implementations include light and dark modes. These could be supplemented with specialized modes (such as high contrast) to meet specific accessibility needs or style requirements.
+
+
+# Palettes
+
+## Color Primitive
+
+The Color Primitive palette includes 16 colors. Each color is available in 19 distinct shades, except gray, which contains 22. Each shade is referenced by a number between 000 and 1000. A shade of 000 corresponds to pure white, while a shade of 1000 corresponds to pure black. Each intermediate shade value is then defined on the basis of the perceived luminance noted L* in the CIELAB color space ([more info on CIELAB](https://en.wikipedia.org/wiki/CIELAB_color_space)). Using L* as a reference ensures that each primitive color fits into a predictable tonal scale, regardless of hue or saturation. This ensures consistent contrast levels across all themes, promoting universal accessibility. The correspondence between shade (S) and perceived luminance (L*) is as follows: $S=1000 \times (1-L^*)$ with $L^* \in [0;1]$. See Figure 2 for an example.
+
+
+
+
+ Figure 2. Breakdown of the first 6 colors of a "Color Primitive" theme. Gray includes 3 complementary shades.
+
+
+To optimize visual ergonomics in dark mode, it is necessary to reduce color saturation in the darkest shades (S > 600). This gradual desaturation avoids perceptual glare in dark mode and improves legibility in low ambient light environments.
+
+An algorithm will soon be available to automatically adjust the parameters of perceived luminance (L*) and saturation (C*) according to a decreasing function for dark shades, while preserving the integrity of the theme's visual identity.
+
+## Color Contextual
+
+
+
+ Figure 3. excerpt from the "Color Contextual" palette for the background.semantic.brand role, with light and dark modes.
+
+
+The "Color Contextual" palette allows you to classify the various colors of a theme according to their actual use, differentiating between each of the modes (light, dark, etc.). This makes it possible (1) to simplify and limit errors when assigning colors to different components, and (2) to manage multiple modes.
+
+This palette introduces the notion of roles, whose format is as follows:
+
+
+
+### Layer
+
+The layer designates the visual rendering level of an interface element, and is divided into three distinct categories:
+
+- Background: Background layer serving as visual support for components (e.g., button background).
+- Content: Informative elements conveying a message (e.g., text, iconography)
+- Border : Peripheral delimitation of components
+
+### Scope
+
+The scope determines the functional area of application of a color according to the following hierarchy:
+
+- Surface: Structural elements of the interface with different levels of elevation (e.g., backgrounds, modals, maps).
+- Semantic: Interactive elements communicating a specific meaning to the user.
+- Palette: set of colors for specific applications requiring customization (e.g., color selection for avatars)
+
+### Intent (optional)
+
+The intent specifies the communicative function associated with the scope. It provides an additional contextual specification of the element's purpose in the interface.
+
+### Variant
+
+The variant establishes a hierarchy of visual importance according to the following taxonomy:
+
+- Primary: Overriding importance, attracts priority attention
+- Secondary: Intermediate importance, supports primary elements
+- Tertiary: Subordinate importance, provides additional information
+- On [...]: Color inversion mechanism to ensure legibility of superimposed content (applicable to layer content only)
+
+### State (optional)
+
+The state characterizes the interactional state of an interface element (e.g., Hover, Active, Disabled), making it possible to visually communicate its reactivity to the user.
+
+# **Accessibility**
+
+Accessibility is a fundamental principle guiding the design of this color system. As demonstrated in the Color Primitive section, the methodical standardization of luminance values (L*) ensures consistent contrast ratios, regardless of the theme or display mode selected. This systematic approach eliminates the need to re-evaluate accessibility parameters when implementing new themes, ensuring ongoing compliance with WCAG accessibility standards. The main objective is to establish an accessibility framework that is invariant and resilient in the face of multiple usage contexts.
+
+# **Technical implementation**
+
+Du à tout les changements, et à l'architecture des tokens, toutes les variables css ont changés. Vous devez donc mettre à jour vos variables css. Il faut absolument
+regénérer vos tokens avec la commande `cunningham -g css,ts,js` pour avoir les nouvelles variables css.
+
+Dans le cas des tokens d'un theme, toutes les valeurs sémantiques sont dans le ```theme.globals```. Cela correspond aux couleurs primitives, transitions, fonts, spacings, breakpoints, font weights, font families, etc.
+De fait toutes les valeurs contextuelles sont dans le ```theme.contextuals```. Cela correspond aux couleurs de fond, aux couleurs de contenu, aux couleurs de bordure, aux couleurs de palette, etc.
+
+
+```json
+// Old structure
+{
+ "themes": {
+ "default": {
+ "theme": {
+ "colors": "..."
+ "font": "..."
+ "spacings": "..."
+ "breakpoints": "..."
+ "...": "..."
+ },
+ "components": {
+ "button": {
+ "...": "..."
+ }
+ }
+
+ }
+ }
+}
+
+
+// New structure
+{
+ "themes": {
+ "default": {
+ "globals": {
+ "colors": "..."
+ "font": "..."
+ "spacings": "..."
+ "breakpoints": "..."
+ "...": "..."
+ },
+ "contextuals": {
+ "background": {
+ "...": "..."
+ }
+ "content": {
+ "...": "..."
+ }
+ "border": {
+ "...": "..."
+ }
+ }
+ "components": {
+ "button": {
+ "...": "..."
+ }
+ }
+ }
+
+ }
+
+}
+```
+
+## **Migration Steps**
+
+
+### **1. Update Dependencies**
+
+First, update your `package.json` to use version 4.0.0:
+
+```json
+{
+ "dependencies": {
+ "@openfun/cunningham-react": "^4.0.0"
+ }
+}
+```
+
+### **2. Regenerate Tokens**
+
+Run the token generation command to get the new CSS variables:
+
+```bash
+cunningham -g css,ts,js
+```
+
+This command will generate the new CSS variables compatible with the new structure.
+
+### **3. Update CSS Variables in Your Code**
+
+All your references to old CSS variables will need to be updated. The new variables follow this structure:
+
+```css
+/* Old structure (v3) */
+.test {
+ color: var(--c--theme--colors--primary-500)
+}
+
+/* New structure (v4) */
+.test {
+ color: var(--c--globals--colors--brand-500);
+ color: var(--c--contextuals--background--semantic--brand--primary);
+ color: var(--c--contextuals--content--semantic--brand--primary);
+ color: var(--c--contextuals--border--semantic--brand--primary);
+ color: var(--c--contextuals--palette--brand--primary);
+}
+
+```
+
+### **3. Update Button Props**
+
+Dans le cas du button, il faut mettre à jour les props `color` et `variant` pour utiliser le nouveau structure.
+La props color correspond au color primitive et la props variant au type de button.
+
+```tsx
+/* Old structure (v3) */
+
+
+/* New structure (v4) */
+
+
+
+
+```
+
+### **4. Verify Accessibility**
+
+The new architecture automatically ensures WCAG accessibility standards compliance through methodical standardization of luminance values (L*). Contrast ratios are now consistent regardless of the selected theme or display mode.
+
+## **Migration Benefits**
+
+1. **Enhanced Accessibility**: Automatic compliance with WCAG standards
+2. **Mode Management**: Native support for light/dark modes
+3. **Visual Consistency**: Automatic propagation of color changes
+4. **Simplified Maintenance**: No need to re-evaluate accessibility parameters when adding new themes
+
+## **Important Notes**
+
+- **Mandatory Migration**: The update is not optional as all CSS variables have changed
+- **Testing Required**: Verify that all your custom components using CSS variables work correctly after migration
+- **Documentation**: Consult the official documentation for new color patterns and best practices
+
+This migration represents a significant but necessary investment to benefit from a more robust, accessible, and maintainable design system.
diff --git a/packages/react/src/docs/migrating/ressources/v3_to_v4/Figure1.gif b/packages/react/src/docs/migrating/ressources/v3_to_v4/Figure1.gif
new file mode 100644
index 0000000..2869fd8
Binary files /dev/null and b/packages/react/src/docs/migrating/ressources/v3_to_v4/Figure1.gif differ
diff --git a/packages/react/src/docs/migrating/ressources/v3_to_v4/Figure2.png b/packages/react/src/docs/migrating/ressources/v3_to_v4/Figure2.png
new file mode 100644
index 0000000..3a8ba77
Binary files /dev/null and b/packages/react/src/docs/migrating/ressources/v3_to_v4/Figure2.png differ
diff --git a/packages/react/src/docs/migrating/ressources/v3_to_v4/Figure3.png b/packages/react/src/docs/migrating/ressources/v3_to_v4/Figure3.png
new file mode 100644
index 0000000..5c72298
Binary files /dev/null and b/packages/react/src/docs/migrating/ressources/v3_to_v4/Figure3.png differ
diff --git a/packages/react/src/docs/theming.mdx b/packages/react/src/docs/theming.mdx
index 8219ba9..b355bc6 100644
--- a/packages/react/src/docs/theming.mdx
+++ b/packages/react/src/docs/theming.mdx
@@ -49,7 +49,7 @@ It's seamless ! You can still use variables in CSS like this
@@ -118,9 +118,9 @@ const config: DefaultTokens = {
...
},
pink: {
- theme: {
+ globals: {
colors: {
- "primary-100": "pink",
+ "brand-100": "pink",
...
}
}
diff --git a/packages/react/src/docs/typo.mdx b/packages/react/src/docs/typo.mdx
index da60a39..22c8185 100644
--- a/packages/react/src/docs/typo.mdx
+++ b/packages/react/src/docs/typo.mdx
@@ -33,8 +33,8 @@ You can customize the values of the font size design tokens with the configurati
export default {
themes: {
default: {
- theme: {
- typo: {
+ globals: {
+ font: {
sizes: {
m: '0.5rem', // You can customize the size of the existing medium text ( 'fs-m' class )
xxl: '3rem' // You can also add custom sizes yourself ( 'fs-xxl' class will be generated )
@@ -74,8 +74,8 @@ You can customize the values of the font weight design tokens with the configura
export default {
themes: {
default: {
- theme: {
- typo: {
+ globals: {
+ fonts: {
weights: {
regular: 500, // You can customize the size of the existing regular text ( 'fw-regular' class )
chunky: 900 // You can also add custom weights yourself ( 'fw-chunky' class will be generated )
@@ -102,7 +102,7 @@ class on every dom element.
dark
format={false}
code={`
-
Accent text
+
Accent text
`}
/>
@@ -119,8 +119,8 @@ You can customize the values of the font family design tokens with the configura
export default {
themes: {
default: {
- theme: {
- typo: {
+ globals: {
+ font: {
families: {
base: 'Inter', // You can customize the font family of the existing base variation ( 'f-base' class )
legend: 'Arial' // You can also add custom font families yourself ( 'f-legend' class will be generated )