Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/classic-eds-dark-mapping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@equinor/fusion-react-styles": minor
---

Make stable EDS 2.x components follow dark mode. The root `ThemeProvider` maps the classic `--eds_*` colour properties that `@equinor/eds-core-react` 2.x reads to the scheme-aware `--eds-color-*` variables of `@equinor/eds-tokens` 2.3.2, under `[data-color-scheme="dark"]` (and the system dark preference on a root without `data-color-scheme="light"`) only, so light mode keeps the classic colours. The scrim uses a translucent mix of `--eds-color-bg-backdrop`. `Tooltip` and `Snackbar` get a dark, near-opaque `--eds-color-bg-neutral-canvas` background and light text.

New exports for hosts with their own global styles: `classicColourVariables`, `classicScrimColour`, `classicOverlayColour`, `classicOverlayColours`, `classicOverlayTextStyles`, `classicColourDeclarations()` and `classicColourSchemeStyles()`.
14 changes: 14 additions & 0 deletions .changeset/dark-mode-component-colours.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@equinor/fusion-react-tabs": major
"@equinor/fusion-react-stepper": major
"@equinor/fusion-react-errorboundary": major
"@equinor/fusion-react-ag-grid-utils": major
"@equinor/fusion-react-filter": major
"@equinor/fusion-react-hanging-garden": major
---

Use EDS colour-scheme-aware CSS variables (`var(--eds-color-…)`, and `var(--eds-elevation-low)` for the hanging-garden popover shadow) instead of static colours from the `@equinor/eds-tokens` JavaScript `tokens` object or hard-coded values. Components now follow `data-color-scheme` (light/dark). Spacing and typography sizes still come from `tokens`. The hanging-garden canvas (PIXI) colours remain static.

**Breaking:** Hosts must load `@equinor/eds-tokens/css/variables` directly or through `ThemeProvider` from `@equinor/fusion-react-styles`. Without the stylesheet, the migrated styles no longer have fallback colours.

Ref: equinor/fusion-core-tasks#2755
9 changes: 9 additions & 0 deletions .changeset/dark-mode-react-styles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@equinor/fusion-react-styles": minor
---

Add an optional `colorScheme` prop (`'light' | 'dark' | 'system'`) to `ThemeProvider` and export the `ColorScheme` type. Without the prop, the provider no longer forces light mode and the subtree inherits `data-color-scheme` from its ancestors (for example `<html>`). With `system`, the provider follows `prefers-color-scheme` and updates when it changes.

Apply shared dark canvas, panel and raised surface colours through the existing EDS CSS roles. React and Web Component providers keep those roles in nested dark scopes and restore stock EDS colours in explicit light scopes.

Ref: equinor/fusion-core-tasks#2755
5 changes: 5 additions & 0 deletions .changeset/dark-mode-styles-nested-scheme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@equinor/fusion-react-styles': patch
---

`EdsTokens` re-declares the EDS semantic colour aliases on every `[data-color-scheme]` element, so a dark subtree below a light root (for example a dark `<body>` with portaled content under a light `<html>`) resolves dark values instead of inheriting light ones.
7 changes: 7 additions & 0 deletions .changeset/dark-mode-web-theme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@equinor/fusion-web-theme": minor
---

Follow the EDS colour scheme instead of forcing light mode: the `color-scheme: only light` declaration is removed. Most colour properties now resolve to an EDS 2.x `--eds-color-*` CSS variable (from `@equinor/eds-tokens/css/variables`) without a literal fallback, so the host must load the EDS colour variables. Infographic, logo and overlay colours stay static. Typography colours resolve to EDS 2.x text variables in the same way. The new `colorSchemeVariables` export documents the colour mapping.

Ref: equinor/fusion-core-tasks#2755
10 changes: 10 additions & 0 deletions .changeset/fusion-wc-person-major-dependants.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@equinor/fusion-react-ag-grid-person-cell": major
"@equinor/fusion-react-components": major
---

Follow `@equinor/fusion-react-person` 3 onto `@equinor/fusion-wc-person` 4, so the person cell and the re-exported person components use the colour-scheme-aware person elements. Both resolve the same `fusion-wc-person` copy as `@equinor/fusion-react-person`, so the custom elements are registered once.

**Breaking:** `@equinor/fusion-wc-person` 4 has no fallback colours, so the host must load the `@equinor/eds-tokens` 2.x CSS variables (`@equinor/eds-tokens/css/variables`), for example through `ThemeProvider` from `@equinor/fusion-react-styles`.

Ref: equinor/fusion-core-tasks#2755
12 changes: 12 additions & 0 deletions .changeset/mdc-colour-overrides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@equinor/fusion-web-theme": minor
"@equinor/fusion-react-styles": patch
"@equinor/fusion-react-searchable-dropdown": patch
"@equinor/fusion-react-context-selector": patch
---

Theme the Material (MWC) internals of `fwc-select`, `fwc-searchable-dropdown` and the context selector with EDS colour variables, so they follow light and dark mode.

- `@equinor/fusion-web-theme` exports `mdcColorSchemeVariables` and `mdcColorVariables`, which map the `--mdc-theme-text-*`, `--mdc-select-*` and `--mdc-checkbox-*` properties to `--eds-color-*` variables.
- `ThemeProvider` from `@equinor/fusion-react-styles` declares them on `:root`, on every `[data-color-scheme]` element and on `fwc-theme`, which covers `fwc-select` app-wide.
- `Dropdown` and `SearchableDropdown` add them to `fwc-searchable-dropdown`, so the list text, section titles, icons and check boxes are themed outside a `ThemeProvider` too. The context selector inherits this.
11 changes: 11 additions & 0 deletions .changeset/side-sheet-indicator-colour.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@equinor/fusion-react-side-sheet": major
---

