@canonical/styles 0.3.0-experimental.0 → 0.4.0-experimental.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/styles",
3
3
  "description": "Canonical's base styles",
4
- "version": "0.3.0-experimental.0",
4
+ "version": "0.4.0-experimental.0",
5
5
  "main": "src/index.css",
6
6
  "files": [
7
7
  "src"
@@ -20,20 +20,17 @@
20
20
  },
21
21
  "homepage": "https://github.com/canonical/ds25#readme",
22
22
  "scripts": {
23
- "lint": "biome lint src/*.{css}",
24
- "format": "bun run format:biome",
25
- "format:biome": "biome format src/*.{css}",
26
23
  "check": "bun run check:biome",
27
24
  "check:fix": "bun run check:biome:fix",
28
- "check:biome": "biome check src/* *.json",
29
- "check:biome:fix": "biome check --write src/* *.json"
25
+ "check:biome": "biome check src *.json",
26
+ "check:biome:fix": "biome check --write src *.json"
30
27
  },
31
28
  "devDependencies": {
32
- "@biomejs/biome": "^1.9.2",
33
- "@canonical/biome-config": "^0.3.0-experimental.0"
29
+ "@biomejs/biome": "^1.9.4",
30
+ "@canonical/biome-config": "^0.4.0-experimental.0"
34
31
  },
35
32
  "dependencies": {
36
33
  "normalize.css": "^8.0.1"
37
34
  },
38
- "gitHead": "49b4177ce486e89e72e913f4b647469b6a3e5e63"
35
+ "gitHead": "c1d4c3d77c4d7a522359babd05186dbf65aca801"
39
36
  }
@@ -0,0 +1,24 @@
1
+ .show-baseline-grid {
2
+ --color-baseline-grid: rgba(255, 0, 0, 0.2);
3
+ position: relative;
4
+
5
+ &::after {
6
+ background: linear-gradient(
7
+ to top,
8
+ var(--color-baseline-grid),
9
+ var(--color-baseline-grid) 1px,
10
+ transparent 1px,
11
+ transparent
12
+ );
13
+ background-size: 100% var(--sp-unit);
14
+ bottom: 0;
15
+ content: "";
16
+ display: block;
17
+ left: 0;
18
+ pointer-events: none;
19
+ position: absolute;
20
+ right: 0;
21
+ top: 0;
22
+ z-index: 200;
23
+ }
24
+ }
@@ -1,3 +1,9 @@
1
+ /*
2
+ TODO
3
+ - add optional character subset version of the font - how to do it conditinoally?
4
+ - reconsider the font-family name - "Ubuntu variable" was a workaround for backwards compatibility with previous "Ubuntu" web font, do we still need this? what would happen if we change it to "Ubuntu"?
5
+ */
6
+
1
7
  /* Ubuntu font declarations, as per Vanilla */
