@canonical/styles 0.17.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,70 @@
1
- ## Canonical Web Team Styles
1
+ # @canonical/styles
2
2
 
3
+ Global stylesheet for the Canonical Design System. Single import that aggregates normalize, typography, and design tokens into a layered cascade.
3
4
 
5
+ ## Installation
4
6
 
7
+ ```bash
8
+ bun add @canonical/styles
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Import once in your application entry point:
14
+
15
+ ```css
16
+ @import url("@canonical/styles");
17
+ ```
18
+
19
+ Or in JavaScript/TypeScript:
20
+
21
+ ```ts
22
+ import "@canonical/styles";
23
+ ```
24
+
25
+ This single import provides:
26
+
27
+ - **CSS reset** via [normalize.css](https://github.com/necolas/normalize.css)
28
+ - **Typography baseline grid** via `@canonical/styles-typography`
29
+ - **Design tokens** (colour, spacing, surfaces, states) via `@canonical/design-tokens`
30
+ - **`color-scheme: light dark`** on `:root` for `light-dark()` support
31
+
32
+ ## Cascade Layers
33
+
34
+ The stylesheet establishes a deterministic layer order:
35
+
36
+ ```css
37
+ @layer normalize, ds.reset, ds.modifiers, ds.components;
38
+ ```
39
+
40
+ This ensures that component styles always override modifier styles, which always override resets, regardless of source order in consuming applications.
41
+
42
+ ## Design Tokens
43
+
44
+ The following token sets from `@canonical/design-tokens` are included:
45
+
46
+ | Token Set | Contents |
47
+ |-----------|----------|
48
+ | `sets.primitive` | Base colour palette, spacing scale, font sizes |
49
+ | `modifiers.theme` | Light/dark theme mappings |
50
+ | `modifiers.surfaces` | Surface elevation tokens |
51
+ | `modifiers.anticipation` | Constructive/destructive/caution intents |
52
+ | `modifiers.criticality` | Error/warning/success/information states |
53
+ | `modifiers.emphasis` | Branded/highlighted/muted emphasis |
54
+ | `modifiers.importance` | Primary/secondary importance levels |
55
+ | `states` | Interactive state tokens (hover, active, focus, disabled) |
56
+
57
+ ## Dependencies
58
+
59
+ | Package | Role |
60
+ |---------|------|
61
+ | `@canonical/design-tokens` | CSS custom properties for colour, spacing, and states |
62
+ | `@canonical/styles-typography` | Baseline grid engine and typographic scale |
63
+ | `normalize.css` | Cross-browser CSS reset |
64
+
65
+ ## Package Structure
66
+
67
+ ```
68
+ src/
69
+ index.css -- entry point, imports all dependencies
70
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/styles",
3
- "description": "Canonical's base styles",
4
- "version": "0.17.1",
3
+ "description": "Canonical Design System global stylesheet. Aggregates normalize, typography, and design tokens.",
4
+ "version": "0.20.0",
5
5
  "main": "src/index.css",
6
6
  "files": [
7
7
  "src"
@@ -12,13 +12,9 @@
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "https://github.com/canonical/ds25"
15
+ "url": "https://github.com/canonical/pragma"
16
16
  },
17
17
  "license": "LGPL-3.0",
18
- "bugs": {
19
- "url": "https://github.com/canonical/ds25/issues"
20
- },
21
- "homepage": "https://github.com/canonical/ds25#readme",
22
18
  "scripts": {
23
19
  "check": "bun run check:biome",
24
20
  "check:fix": "bun run check:biome:fix",
@@ -26,17 +22,13 @@
26
22
  "check:biome:fix": "biome check --write"
27
23
  },
28
24
  "devDependencies": {
29
- "@biomejs/biome": "2.4.5",
30
- "@canonical/biome-config": "^0.17.1"
25
+ "@biomejs/biome": "2.4.6",
26
+ "@canonical/biome-config": "^0.20.0"
31
27
  },
32
28
  "dependencies": {
33
- "@canonical/styles-elements": "^0.17.1",
34
- "@canonical/styles-modes-canonical": "^0.17.1",
35
- "@canonical/styles-modes-density": "^0.17.1",
36
- "@canonical/styles-modes-intents": "^0.17.1",
37
- "@canonical/styles-modes-motion": "^0.17.1",
38
- "@canonical/styles-primitives-canonical": "^0.17.1",
29
+ "@canonical/design-tokens": "^0.5.2",
30
+ "@canonical/styles-typography": "^0.20.0",
39
31
  "normalize.css": "^8.0.1"
40
32
  },
41
- "gitHead": "e3eaaa9efdb58fa72acb8fdd3c7dffa25a1341c4"
33
+ "gitHead": "1aee634b278922f2aa1cfe2a11d3b14e64280905"
42
34
  }