Use EDS colour-scheme-aware CSS variables instead of static `tokens` colours, so the side sheet follows `data-color-scheme` (light/dark).

**Breaking:** Hosts must load `@equinor/eds-tokens/css/variables` directly or through `ThemeProvider` from `@equinor/fusion-react-styles`. Without the stylesheet, the sheet background and default indicator no longer have fallback colours.

The `Indicator` now also accepts a CSS variable (`var(--…)`) as `color`, through the new exported `IndicatorColor` and `CSSVariableString` types, and defaults to `var(--eds-color-bg-danger-fill-emphasis-default)`.

Ref: equinor/fusion-core-tasks#2755
21 changes: 21 additions & 0 deletions .changeset/unreleased-fusion-wc-majors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
"@equinor/fusion-react-styles": major
"@equinor/fusion-react-person": major
"@equinor/fusion-react-markdown": major
"@equinor/fusion-react-skeleton": major
"@equinor/fusion-react-layout": major
"@equinor/fusion-react-context-selector": major
"@equinor/fusion-react-searchable-dropdown": major
"@equinor/fusion-react-textarea": major
"@equinor/fusion-react-list": major
"@equinor/fusion-react-filter": major
---

Depend on the colour-scheme-aware major versions of the Fusion web components, so they follow light and dark mode.

- `@equinor/fusion-wc-theme` 2: `<fwc-theme>` no longer forces light mode and follows the document `data-color-scheme`.
- `@equinor/fusion-wc-avatar` 4, `-chip` 2, `-list` 2, `-markdown` 2, `-page` 1, `-people` 3, `-person` 4, `-searchable-dropdown` 5, `-skeleton` 3 and `-textarea` 2 use EDS CSS colour variables without fallbacks.

**Breaking:** the web components no longer carry fallback colours, so the host must load the `@equinor/eds-tokens` 2.x CSS variables (`@equinor/eds-tokens/css/variables`). `ThemeProvider` from `@equinor/fusion-react-styles` does this. Without it, the components render without colours. `ThemeProvider` and `<fwc-theme>` also stop forcing light mode and follow the document colour scheme; set `data-color-scheme="light"` on `<html>`, or `colorScheme="light"` on `ThemeProvider`, to keep the previous look.

Ref: equinor/fusion-core-tasks#2755
59 changes: 31 additions & 28 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,45 @@ bun run build
bun run start
```

### Temporary light-only Storybook

Storybook's preview document follows the EDS
### Colour scheme (light / dark / system)

Use the **Colour scheme** toolbar item to switch the preview between System, Light and Dark.
The decorator in `storybook/.storybook/preview.tsx` always sets an explicit `light` or `dark`
`data-color-scheme` on the preview `<html>`, the way the Fusion portal passes the scheme down.
For System it resolves `prefers-color-scheme` with `matchMedia` and updates the attribute when
the OS setting changes, as the portal does.
`ThemeProvider` inherits it, and content portaled to `body` follows it too. The body uses the EDS
neutral canvas background and text colours from `preview-head.html`.
Follow the EDS
[colour scheme detection](https://eds.equinor.com/docs/foundation/colour/getting_started#colour-scheme-detection)
guidance: `preview-head.html` declares `<html data-color-scheme="light">`,
which the HTML parser merges onto the preview document's root element before
any styles load. EDS then resolves its light CSS variables and applies
`color-scheme: light`, so EDS colours and native controls stay light on initial
load and when the OS/browser preference changes, including docs canvases and
content portaled to `body`.
Only the preview, where components use EDS CSS variables, is affected; the
Storybook manager UI is left unchanged.

This is a temporary Storybook-only policy for
[equinor/fusion-core-tasks#2120](https://github.com/equinor/fusion-core-tasks/issues/2120),
not dark-mode support or a change to reusable `ThemeProvider` defaults.
Explicit nested color-scheme examples remain free to override the inherited
scheme. Remove the preview head override when Storybook supports automatic theming.
guidance.

Run the regression checks with:

```sh
bun run --cwd storybook test
```

The checks verify the preview head markup and render an EDS CSS variable in
headless Chromium with a dark `prefers-color-scheme`, asserting it resolves to
the EDS light token value. Install the browser once with
`bun run --cwd storybook test:setup`.

For browser verification, load Storybook with both light and dark
`prefers-color-scheme` preferences, then switch each preference live without
reloading. Check an ordinary story, its Docs canvas, and body-portaled
content. The preview root must keep `data-color-scheme="light"`,
EDS colors must remain light, and preview native controls must resolve to
`color-scheme: light`.
The checks verify that `preview-head.html` does not force a scheme. They also render an
EDS CSS colour variable and the classic (EDS 2.x) colour mapping in headless Chromium for Light,
Dark and System (with light and dark `prefers-color-scheme`) and assert each matches the explicit
scheme. They also unit test how System resolves and follows OS changes. Install the browser once
with `bun run --cwd storybook test:setup`.

For browser verification, check an ordinary story, its Docs canvas and body-portaled content
(Tooltip, Menu, Popover, Dialog, Scrim) in each toolbar scheme, and switch the OS preference
while System is selected.

### Colours

Style components with EDS CSS custom properties (`var(--eds-color-…)`), not the JavaScript
`tokens` object from `@equinor/eds-tokens`, whose colours are static light values. Do not
hard-code colours or add literal fallbacks inside `var()`.

Use the stable `@equinor/eds-core-react` 2.x components. They read classic `--eds_*` colour
properties, which the root `ThemeProvider` from `@equinor/fusion-react-styles` maps to EDS colour
variables in dark mode only (see `classicColourDeclarations` in its README). Do not wrap or restyle
them per component for dark mode.

## Development

Expand Down
Loading
Loading