2
8
  @font-face {
3
9
  font-family: "Ubuntu variable";
package/src/index.css CHANGED
@@ -1,17 +1,13 @@
1
+ /* Reset */
1
2
  @import url("normalize.css");
3
+
4
+ /* Values and settings */
2
5
  @import url("./tokens.css");
3
6
  @import url("./font-faces.css");
7
+
8
+ /* Foundations styling */
9
+ @import url("./typography.css");
4
10
  @import url("./intents.css");
5
11
 
6
- html {
7
- color: #000;
8
- font-family: "Ubuntu variable", "Ubuntu", -apple-system, "Segoe UI", "Roboto",
9
- "Oxygen", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
10
- sans-serif;
11
- -moz-osx-font-smoothing: grayscale;
12
- -webkit-font-smoothing: antialiased;
13
- font-weight: 400;
14
- line-height: 1.5rem;
15
- text-wrap: pretty;
16
- font-size: 1rem;
17
- }
12
+ /* Debugging utilities */
13
+ @import url("./baseline-grid.css");
package/src/intents.css CHANGED
@@ -1,7 +1,29 @@
1
1
  .positive {
2
- --color: green;
2
+ --intent-color: var(--color-background-positive-default);
3
+ --intent-color-hover: var(--color-background-positive-hover);
4
+ --intent-color-active: var(--color-background-positive-active);
5
+ --intent-color-text: var(--color-background-positive-text);
6
+ --intent-color-border: var(--intent-color);
7
+ --intent-color-border-hover: var(--intent-color-hover);
8
+ --intent-color-border-active: var(--intent-color-active);
3
9
  }
4
10
 
5
11
  .negative {
6
- --color: red;
12
+ --intent-color: var(--color-background-negative-default);
13
+ --intent-color-hover: var(--color-background-negative-hover);
14
+ --intent-color-active: var(--color-background-negative-active);
15
+ --intent-color-text: var(--color-background-negative-text);
16
+ --intent-color-border: var(--intent-color);
17
+ --intent-color-border-hover: var(--intent-color-hover);
18
+ --intent-color-border-active: var(--intent-color-active);
19
+ }
20
+
21
+ .neutral {
22
+ --intent-color: var(--color-background-default);
23
+ --intent-color-hover: var(--color-background-hover);
24
+ --intent-color-active: var(--color-background-active);
25
+ --intent-color-text: var(--color-text-default);
26
+ --intent-color-border: var(--color-border-high-contrast);
27
+ --intent-color-border-hover: var(--intent-color-border);
28
+ --intent-color-border-active: var(--intent-color-border);
7
29
  }
package/src/tokens.css CHANGED
@@ -1,9 +1,14 @@
1
+ /* TODO: this should potentially be part of the theme definition, as it implements design decisions specific to the theme */
2
+
1
3
  /* base tokens */
2
4
  :root {
3
5
  /* color tokens */
4
6
  /* based on: https://docs.google.com/spreadsheets/d/1AY6BLFU-Cnj48ggHUnNVlWRxwWZ6Z-66s7jxJC1HLSU/edit?gid=1738212977#gid=1738212977 */
5
- --color-background-default: #fff;
6
- --color-text-default: #000;
7
+ --color-palette-white: #fff;
8
+ --color-palette-black: #000;
9
+
10
+ --color-background-default: var(--color-palette-white);
11
+ --color-text-default: var(--color-palette-black);
7
12
  --color-background-hover: rgba(242, 242, 242, 1);
8
13
  --color-background-active: rgba(235, 235, 235, 1);
9
14
  --color-border-high-contrast: rgba(0, 0, 0, 0.56);
@@ -11,7 +16,12 @@
11
16
  --color-background-positive-default: rgba(14, 132, 32, 1);
12
17
  --color-background-positive-hover: rgba(12, 109, 26, 1);
13
18
  --color-background-positive-active: rgba(10, 95, 23, 1);
14
- --color-text-button-positive: rgba(255, 255, 255, 1);
19
+ --color-background-positive-text: var(--color-palette-white); /* text on positive background */
20
+
21
+ --color-background-negative-default: rgba(199, 22, 43, 1);
22
+ --color-background-negative-hover: rgba(176, 19, 38, 1);
23
+ --color-background-negative-active: rgba(162, 18, 35, 1);
24
+ --color-background-negative-text: var(--color-palette-white); /* text on positive background */
15
25
 
16
26
  /* spacing tokens */
17
27
  --spacing-horizontal-small: 0.5rem;
@@ -29,3 +39,23 @@
29
39
  --font-weight-default: 400;
30
40
  --line-height-default: 1.5rem;
31
41
  }
42
+
43
+ /* component semantic tokens */
44
+ :root {
45
+ --button-color-background: var(--color-background-default);
46
+ --button-color-background-hover: var(--color-background-hover);
47
+ --button-color-background-active: var(--color-background-active);
48
+ --button-color-text: var(--color-text-default);
49
+ --button-color-border: var(--color-border-high-contrast);
50
+ --button-color-border-hover: var(--button-color-border);
51
+ --button-color-border-active: var(--button-color-border);
52
+
53
+ --button-margin-left: var(--spacing-horizontal-large);
54
+ --button-margin-bottom: var(--spacing-input-margin-bottom);
55
+ --button-padding-vertical: var(--spacing-input-padding-vertical);
56
+ --button-padding-horizontal: var(--spacing-horizontal-large);
57
+ --button-border-width: var(--spacing-border-width);
58
+ --button-font-size: var(--font-size-default);
59
+ --button-font-weight: var(--font-weight-default);
60
+ --button-line-height: var(--line-height-default);
61
+ }
@@ -0,0 +1,182 @@
1
+ /*
2
+ TODO
3
+ - conditional (?) font size increase on large screens
4
+ - different heading sizes/spacing on different screen sizes
5
+ - how to make very opinionated styles (heading sizes in pairs, margin collapsing between them, etc) configurable/themable?
6
+ */
7
+
8
+ :root {
9
+ --font-family-sans: "Ubuntu variable", "Ubuntu", -apple-system, "Segoe UI",
10
+ "Roboto", "Oxygen", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
11
+ sans-serif;
12
+ --font-family-mono: "Ubuntu Mono variable", "Ubuntu Mono", Consolas, Monaco,
13
+ Courier, monospace;
14
+ --text-max-width: 40em;
15
+
16
+ --font-size-default: 1rem;
17
+ --font-size-default-scaled: 1.125rem;
18
+
19
+ --font-size-h1: 2.5rem;
20
+ --font-size-h2: var(--font-size-h1);
21
+ --font-size-h3: 1.5rem;
22
+ --font-size-h4: var(--font-size-h3);
23
+
24
+ --font-weight-bold: 550;
25
+ --font-weight-regular: 400;
26
+ --font-weight-thin: 300;
27
+ --font-weight-display-heading: 100;
28
+ --font-weight-h2: 180; /* custom font weight for h2 */
29
+ --font-weight-h4: 275; /* custom font weight for h4 */
30
+
31
+ --sp-unit: 0.5rem;
32
+ --spv-x-small: calc(0.5 * var(--sp-unit));
33
+ --spv-small: var(--sp-unit);
34
+ --spv-medium: calc(1.5 * var(--sp-unit));
35
+ --spv-large: calc(2 * var(--sp-unit));
36
+ --spv-x-large: calc(3 * var(--sp-unit));
37
+ --spv-strip-shallow: calc(3 * var(--sp-unit));
38
+ --spv-strip-regular: calc(8 * var(--sp-unit));
39
+ --spv-strip-deep: calc(16 * var(--sp-unit));
40
+
41
+ --sp-after-display: var(--spv-x-large);
42
+ --sp-after-h1: var(--spv-x-large);
43
+ --sp-after-h2: var(--sp-after-h1);
44
+ --sp-after-h3: var(--spv-x-large);
45
+ --sp-after-h4: var(--sp-after-h3);
46
+ --sp-after-p: var(--spv-x-large);
47
+ --sp-after-p-small-caps: var(--spv-large);
48
+ --sp-after-p-dense: var(--spv-large);
49
+ --sp-after-default-text: var(--sp-unit);
50
+ --sp-after-small: var(--spv-large);
51
+ --sp-after-small-dense: var(--spv-large);
52
+ --sp-after-x-small: var(--spv-large);
53
+
54
+ --line-height-default: calc(3 * var(--sp-unit));
55
+ --line-height-h1: calc(6 * var(--sp-unit));
56
+ --line-height-h2: var(--line-height-h1);
57
+ --line-height-h3: calc(4 * var(--sp-unit));
58
+ --line-height-h4: var(--line-height-h3);
59
+
60
+ --nudge-p: 0.375rem;
61
+ --nudge-h1: 0.55rem;
62
+ --nudge-h2: var(--nudge-h1);
63
+ --nudge-h3: 0.45rem;
64
+ --nudge-h4: var(--nudge-h3);
65
+ --nudge-h5: var(--nudge-p);
66
+ --nudge-h6: var(--nudge-p);
67
+ }
68
+
69
+ html {
70
+ color: #000;
71
+ font-family: var(--font-family-sans);
72
+ -moz-osx-font-smoothing: grayscale;
73
+ -webkit-font-smoothing: antialiased;
74
+ font-weight: var(--font-weight-regular);
75
+ font-size: var(--font-size-default);
76
+ line-height: var(--line-height-default);
77
+ text-wrap: pretty;
78
+ }
79
+
80
+ /* FIXME: we would need to add many more selectors here, everything that is a heading (in components) */
81
+ h1,
82
+ h2,
83
+ h3,
84
+ h4,
85
+ h5,
86
+ h6,
87
+ .heading-1,
88
+ .heading-2,
89
+ .heading-3,
90
+ .heading-4,
91
+ .heading-5,
92
+ .heading-6 {
93
+ font-style: normal;
94
+ margin-top: 0;
95
+ max-width: var(--text-max-width);
96
+ }
97
+
98
+ h1,
99
+ .heading-1 {
100
+ font-size: var(--font-size-h1);
101
+ font-weight: var(--font-weight-bold);
102
+ line-height: var(--line-height-h1);
103
+ padding-top: var(--nudge-h1);
104
+ margin-bottom: calc(var(--sp-after-h1) - var(--nudge-h1));
105
+ }
106
+
107
+ h2,
108
+ .heading-2 {
109
+ font-size: var(--font-size-h2);
110
+ font-weight: var(--font-weight-h2);
111
+ line-height: var(--line-height-h2);
112
+ padding-top: var(--nudge-h2);
113
+ margin-bottom: calc(var(--sp-after-h2) - var(--nudge-h2));
114
+ }
115
+
116
+ h3,
117
+ .heading-3 {
118
+ font-size: var(--font-size-h3);
119
+ font-weight: var(--font-weight-bold);
120
+ line-height: var(--line-height-h3);
121
+ padding-top: var(--nudge-h3);
122
+ margin-bottom: calc(var(--sp-after-h3) - var(--nudge-h3));
123
+ }
124
+
125
+ h4,
126
+ .heading-4 {
127
+ font-size: var(--font-size-h4);
128
+ font-weight: var(--font-weight-h4);
129
+ line-height: var(--line-height-h4);
130
+ padding-top: var(--nudge-h4);
131
+ margin-bottom: calc(var(--sp-after-h4) - var(--nudge-h4));
132
+ }
133
+
134
+ h5,
135
+ .heading-5 {
136
+ font-size: var(--font-size-default);
137
+ font-weight: var(--font-weight-bold);
138
+ line-height: var(--line-height-default);
139
+ padding-top: var(--nudge-h5);
140
+ margin-bottom: calc(var(--sp-after-p) - var(--nudge-h5));
141
+ }
142
+
143
+ h6,
144
+ .heading-6 {
145
+ font-size: var(--font-size-default);
146
+ font-style: italic;
147
+ font-weight: var(--font-weight-regular);
148
+ line-height: var(--line-height-default);
149
+ padding-top: var(--nudge-h6);
150
+ margin-bottom: calc(var(--sp-after-p) - var(--nudge-h6));
151
+ }
152
+
153
+ /*
154
+ Canonical specific:
155
+ consecutive headings of the same size should collapse margin between them
156
+ */
157
+ h1,
158
+ h2,
159
+ .heading-1,
160
+ .heading-2 {
161
+ & + & {
162
+ margin-top: calc(-1 * var(--sp-after-h1));
163
+ }
164
+ }
165
+
166
+ h3,
167
+ h4,
168
+ .heading-3,
169
+ .heading-4 {
170
+ & + & {
171
+ margin-top: calc(-1 * var(--sp-after-h3));
172
+ }
173
+ }
174
+
175
+ h5,
176
+ h6,
177
+ .heading-5,
178
+ .heading-6 {
179
+ & + & {
180
+ margin-top: calc(-1 * var(--sp-after-p));
181
+ }
182
+ }