@canonical/styles 0.20.0 → 0.21.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/package.json +18 -6
- package/src/fonts.css +48 -0
- package/src/grid.css +67 -15
- package/src/index.css +2 -2
- package/src/spacing.css +118 -0
- package/src/tmp.css +0 -23
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/styles",
|
|
3
3
|
"description": "Canonical Design System global stylesheet. Aggregates normalize, typography, and design tokens.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.0",
|
|
5
5
|
"main": "src/index.css",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.css",
|
|
8
|
+
"./fonts": "./src/fonts.css"
|
|
9
|
+
},
|
|
6
10
|
"files": [
|
|
7
11
|
"src"
|
|
8
12
|
],
|
|
@@ -22,13 +26,21 @@
|
|
|
22
26
|
"check:biome:fix": "biome check --write"
|
|
23
27
|
},
|
|
24
28
|
"devDependencies": {
|
|
25
|
-
"@biomejs/biome": "2.4.
|
|
26
|
-
"@canonical/biome-config": "^0.
|
|
29
|
+
"@biomejs/biome": "2.4.9",
|
|
30
|
+
"@canonical/biome-config": "^0.21.0"
|
|
27
31
|
},
|
|
28
32
|
"dependencies": {
|
|
29
|
-
"@canonical/design-tokens": "^0.
|
|
30
|
-
"@canonical/styles-typography": "^0.
|
|
33
|
+
"@canonical/design-tokens": "^0.6.0",
|
|
34
|
+
"@canonical/styles-typography": "^0.21.0",
|
|
31
35
|
"normalize.css": "^8.0.1"
|
|
32
36
|
},
|
|
33
|
-
"
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@canonical/ds-assets": ">=0.18.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"@canonical/ds-assets": {
|
|
42
|
+
"optional": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"gitHead": "4a39c954e7bbad4903397f8371f801982034a26d"
|
|
34
46
|
}
|
package/src/fonts.css
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* @canonical/styles — Font loading (Ubuntu Sans, self-hosted)
|
|
2
|
+
*
|
|
3
|
+
* Variable fonts from @canonical/ds-assets.
|
|
4
|
+
* Licensed under Ubuntu Font License v1.0.
|
|
5
|
+
*
|
|
6
|
+
* Opt-in: import this file to load the Ubuntu Sans font family.
|
|
7
|
+
*
|
|
8
|
+
* @import url("@canonical/styles/fonts");
|
|
9
|
+
* @import url("@canonical/styles");
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@font-face {
|
|
13
|
+
font-family: "Ubuntu Sans";
|
|
14
|
+
src: url("@canonical/ds-assets/fonts/ubuntu-sans/UbuntuSans[wdth,wght].woff2")
|
|
15
|
+
format("woff2-variations");
|
|
16
|
+
font-weight: 100 900;
|
|
17
|
+
font-stretch: 62.5% 100%;
|
|
18
|
+
font-style: normal;
|
|
19
|
+
font-display: swap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@font-face {
|
|
23
|
+
font-family: "Ubuntu Sans";
|
|
24
|
+
src: url("@canonical/ds-assets/fonts/ubuntu-sans/UbuntuSans-Italic[wdth,wght].woff2")
|
|
25
|
+
format("woff2-variations");
|
|
26
|
+
font-weight: 100 900;
|
|
27
|
+
font-stretch: 62.5% 100%;
|
|
28
|
+
font-style: italic;
|
|
29
|
+
font-display: swap;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@font-face {
|
|
33
|
+
font-family: "Ubuntu Sans Mono";
|
|
34
|
+
src: url("@canonical/ds-assets/fonts/ubuntu-sans/UbuntuSansMono[wght].woff2")
|
|
35
|
+
format("woff2-variations");
|
|
36
|
+
font-weight: 100 900;
|
|
37
|
+
font-style: normal;
|
|
38
|
+
font-display: swap;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@font-face {
|
|
42
|
+
font-family: "Ubuntu Sans Mono";
|
|
43
|
+
src: url("@canonical/ds-assets/fonts/ubuntu-sans/UbuntuSansMono-Italic[wght].woff2")
|
|
44
|
+
format("woff2-variations");
|
|
45
|
+
font-weight: 100 900;
|
|
46
|
+
font-style: italic;
|
|
47
|
+
font-display: swap;
|
|
48
|
+
}
|
package/src/grid.css
CHANGED
|
@@ -1,19 +1,67 @@
|
|
|
1
1
|
/* @canonical/styles — Grid layout presets
|
|
2
2
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* .
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
3
|
+
* ┌─────────────────────────────────────────────────────────────┐
|
|
4
|
+
* │ Three grid modes │
|
|
5
|
+
* ├──────────────┬──────────────────────────────────────────────┤
|
|
6
|
+
* │ .responsive │ Breakpoint-driven: 4-col / 8-col / 12-col │
|
|
7
|
+
* │ .intrinsic │ Fluid auto-fill, groups of 4 columns │
|
|
8
|
+
* │ (bare) │ No preset — bring your own columns │
|
|
9
|
+
* └──────────────┴──────────────────────────────────────────────┘
|
|
10
|
+
*
|
|
11
|
+
* Classes:
|
|
12
|
+
* .grid Base grid context (display: grid)
|
|
13
|
+
* .grid.responsive Breakpoint-driven column grid
|
|
14
|
+
* .grid.intrinsic Fluid auto-fill grid
|
|
15
|
+
* .subgrid CSS subgrid child — inherits parent columns
|
|
16
|
+
*
|
|
17
|
+
* Customization:
|
|
18
|
+
* --grid-gap Shorthand: sets both row-gap and column-gap (default: var(--grid-gutter))
|
|
19
|
+
* --grid-row-gap Block-direction (vertical) gap between rows
|
|
20
|
+
* --grid-column-gap Inline-direction (horizontal) gap between columns
|
|
21
|
+
* --grid-col-min Minimum column width for intrinsic mode (default: 100px)
|
|
22
|
+
* --subgrid-span Column span for subgrid children (default: 1 / -1, full width)
|
|
23
|
+
*
|
|
24
|
+
* Breakpoints (responsive mode):
|
|
25
|
+
* < 768px 4 columns (mobile)
|
|
26
|
+
* 768px – 1279px 8 columns (tablet)
|
|
27
|
+
* ≥ 1280px 12 columns (desktop)
|
|
28
|
+
*
|
|
29
|
+
* Relationship to spacing architecture:
|
|
30
|
+
* The grid provides horizontal structure. Vertical spacing between
|
|
31
|
+
* grid items is handled by the spacing architecture tokens
|
|
32
|
+
* (--container-gap-* for app UI, element margin-bottom for editorial).
|
|
33
|
+
* The --grid-gap property controls both axes unless overridden
|
|
34
|
+
* per-axis with --grid-row-gap or --grid-column-gap.
|
|
35
|
+
*
|
|
36
|
+
* Usage examples:
|
|
37
|
+
*
|
|
38
|
+
* <!-- Responsive 12-column layout -->
|
|
39
|
+
* <div class="grid responsive">
|
|
40
|
+
* <main style="grid-column: span 8">Content</main>
|
|
41
|
+
* <aside style="grid-column: span 4">Sidebar</aside>
|
|
42
|
+
* </div>
|
|
43
|
+
*
|
|
44
|
+
* <!-- Fluid card grid -->
|
|
45
|
+
* <div class="grid intrinsic">
|
|
46
|
+
* <article>Card 1</article>
|
|
47
|
+
* <article>Card 2</article>
|
|
48
|
+
* </div>
|
|
49
|
+
*
|
|
50
|
+
* <!-- Subgrid for aligned form fields -->
|
|
51
|
+
* <div class="grid responsive">
|
|
52
|
+
* <form class="subgrid">
|
|
53
|
+
* <div class="subgrid" style="grid-column: span 6">
|
|
54
|
+
* <label>Name</label>
|
|
55
|
+
* <input />
|
|
56
|
+
* </div>
|
|
57
|
+
* </form>
|
|
58
|
+
* </div>
|
|
59
|
+
*
|
|
60
|
+
* <!-- Custom gap -->
|
|
61
|
+
* <div class="grid responsive" style="--grid-gap: 2rem">...</div>
|
|
62
|
+
*
|
|
63
|
+
* <!-- Separate row/column gaps -->
|
|
64
|
+
* <div class="grid responsive" style="--grid-row-gap: 1.5rem; --grid-column-gap: 1rem">...</div>
|
|
17
65
|
*/
|
|
18
66
|
|
|
19
67
|
@layer ds.components {
|
|
@@ -30,7 +78,11 @@
|
|
|
30
78
|
.grid {
|
|
31
79
|
display: grid;
|
|
32
80
|
grid-template-columns: var(--modifier-grid-template);
|
|
33
|
-
gap: var(
|
|
81
|
+
column-gap: var(
|
|
82
|
+
--grid-column-gap,
|
|
83
|
+
var(--grid-gap, var(--grid-gutter, 1.5rem))
|
|
84
|
+
);
|
|
85
|
+
row-gap: var(--grid-row-gap, var(--grid-gap, var(--grid-gutter, 1.5rem)));
|
|
34
86
|
}
|
|
35
87
|
|
|
36
88
|
.responsive {
|
package/src/index.css
CHANGED
package/src/spacing.css
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* @canonical/styles — Spacing architecture tokens
|
|
2
|
+
*
|
|
3
|
+
* Provisional tokens implementing the spacing architecture spec v0.4.
|
|
4
|
+
* Two modes: element-owned (editorial) and container-owned (app UI).
|
|
5
|
+
* Will migrate to @canonical/design-tokens once validated.
|
|
6
|
+
*
|
|
7
|
+
* Terminology:
|
|
8
|
+
* block = vertical axis (block-start = top, block-end = bottom)
|
|
9
|
+
* inline = horizontal axis (inline-start = left in LTR, right in RTL)
|
|
10
|
+
*
|
|
11
|
+
* Convention: ALL available custom properties are listed here.
|
|
12
|
+
* Commented-out properties are valid extension points that consumers
|
|
13
|
+
* or themes may set; they are documented so the full API surface
|
|
14
|
+
* is visible in one place.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
:root {
|
|
18
|
+
/* ── Baseline grid ──────────────────────────────────────────────── */
|
|
19
|
+
--space-baseline: var(
|
|
20
|
+
--dimension-size-height-baseline,
|
|
21
|
+
0.5rem
|
|
22
|
+
); /* 8px — bU */
|
|
23
|
+
--baseline-height: var(
|
|
24
|
+
--space-baseline
|
|
25
|
+
); /* alias consumed by typography engine */
|
|
26
|
+
|
|
27
|
+
/* ── Spacing scale (semantic aliases) ───────────────────────────── */
|
|
28
|
+
--space-0: 0;
|
|
29
|
+
--space-025: var(--dimension-025); /* 0.125rem / 2px — micro */
|
|
30
|
+
--space-050: var(--dimension-050); /* 0.25rem / 4px — xxs */
|
|
31
|
+
--space-100: var(--dimension-100); /* 0.5rem / 8px — xs (1bU) */
|
|
32
|
+
--space-150: var(--dimension-150); /* 0.75rem / 12px — sm */
|
|
33
|
+
--space-200: var(--dimension-200); /* 1rem / 16px — md (2bU) */
|
|
34
|
+
--space-300: var(--dimension-300); /* 1.5rem / 24px — lg (3bU) */
|
|
35
|
+
--space-400: var(--dimension-400); /* 2rem / 32px — xl (4bU) */
|
|
36
|
+
--space-600: var(--dimension-600); /* 3rem / 48px — 2xl */
|
|
37
|
+
--space-800: var(--dimension-800); /* 4rem / 64px — 3xl */
|
|
38
|
+
|
|
39
|
+
/* ── Element-owned spacing (margin-block-end) ───────────────────── */
|
|
40
|
+
/* Direction: block-end (downward in horizontal writing modes). */
|
|
41
|
+
/* */
|
|
42
|
+
/* For typographic elements (h1-h6, p, .p), space-after is */
|
|
43
|
+
/* implemented in @canonical/styles-typography mapper.css as a */
|
|
44
|
+
/* unitless --space-after variable (in baseline-height units) */
|
|
45
|
+
/* consumed by the baseline engine: */
|
|
46
|
+
/* margin-bottom: calc(bottom-nudge + space-after × baseline-height) */
|
|
47
|
+
/* */
|
|
48
|
+
/* Default: --space-after: 0 on all elements (app UI contexts). */
|
|
49
|
+
/* Editorial/prose contexts opt in via the .editorial class: */
|
|
50
|
+
/* h1, h2: --space-after: 2 (= 2 × 0.5rem = 1rem = 16px) */
|
|
51
|
+
/* h3-h6, p: --space-after: 1 (= 1 × 0.5rem = 0.5rem = 8px) */
|
|
52
|
+
/* */
|
|
53
|
+
/* The tokens below are for NON-typographic elements. */
|
|
54
|
+
/* When the spacing architecture is finalised, the typography */
|
|
55
|
+
/* mapper should read FROM these tokens instead of hardcoding. */
|
|
56
|
+
--spaceAfter-button: var(--space-200); /* 1rem / 16px — block-end margin */
|
|
57
|
+
/* --spaceAfter-figure: var(--space-300); */ /* block-end margin for figures */
|
|
58
|
+
/* --spaceAfter-list: var(--space-200); */ /* block-end margin for ul/ol */
|
|
59
|
+
/* --spaceAfter-table: var(--space-300); */ /* block-end margin for tables */
|
|
60
|
+
/* --spaceAfter-hr: var(--space-400); */ /* block-end margin for <hr> */
|
|
61
|
+
|
|
62
|
+
/* ── Container-owned spacing (gap values) ───────────────────────── */
|
|
63
|
+
/* Used in application UI contexts: forms, dashboards, cards. */
|
|
64
|
+
/* These are axis-agnostic by default — containers apply them to */
|
|
65
|
+
/* whichever axis they need (block-direction gap for stacked forms, */
|
|
66
|
+
/* inline-direction gap for button rows, both for grids). */
|
|
67
|
+
--container-gap-tight: var(--space-050); /* 4px — dense key-value pairs */
|
|
68
|
+
--container-gap-default: var(--space-200); /* 16px — standard card/form gap */
|
|
69
|
+
--container-gap-loose: var(--space-300); /* 24px — sections, visual break */
|
|
70
|
+
|
|
71
|
+
/* Per-axis container gap overrides (set by consumers, not defined here): */
|
|
72
|
+
/* --container-gap-block: … ; */ /* block-direction gap override */
|
|
73
|
+
/* --container-gap-inline: … ; */ /* inline-direction gap override */
|
|
74
|
+
|
|
75
|
+
/* ── Intra-component spacing ────────────────────────────────────── */
|
|
76
|
+
/* Component-owned: internal padding regardless of context. */
|
|
77
|
+
--component-padding-block: var(
|
|
78
|
+
--space-100
|
|
79
|
+
); /* 8px — block (vertical) padding */
|
|
80
|
+
--component-padding-inline: var(
|
|
81
|
+
--space-200
|
|
82
|
+
); /* 16px — inline (horizontal) padding */
|
|
83
|
+
|
|
84
|
+
/* Per-side component padding overrides (set by themes/consumers): */
|
|
85
|
+
/* --component-padding-block-start: … ; */ /* top padding override */
|
|
86
|
+
/* --component-padding-block-end: … ; */ /* bottom padding override */
|
|
87
|
+
/* --component-padding-inline-start: … ; */ /* left (LTR) padding */
|
|
88
|
+
/* --component-padding-inline-end: … ; */ /* right (LTR) padding */
|
|
89
|
+
|
|
90
|
+
/* ── Layout grid ────────────────────────────────────────────────── */
|
|
91
|
+
--grid-gutter: var(
|
|
92
|
+
--space-200
|
|
93
|
+
); /* 16px / 1rem — column gutters (inline-direction) */
|
|
94
|
+
--grid-margin: var(
|
|
95
|
+
--space-400
|
|
96
|
+
); /* 32px / 2rem — outer page margin (inline-direction) */
|
|
97
|
+
|
|
98
|
+
/* Grid gap axis overrides (consumed by grid.css): */
|
|
99
|
+
/* --grid-gap: … ; */ /* shorthand: sets both row-gap and column-gap */
|
|
100
|
+
/* --grid-row-gap: … ; */ /* block-direction gap between grid rows */
|
|
101
|
+
/* --grid-column-gap: … ; */ /* inline-direction gap between grid columns */
|
|
102
|
+
|
|
103
|
+
/* ── Heading alignment ──────────────────────────────────────────── */
|
|
104
|
+
/* Inline padding for headings to align with padded blocks. */
|
|
105
|
+
/* --heading-padding-inline: … ; */ /* set by layout context, default 0 */
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* ── Content-flow container ─────────────────────────────────────── */
|
|
109
|
+
|
|
110
|
+
@layer ds.components {
|
|
111
|
+
/* Content-flow container: establishes element-owned spacing context.
|
|
112
|
+
* Children use their own margin-bottom; last child is reset to 0
|
|
113
|
+
* to prevent double spacing at the container boundary.
|
|
114
|
+
*/
|
|
115
|
+
.content-flow > :last-child {
|
|
116
|
+
margin-bottom: 0;
|
|
117
|
+
}
|
|
118
|
+
}
|
package/src/tmp.css
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
}
|