package/src/grid.css ADDED
@@ -0,0 +1,57 @@
1
+ /* @canonical/styles — Grid layout presets
2
+ *
3
+ * .grid — establishes a grid context
4
+ * .grid.responsive — 4 / 8 / 12 column responsive grid (breakpoint-driven)
5
+ * .grid.intrinsic — fluid auto-fill grid (groups of 4)
6
+ * .subgrid — subgrid child, inherits parent columns
7
+ *
8
+ * The .grid class subscribes to --modifier-grid-template.
9
+ * If no modifier is set, grid-template-columns is not declared
10
+ * and the grid behaves as a plain block-level grid context.
11
+ *
12
+ * Usage:
13
+ * <div class="grid responsive"> — 8-col fixed
14
+ * <div class="grid intrinsic"> — fluid auto-fill
15
+ * <div class="grid"> — bare context, bring your own columns
16
+ * <div class="subgrid"> — inherits parent columns
17
+ */
18
+
19
+ @layer ds.components {
20
+ :root {
21
+ --grid-col-min: 100px;
22
+
23
+ --grid-intrinsic: repeat(
24
+ auto-fill,
25
+ minmax(var(--grid-col-min), 1fr) minmax(var(--grid-col-min), 1fr)
26
+ minmax(var(--grid-col-min), 1fr) minmax(var(--grid-col-min), 1fr)
27
+ );
28
+ }
29
+
30
+ .grid {
31
+ display: grid;
32
+ grid-template-columns: var(--modifier-grid-template);
33
+ gap: var(--grid-gap, 1rem);
34
+ }
35
+
36
+ .responsive {
37
+ --modifier-grid-template: repeat(4, 1fr);
38
+
39
+ @media (min-width: 768px) {
40
+ --modifier-grid-template: repeat(8, 1fr);
41
+ }
42
+
43
+ @media (min-width: 1280px) {
44
+ --modifier-grid-template: repeat(12, 1fr);
45
+ }
46
+ }
47
+
48
+ .intrinsic {
49
+ --modifier-grid-template: var(--grid-intrinsic);
50
+ }
51
+
52
+ .subgrid {
53
+ display: grid;
54
+ grid-template-columns: subgrid;
55
+ grid-column: var(--subgrid-span, 1 / -1);
56
+ }
57
+ }
package/src/index.css CHANGED
@@ -1,13 +1,30 @@
1
- @layer normalize, primitives, modes, elements;
1
+ /* @canonical/styles — Global stylesheet entry point
2
+ *
3
+ * Single import for consumers:
4
+ * @import url("@canonical/styles");
5
+ */
6
+
7
+ /* Layer ordering — deterministic cascade (spec §C.2) */
8
+ @layer normalize, ds.reset, ds.modifiers, ds.components;
2
9
 
3
10
  /* Reset */
4
11
  @import url("normalize.css");
5
- /* Load external files first */
6
- /* TODO Ideally we would load the font-faces before this */
7
-
8
- @import url("@canonical/styles-primitives-canonical");
9
- @import url("@canonical/styles-modes-canonical");
10
- @import url("@canonical/styles-modes-density");
11
- @import url("@canonical/styles-modes-motion");
12
- @import url("@canonical/styles-modes-intents");
13
- @import url("@canonical/styles-elements");
12
+
13
+ /* Typography: interpreter engine + scale tokens */
14
+ @import url("@canonical/styles-typography");
15
+
16
+ /* Design tokens — colour, spacing, surfaces, states */
17
+ @import url("@canonical/design-tokens/dist/sets.primitive.css");
18
+ @import url("@canonical/design-tokens/dist/modifiers.theme.css");
19
+ @import url("@canonical/design-tokens/dist/modifiers.surfaces.css");
20
+ @import url("@canonical/design-tokens/dist/modifiers.anticipation.css");
21
+ @import url("@canonical/design-tokens/dist/modifiers.criticality.css");
22
+ @import url("@canonical/design-tokens/dist/modifiers.emphasis.css");
23
+ @import url("@canonical/design-tokens/dist/modifiers.importance.css");
24
+ @import url("@canonical/design-tokens/dist/states.css");
25
+
26
+ /* Grid layout presets */
27
+ @import url("./grid.css");
28
+
29
+ /* Temporary semantic tokens (candidates for design-tokens) */
30
+ @import url("./tmp.css");
package/src/tmp.css ADDED
@@ -0,0 +1,23 @@
1
+ /* @canonical/styles — Temporary semantic tokens
2
+ *
3
+ * Candidates for upstreaming to @canonical/design-tokens once validated.
4
+ * Prefixed --tmp- to signal provisional status.
5
+ */
6
+
7
+ :root {
8
+ --tmp-space-input-block: var(
9
+ --dimension-100
10
+ ); /* 0.5rem — vertical padding inside inputs */
11
+ --tmp-space-input-inline: var(
12
+ --dimension-150
13
+ ); /* 0.75rem — horizontal padding inside inputs */
14
+ --tmp-space-field-gap: var(
15
+ --dimension-300
16
+ ); /* 1.5rem — gap between form fields */
17
+ --tmp-space-field-inline: var(
18
+ --dimension-100
19
+ ); /* 0.5rem — gap between label and input */
20
+ --tmp-space-group-gap: var(
21
+ --dimension-050
22
+ ); /* 0.25rem — gap between description/error and input */
23
+ }