Skip to content
Open
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
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

### Fixed

- _Progress_ now follows the colour mode: its primary colour was fixed to the light value in dark mode.
- Practical guidance and theme colours docs read intent colours from `theme.vars.palette`.

## [v0.8.0] - 2026-11-02

### Added
Expand Down
12 changes: 12 additions & 0 deletions src/components/controls/Progress.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "@testing-library/jest-dom";
import { screen } from "@testing-library/react";

import { renderWithProviders } from "../../__test-utils__/helpers";
import { DiamondDSTheme } from "../../themes/DiamondDSTheme";
import { Progress } from "./Progress";

describe("Progress", () => {
Expand Down Expand Up @@ -36,4 +37,15 @@ describe("Progress", () => {
expect(progressbar.parentElement).toBeInTheDocument();
expect(progressbar.parentElement).toHaveStyle("position:relative");
});

it("should not hardcode the light-mode primary colour", () => {
renderWithProviders(<Progress />);

const css = Array.from(document.querySelectorAll("style"))
.map((style) => style.textContent)
.join("\n");
expect(css).not.toMatch(
new RegExp(`color:\\s*${DiamondDSTheme.palette.primary.main}`, "i"),
);
});
});
18 changes: 9 additions & 9 deletions src/components/controls/Progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const Progress = (props: ProgressProps) => (
{/* Outer */}
<CircularProgress
variant="determinate"
sx={(theme) => ({
color: theme.palette.primary.main,
sx={{
color: "primary.main",
opacity: 0.2,
})}
}}
size={40}
thickness={9}
value={100}
Expand All @@ -43,13 +43,13 @@ const Progress = (props: ProgressProps) => (
{/* Inner */}
<CircularProgress
variant="determinate"
sx={(theme) => ({
color: theme.palette.primary.main,
sx={{
color: "primary.main",
opacity: 0.5,
position: "absolute",
left: 2,
top: 2,
})}
}}
size={36}
thickness={4}
value={100}
Expand All @@ -59,8 +59,8 @@ const Progress = (props: ProgressProps) => (
<CircularProgress
variant="indeterminate"
disableShrink
sx={(theme) => ({
color: theme.palette.primary.main,
sx={{
color: "primary.main",
animationDuration: speed[props.speed ?? "medium"],
position: "absolute",
left: 2.4,
Expand All @@ -72,7 +72,7 @@ const Progress = (props: ProgressProps) => (
["@media (prefers-reduced-motion: reduce)"]: {
animationDuration: speed["verySlow"],
},
})}
}}
size={35}
thickness={2}
/>
Expand Down
53 changes: 43 additions & 10 deletions src/storybook/PracticalGuidance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Components should consume semantic theme roles rather than hardcoded values. The
<tbody>
<tr>
<td>
<code>theme.palette.primary.main</code>
<code>theme.vars.palette.primary.main</code>
</td>
<td>
<code>#005bbb</code>
Expand Down Expand Up @@ -80,6 +80,39 @@ Using semantic roles keeps interfaces consistent across products, supports light
and dark themes, and allows the system to evolve without rewriting component
styles.

### Read intent colours from `theme.vars`

The light, main, dark and contrast text slots of the intent colours (primary, secondary, error, warning, success, info) are fixed hex values on `theme.palette`. Read in code, they give the light theme's colour in both modes and do not change when the mode does. `theme.vars.palette` returns a CSS variable instead, so the colour follows the mode. It is there whenever the theme uses CSS variables, as the Diamond theme does.

<table className="ds-table">
<thead>
<tr>
<th>✅ Prefer</th>
<th>❌ Avoid</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>theme.vars.palette.primary.main</code>
</td>
<td>
<code>theme.palette.primary.main</code>
</td>
</tr>
<tr>
<td>
<code>rgb(var(--ds-primary-channel) / 0.12)</code>
</td>
<td>
<code>alpha(theme.palette.primary.main, 0.12)</code>
</td>
</tr>
</tbody>
</table>

Roles that are already CSS variables, such as text, background, border, surface and the container and solid roles, are safe to read from either. `alpha()`, `lighten()` and `darken()` throw on a `var()` colour, so use the channel tokens for transparency. The tokens for the error intent are named `danger`, so its channel token is `--ds-danger-channel`.

## Using components

Build with existing components and patterns before creating new ones.
Expand Down Expand Up @@ -217,7 +250,7 @@ Brand colour is intentionally separate. Brand communicates Diamond identity rath
<ul>
<li>Use neutral roles for structure.</li>
<li>Use intent roles for meaning.</li>
<li>Use <code>theme.palette</code> or MUI component props so colours work across light and dark themes.</li>
<li>Use theme roles or MUI component props so colours work across light and dark themes.</li>
<li>Ensure disabled and error states override hover, focus and selected styling.</li>
</ul>
</div>
Expand Down Expand Up @@ -253,7 +286,7 @@ Each role includes related tokens for emphasis, contrast, containers, and intera
<code>--ds-[token]</code>
</td>
<td>
<code>palette.[role].main</code>
<code>theme.vars.palette.[role].main</code>
</td>
<td>Main semantic colour</td>
<td>Actions, status communication, emphasis, identity</td>
Expand All @@ -263,7 +296,7 @@ Each role includes related tokens for emphasis, contrast, containers, and intera
<code>--ds-on-[token]</code>
</td>
<td>
<code>palette.[role].contrastText</code>
<code>theme.vars.palette.[role].contrastText</code>
</td>
<td>Foreground colour paired with the role</td>
<td>Text and icons shown on the role colour</td>
Expand All @@ -273,7 +306,7 @@ Each role includes related tokens for emphasis, contrast, containers, and intera
<code>--ds-[token]-emphasis</code>
</td>
<td>
<code>palette.[role].dark</code>
<code>theme.vars.palette.[role].dark</code>
</td>
<td>Stronger variation of the role</td>
<td>Hover, active, or stronger emphasis states</td>
Expand All @@ -283,7 +316,7 @@ Each role includes related tokens for emphasis, contrast, containers, and intera
<code>--ds-[token]-accent</code>
</td>
<td>
<code>palette.[role].light</code>
<code>theme.vars.palette.[role].light</code>
</td>
<td>Lighter accent variation</td>
<td>Focus rings, highlights, supporting accents</td>
Expand All @@ -293,7 +326,7 @@ Each role includes related tokens for emphasis, contrast, containers, and intera
<code>--ds-[token]-container</code>
</td>
<td>
<code>palette.[role].container</code>
<code>theme.vars.palette.[role].container</code>
</td>
<td>Lower-emphasis role surface</td>
<td>Chips, alerts, selected regions, grouped states</td>
Expand All @@ -303,7 +336,7 @@ Each role includes related tokens for emphasis, contrast, containers, and intera
<code>--ds-on-[token]-container</code>
</td>
<td>
<code>palette.[role].onContainer</code>
<code>theme.vars.palette.[role].onContainer</code>
</td>
<td>Foreground colour paired with role containers</td>
<td>Text and icons inside semantic containers</td>
Expand All @@ -313,7 +346,7 @@ Each role includes related tokens for emphasis, contrast, containers, and intera
<code>--ds-[token]-solid</code>
</td>
<td>
<code>palette.[role].solid</code>
<code>theme.vars.palette.[role].solid</code>
</td>
<td>High-emphasis interactive surface</td>
<td>Contained buttons and strong interactive controls</td>
Expand All @@ -323,7 +356,7 @@ Each role includes related tokens for emphasis, contrast, containers, and intera
<code>--ds-on-[token]-solid</code>
</td>
<td>
<code>palette.[role].onSolid</code>
<code>theme.vars.palette.[role].onSolid</code>
</td>
<td>Foreground colour paired with solid surfaces</td>
<td>Text and icons inside solid controls</td>
Expand Down
16 changes: 8 additions & 8 deletions src/storybook/foundation/1. colour.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ Intent and brand colours follow a shared semantic structure.
<code>--ds-[token]</code>
</td>
<td>
<code>palette.[role].main</code>
<code>theme.vars.palette.[role].main</code>
</td>
<td>Main semantic colour</td>
<td>Actions, status communication, emphasis, identity</td>
Expand All @@ -793,7 +793,7 @@ Intent and brand colours follow a shared semantic structure.
<code>--ds-on-[token]</code>
</td>
<td>
<code>palette.[role].contrastText</code>
<code>theme.vars.palette.[role].contrastText</code>
</td>
<td>Foreground colour paired with the role</td>
<td>Text and icons shown on the role colour</td>
Expand All @@ -803,7 +803,7 @@ Intent and brand colours follow a shared semantic structure.
<code>--ds-[token]-emphasis</code>
</td>
<td>
<code>palette.[role].dark</code>
<code>theme.vars.palette.[role].dark</code>
</td>
<td>Stronger variation of the role</td>
<td>Hover, active, or stronger emphasis states</td>
Expand All @@ -813,7 +813,7 @@ Intent and brand colours follow a shared semantic structure.
<code>--ds-[token]-accent</code>
</td>
<td>
<code>palette.[role].light</code>
<code>theme.vars.palette.[role].light</code>
</td>
<td>Lighter accent variation</td>
<td>Focus rings, highlights, supporting accents</td>
Expand All @@ -823,7 +823,7 @@ Intent and brand colours follow a shared semantic structure.
<code>--ds-[token]-container</code>
</td>
<td>
<code>palette.[role].container</code>
<code>theme.vars.palette.[role].container</code>
</td>
<td>Lower-emphasis role surface</td>
<td>Chips, alerts, selected regions, grouped states</td>
Expand All @@ -833,7 +833,7 @@ Intent and brand colours follow a shared semantic structure.
<code>--ds-on-[token]-container</code>
</td>
<td>
<code>palette.[role].onContainer</code>
<code>theme.vars.palette.[role].onContainer</code>
</td>
<td>Foreground colour paired with role containers</td>
<td>Text and icons inside semantic containers</td>
Expand All @@ -843,7 +843,7 @@ Intent and brand colours follow a shared semantic structure.
<code>--ds-[token]-solid</code>
</td>
<td>
<code>palette.[role].solid</code>
<code>theme.vars.palette.[role].solid</code>
</td>
<td>High-emphasis interactive surface</td>
<td>Contained buttons and strong interactive controls</td>
Expand All @@ -853,7 +853,7 @@ Intent and brand colours follow a shared semantic structure.
<code>--ds-on-[token]-solid</code>
</td>
<td>
<code>palette.[role].onSolid</code>
<code>theme.vars.palette.[role].onSolid</code>
</td>
<td>Foreground colour paired with solid surfaces</td>
<td>Text and icons inside solid controls</td>
Expand Down
4 changes: 2 additions & 2 deletions src/storybook/foundation/1.1. theme-colours.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This page is a token reference. If you're deciding which colour role to use, rea
<section>
<h3>Intent colours</h3>
<p>
Exposed as MUI palette roles (e.g. <code>theme.palette.primary.main</code>
Exposed as MUI palette roles (e.g. <code>theme.vars.palette.primary.main</code>
).
</p>
<div className="ds-intent-grid">
Expand Down Expand Up @@ -246,7 +246,7 @@ This page is a token reference. If you're deciding which colour role to use, rea
<section>
<h3>Intent colours</h3>
<p>
Exposed as MUI palette roles (e.g. <code>theme.palette.primary.main</code>
Exposed as MUI palette roles (e.g. <code>theme.vars.palette.primary.main</code>
).
</p>
<div className="ds-intent-grid">
Expand Down
Loading