@ptlm-azulejo/segmented-control 0.1.0-alpha.67 → 0.1.0-alpha.70
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 +64 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,23 +4,84 @@ A Segmented Control allows users to switch between multiple options or views wit
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
+
Install the segmented control, the theme package, and **the font package matching
|
|
8
|
+
your project's brand**:
|
|
9
|
+
|
|
10
|
+
**Leroy Merlin projects**
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @ptlm-azulejo/segmented-control @ptlm-azulejo/themes @ptlm-azulejo/fonts-leroy-merlin
|
|
14
|
+
# or
|
|
15
|
+
yarn add @ptlm-azulejo/segmented-control @ptlm-azulejo/themes @ptlm-azulejo/fonts-leroy-merlin
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Adeo projects**
|
|
19
|
+
|
|
7
20
|
```bash
|
|
8
|
-
npm install @ptlm-azulejo/segmented-control @ptlm-azulejo/themes
|
|
21
|
+
npm install @ptlm-azulejo/segmented-control @ptlm-azulejo/themes @ptlm-azulejo/fonts-adeo
|
|
9
22
|
# or
|
|
10
|
-
yarn add @ptlm-azulejo/segmented-control @ptlm-azulejo/themes
|
|
23
|
+
yarn add @ptlm-azulejo/segmented-control @ptlm-azulejo/themes @ptlm-azulejo/fonts-adeo
|
|
11
24
|
```
|
|
12
25
|
|
|
13
26
|
## Styles & theming
|
|
14
27
|
|
|
28
|
+
The component ships no colors or typeface of its own — it reads design tokens from
|
|
29
|
+
CSS variables at runtime. Those tokens come from `@ptlm-azulejo/themes`, and **the
|
|
30
|
+
brand is selected by a class on your app's `<html>` element**, so switching brand
|
|
31
|
+
never touches component code.
|
|
32
|
+
|
|
33
|
+
| Project | Preset stylesheet | Root class | Typeface | Font package |
|
|
34
|
+
| --- | --- | --- | --- | --- |
|
|
35
|
+
| Leroy Merlin | `@ptlm-azulejo/themes/presets/leroy-merlin.css` | `preset-lm` | LeroyMerlinSans | `@ptlm-azulejo/fonts-leroy-merlin` |
|
|
36
|
+
| Adeo | `@ptlm-azulejo/themes/presets/adeo.css` | `preset-adeo` | Roboto | `@ptlm-azulejo/fonts-adeo` |
|
|
37
|
+
|
|
38
|
+
**Leroy Merlin projects**
|
|
39
|
+
|
|
15
40
|
```js
|
|
16
41
|
import "@ptlm-azulejo/themes/presets/leroy-merlin.css";
|
|
42
|
+
import "@ptlm-azulejo/fonts-leroy-merlin";
|
|
43
|
+
import "@ptlm-azulejo/segmented-control/style.css";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<html lang="pt" class="preset-lm"></html>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Adeo projects**
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import "@ptlm-azulejo/themes/presets/adeo.css";
|
|
54
|
+
import "@ptlm-azulejo/fonts-adeo";
|
|
17
55
|
import "@ptlm-azulejo/segmented-control/style.css";
|
|
18
56
|
```
|
|
19
57
|
|
|
20
58
|
```html
|
|
21
|
-
<html
|
|
59
|
+
<html lang="pt" class="preset-adeo"></html>
|
|
22
60
|
```
|
|
23
61
|
|
|
62
|
+
> The preset class is what resolves the brand at runtime. Without it — even with
|
|
63
|
+
> the stylesheets imported — the component renders uncolored and in a fallback
|
|
64
|
+
> typeface. See the [themes package](../themes/README.md) for brand switching,
|
|
65
|
+
> dark mode, and custom brands.
|
|
66
|
+
|
|
67
|
+
### Light and dark mode
|
|
68
|
+
|
|
69
|
+
Add `data-theme` alongside the brand class to pin the color scheme. Leave it off
|
|
70
|
+
and the preset follows the OS `prefers-color-scheme`:
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<html lang="pt" class="preset-lm" data-theme="dark"></html>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Why the font package is separate
|
|
77
|
+
|
|
78
|
+
The preset only *names* its typeface in `--font-family` and ships no font files.
|
|
79
|
+
[Loading them is your app's job](../themes/README.md#fonts), as with upstream
|
|
80
|
+
Mozaic, so you keep control of hosting, subsetting and preload. Without the
|
|
81
|
+
matching font package, `font-sans` falls back to a generic sans-serif. A
|
|
82
|
+
multi-brand app can install both and switch by swapping the `.preset-*` class:
|
|
83
|
+
only the active brand's file is ever downloaded.
|
|
84
|
+
|
|
24
85
|
## Props
|
|
25
86
|
|
|
26
87
|
| Name | Type | Default | Description |
|