@ptlm-azulejo/themes 1.1.0 → 1.2.0-alpha.67
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/CHANGELOG.md +56 -0
- package/README.md +88 -4
- package/base.css +5 -3
- package/package.json +1 -1
- package/presets/adeo.css +2 -0
- package/presets/leroy-merlin.css +2 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @ptlm-azulejo/themes
|
|
2
|
+
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- eb0b0f8: Make components follow the brand typeface, add the medium (500) font weight, and
|
|
8
|
+
expose stable `data-testid` hooks.
|
|
9
|
+
|
|
10
|
+
- Each preset now names its brand's typeface in `--font-family`
|
|
11
|
+
(`presets/leroy-merlin.css` → LeroyMerlin, `presets/adeo.css` → Roboto), with
|
|
12
|
+
`Arial, sans-serif` as the fallback stack.
|
|
13
|
+
- Components apply that typeface on their root, so they follow the active brand
|
|
14
|
+
instead of inheriting the host page's font. Opt out per component by setting
|
|
15
|
+
`--font-family: inherit` on it.
|
|
16
|
+
- `base.css` adds `--font-weight-medium: 500`, alongside the existing regular
|
|
17
|
+
(400), semi-bold (600) and bold (700) weights.
|
|
18
|
+
- Every component now exposes `data-testid` on its root and on meaningful
|
|
19
|
+
sub-parts (`button` / `button-spinner`, `loader` / `loader-text`,
|
|
20
|
+
`datepicker` / `datepicker-clear`, `segmented-control` /
|
|
21
|
+
`segmented-control-segment`), so tests can target them without depending on
|
|
22
|
+
CSS class names.
|
|
23
|
+
|
|
24
|
+
As with upstream Mozaic, the presets **name** the typeface but ship no
|
|
25
|
+
`@font-face` and no font binaries — loading the files stays the app's job, so you
|
|
26
|
+
keep control of hosting, subsetting and preload. Until you load them the fallback
|
|
27
|
+
stack renders and nothing breaks. Install the font package matching your brand
|
|
28
|
+
alongside the preset:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Leroy Merlin
|
|
32
|
+
yarn add @ptlm-azulejo/themes @ptlm-azulejo/fonts-leroy-merlin
|
|
33
|
+
# Adeo
|
|
34
|
+
yarn add @ptlm-azulejo/themes @ptlm-azulejo/fonts-adeo
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
See the Fonts section of `packages/themes/README.md` for the full recipe.
|
|
38
|
+
|
|
39
|
+
## 1.1.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- 53000f7: Add Mozaic-aligned multi-brand theming support.
|
|
44
|
+
|
|
45
|
+
- New `@ptlm-azulejo/themes` package with structural/status tokens in `base.css`
|
|
46
|
+
and brand presets selected by a root class (`presets/leroy-merlin.css`,
|
|
47
|
+
`presets/adeo.css`), via `.preset-lm` / `.preset-adeo` and `data-theme` for
|
|
48
|
+
light/dark.
|
|
49
|
+
- `AzButton` now consumes theme tokens through utilities mapped in
|
|
50
|
+
`@theme inline`, working across both brands and in light/dark.
|
|
51
|
+
|
|
52
|
+
**BREAKING:** components no longer bake brand colors. The consumer must now
|
|
53
|
+
import `@ptlm-azulejo/themes/base.css` + a preset and apply the
|
|
54
|
+
`.preset-lm`/`.preset-adeo` class (and optional `data-theme="dark"`) on the root
|
|
55
|
+
element; otherwise components render uncolored. See the migration notes in
|
|
56
|
+
`packages/themes/README.md`.
|
package/README.md
CHANGED
|
@@ -11,12 +11,24 @@ The theme has two parts:
|
|
|
11
11
|
|
|
12
12
|
| File | Contents | Brand-specific? |
|
|
13
13
|
|---|---|---|
|
|
14
|
-
| `base.css` | **Structural + status** tokens (`--spacing-*`, `--border-radius-*`, `--font-*`, `--shadow-*`, `--color-danger-*`…) | No |
|
|
15
|
-
| `presets/<brand>.css` | **
|
|
14
|
+
| `base.css` | **Structural + status** tokens (`--spacing-*`, `--border-radius-*`, `--font-size-*`, `--font-weight-*`, `--shadow-*`, `--color-danger-*`…) | No |
|
|
15
|
+
| `presets/<brand>.css` | **Brand** tokens — typeface (`--font-family`) and functional colors (`--color-brand`, `--color-text-*`, `--color-background-*`, `--color-border-*`) | Yes |
|
|
16
16
|
|
|
17
17
|
The brand is selected with a **class on the root element** (`.preset-lm`,
|
|
18
18
|
`.preset-adeo`) and light/dark mode with the **`data-theme`** attribute.
|
|
19
19
|
|
|
20
|
+
> Font **sizes and weights** live in `base.css` and are the same for every brand
|
|
21
|
+
> (400 / 500 / 600 / 700). The **typeface itself** is the brand's voice, so
|
|
22
|
+
> `--font-family` lives in the preset.
|
|
23
|
+
>
|
|
24
|
+
> Heads-up for anyone doing a strict DE→PARA: upstream Mozaic defines the weights
|
|
25
|
+
> **per brand** — `build/<brand>/css/root.css` in `@mozaic-ds/tokens` sets
|
|
26
|
+
> `--font-weight-semi-bold` to **500** for Adeo (aliased to `font.weight.medium`)
|
|
27
|
+
> and 600 for Leroy Merlin. This library uses 600 for both, and exposes 500
|
|
28
|
+
> separately as `--font-weight-medium`. The two also differ on which cuts
|
|
29
|
+
> physically exist: LeroyMerlinSans ships no Medium (500) or Bold (700) file, so
|
|
30
|
+
> 500 falls back to Regular and 700 is browser-synthesized from SemiBold.
|
|
31
|
+
|
|
20
32
|
## Installation
|
|
21
33
|
|
|
22
34
|
```bash
|
|
@@ -36,7 +48,11 @@ import '@ptlm-azulejo/button/style.css'
|
|
|
36
48
|
|
|
37
49
|
> Each preset `@import`s `base.css` (the structural + status tokens), so a single
|
|
38
50
|
> preset import gives you everything. You can still import `base.css` on its own
|
|
39
|
-
> (`@ptlm-azulejo/themes/base.css`) if you ever need it without a brand
|
|
51
|
+
> (`@ptlm-azulejo/themes/base.css`) if you ever need it without a brand — but note
|
|
52
|
+
> it carries **no `--font-family`**, since the typeface belongs to the brand.
|
|
53
|
+
> Without a preset, components render uncolored and fall back to a generic
|
|
54
|
+
> sans-serif (the font weights still apply). Define `--font-family` yourself if you
|
|
55
|
+
> go this route.
|
|
40
56
|
|
|
41
57
|
Then apply the brand class on `<html>` (or any container):
|
|
42
58
|
|
|
@@ -57,6 +73,70 @@ Then apply the brand class on `<html>` (or any container):
|
|
|
57
73
|
- `data-theme="dark"` forces dark; `data-theme="light"` forces light.
|
|
58
74
|
- With no `data-theme`, the preset follows the operating system's `prefers-color-scheme`.
|
|
59
75
|
|
|
76
|
+
## Fonts
|
|
77
|
+
|
|
78
|
+
Each preset **names** its brand's typeface but **ships no font files and no
|
|
79
|
+
`@font-face`** — exactly like upstream Mozaic, which sets
|
|
80
|
+
`font-family: LeroyMerlin` and assumes the app already loaded it. Loading the
|
|
81
|
+
files is the app's job.
|
|
82
|
+
|
|
83
|
+
There is a package per brand that does exactly that job:
|
|
84
|
+
|
|
85
|
+
| Brand | `--font-family` | Font package |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `.preset-lm` | `"LeroyMerlin", Arial, sans-serif` | [`@ptlm-azulejo/fonts-leroy-merlin`](../FontsLeroyMerlin/README.md) |
|
|
88
|
+
| `.preset-adeo` | `"Roboto", Arial, sans-serif` | [`@ptlm-azulejo/fonts-adeo`](../FontsAdeo/README.md) |
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
yarn add @ptlm-azulejo/themes @ptlm-azulejo/fonts-leroy-merlin
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
import '@ptlm-azulejo/themes/presets/leroy-merlin.css'
|
|
96
|
+
import '@ptlm-azulejo/fonts-leroy-merlin'
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Until you load a typeface the fallback stack renders, so nothing breaks — it just
|
|
100
|
+
isn't on-brand. You can also wire the `@font-face` yourself if you'd rather
|
|
101
|
+
control hosting, subsetting and preload; the packages are a convenience, not a
|
|
102
|
+
requirement.
|
|
103
|
+
|
|
104
|
+
Declare the cuts the tokens reference — 400, 500, 600 and 700. One upstream quirk
|
|
105
|
+
worth knowing: **LeroyMerlinSans ships only Light, Regular and SemiBold**
|
|
106
|
+
(`@mozaic-ds/web-fonts`), so it has no Medium (500) or Bold (700) file — 500 falls
|
|
107
|
+
back to Regular and 700 is synthesized from SemiBold, same as upstream Mozaic.
|
|
108
|
+
Roboto on the Google Fonts CDN serves all four cuts.
|
|
109
|
+
|
|
110
|
+
### How each brand loads its font
|
|
111
|
+
|
|
112
|
+
The two font packages differ, for licensing reasons:
|
|
113
|
+
|
|
114
|
+
- **`@ptlm-azulejo/fonts-leroy-merlin` ships the files** and serves them from your
|
|
115
|
+
own domain — LeroyMerlinSans is proprietary and not on a public CDN.
|
|
116
|
+
- **`@ptlm-azulejo/fonts-adeo` loads Roboto from the Google Fonts CDN** — Roboto is
|
|
117
|
+
OFL-1.1 and Google serves every cut the tokens reference, so the package is a
|
|
118
|
+
single `@import` with no binaries to vendor.
|
|
119
|
+
|
|
120
|
+
### Only the active brand's font is downloaded
|
|
121
|
+
|
|
122
|
+
You can declare **both** brands' faces and switch freely — the other brand's file
|
|
123
|
+
is never fetched. `@font-face` is a *declaration*, not a fetch: a browser only
|
|
124
|
+
requests a font file when text it is actually rendering computes a `font-family`
|
|
125
|
+
naming it. With `.preset-lm` on the root, nothing ever computes `Roboto`.
|
|
126
|
+
|
|
127
|
+
The one thing that breaks this is **`<link rel="preload" as="font">`**, which is
|
|
128
|
+
eager and bypasses that matching. If you ship a single fixed brand, preload it —
|
|
129
|
+
just never preload both.
|
|
130
|
+
|
|
131
|
+
### Opting out
|
|
132
|
+
|
|
133
|
+
Components apply the brand typeface themselves, so they follow the brand rather
|
|
134
|
+
than inheriting your page's font. To hand a component back to the page font:
|
|
135
|
+
|
|
136
|
+
```css
|
|
137
|
+
.preset-lm .btn { font-family: inherit; }
|
|
138
|
+
```
|
|
139
|
+
|
|
60
140
|
### Switching brand at runtime
|
|
61
141
|
|
|
62
142
|
Just swap the root class (both presets can be imported at the same time):
|
|
@@ -68,10 +148,14 @@ document.documentElement.classList.add('preset-adeo')
|
|
|
68
148
|
|
|
69
149
|
## Creating a custom brand
|
|
70
150
|
|
|
71
|
-
Define the same
|
|
151
|
+
Define the same brand tokens of the contract under your brand class:
|
|
72
152
|
|
|
73
153
|
```css
|
|
74
154
|
.preset-my-brand {
|
|
155
|
+
/* Typeface. The 400/500/600/700 weights come from base.css; override them here
|
|
156
|
+
only if your typeface lacks those cuts. */
|
|
157
|
+
--font-family: "Inter", Arial, sans-serif;
|
|
158
|
+
|
|
75
159
|
--color-brand: #6c2bd9;
|
|
76
160
|
--color-brand-dark: #531fb0;
|
|
77
161
|
--color-brand-light: #efe7fb;
|
package/base.css
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* System. The functional naming (--spacing-*, --border-radius-*, --font-*,
|
|
6
6
|
* --color-danger-* ...) matches Mozaic to ease DE→PARA migrations.
|
|
7
7
|
*
|
|
8
|
-
* These tokens do NOT change per brand.
|
|
9
|
-
* (presets/leroy-merlin.css or
|
|
8
|
+
* These tokens do NOT change per brand. The brand typeface (--font-family) and
|
|
9
|
+
* the neutral/functional colors come from a preset (presets/leroy-merlin.css or
|
|
10
|
+
* presets/adeo.css) applied via a root class.
|
|
10
11
|
*
|
|
11
12
|
* Usage (consumer):
|
|
12
13
|
* import "@ptlm-azulejo/themes/base.css";
|
|
@@ -57,8 +58,9 @@
|
|
|
57
58
|
--font-size-11: 3.0625rem;
|
|
58
59
|
--font-size-12: 3.6875rem;
|
|
59
60
|
|
|
60
|
-
/* ── Typography · font weights
|
|
61
|
+
/* ── Typography · font weights ──────────────────────────── */
|
|
61
62
|
--font-weight-regular: 400;
|
|
63
|
+
--font-weight-medium: 500;
|
|
62
64
|
--font-weight-semi-bold: 600;
|
|
63
65
|
--font-weight-bold: 700;
|
|
64
66
|
|
package/package.json
CHANGED
package/presets/adeo.css
CHANGED
|
@@ -64,6 +64,8 @@
|
|
|
64
64
|
--color-brand-dark: var(--color-teal-700);
|
|
65
65
|
--color-brand-light: var(--color-teal-100);
|
|
66
66
|
|
|
67
|
+
--font-family: "Roboto", Arial, sans-serif;
|
|
68
|
+
|
|
67
69
|
/* ── Functional tokens · light (default) ──────────────────── */
|
|
68
70
|
--color-text-primary: #000000;
|
|
69
71
|
--color-text-secondary: #404040;
|
package/presets/leroy-merlin.css
CHANGED
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
--color-brand-dark: var(--color-green-700);
|
|
43
43
|
--color-brand-light: var(--color-green-100);
|
|
44
44
|
|
|
45
|
+
--font-family: "LeroyMerlin", Arial, sans-serif;
|
|
46
|
+
|
|
45
47
|
/* ── Functional tokens · light (default) ──────────────────── */
|
|
46
48
|
--color-text-primary: #000000;
|
|
47
49
|
--color-text-secondary: #404040;
|