@carissa-io/theme-default 0.1.0 → 0.2.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/DESIGN.md +5 -1
- package/README.md +59 -2
- package/package.json +3 -2
- package/scss/_tokens.scss +39 -0
- package/scss/index.scss +2 -32
package/DESIGN.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
This is the design document of the **Carissa Default theme** (`@carissa-io/theme-default`): the decisions behind its
|
|
6
6
|
values. The components are style-agnostic; this theme gives them their look through SCSS variable overrides in
|
|
7
7
|
[scss/index.scss](scss/index.scss), and its palette and shared values (radius, focus ring, transition...) are Sass
|
|
8
|
-
variables
|
|
8
|
+
variables in [scss/_tokens.scss](scss/_tokens.scss). Other themes (tech terminal, brutalist, ...) are their own `theme-<name>` repositories,
|
|
9
9
|
never changes to the components.
|
|
10
10
|
|
|
11
11
|
## Principles
|
|
@@ -22,6 +22,10 @@ never changes to the components.
|
|
|
22
22
|
| Text (body) | `#171717` |
|
|
23
23
|
| Text (meta, placeholder) | `#737373` (4.7:1; lighter greys only for disabled states) |
|
|
24
24
|
|
|
25
|
+
The same palette is available as Sass tokens (`$black`, `$muted`, `$surface`, `$error`...) in
|
|
26
|
+
[scss/_tokens.scss](scss/_tokens.scss), the machine-readable palette: apps read them (for example to configure Bootstrap)
|
|
27
|
+
instead of copying the hex values, so a change of value here reaches them with the next release.
|
|
28
|
+
|
|
25
29
|
## Typography
|
|
26
30
|
| Variant | Purpose | Style |
|
|
27
31
|
| :--- | :--- | :--- |
|
package/README.md
CHANGED
|
@@ -22,9 +22,66 @@ peer dependencies).
|
|
|
22
22
|
```scss
|
|
23
23
|
@use '@carissa-io/theme-default/scss';
|
|
24
24
|
```
|
|
25
|
-
3. **
|
|
25
|
+
3. **Tokens (Sass variables only, no CSS):** see [Tokens](#tokens).
|
|
26
|
+
4. **A starting point for a new theme:** copy `scss/index.scss` and `scss/_tokens.scss` and change the values. In the Carissa workspace,
|
|
26
27
|
`scripts/new-theme.sh <name> "<description>"` does this and sets up the repo.
|
|
27
28
|
|
|
29
|
+
## Tokens
|
|
30
|
+
The palette and the values shared by every component are Sass variables in `scss/_tokens.scss`, the single source of
|
|
31
|
+
the theme's values (`scss/index.scss` reads them with `@use 'tokens' as *`). The file emits no CSS, so an app can read
|
|
32
|
+
the values without pulling any rule in. The names are the **public token API**: renaming or removing one is a breaking
|
|
33
|
+
change.
|
|
34
|
+
|
|
35
|
+
```scss
|
|
36
|
+
@use '@carissa-io/theme-default/scss/tokens' as theme;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
| Token | Value | Use |
|
|
40
|
+
| :--- | :--- | :--- |
|
|
41
|
+
| `$black` | `#000` | primary, hover and focus |
|
|
42
|
+
| `$white` | `#fff` | surfaces |
|
|
43
|
+
| `$text` | `#171717` | body text |
|
|
44
|
+
| `$muted` | `#737373` | labels, field borders, placeholders |
|
|
45
|
+
| `$surface` | `#f5f5f5` | hover surface, disabled background |
|
|
46
|
+
| `$surface-active` | `#e5e5e5` | pressed surface, dividers |
|
|
47
|
+
| `$primary-hover` | `#262626` | primary action on hover |
|
|
48
|
+
| `$primary-active` | `#404040` | primary action while pressed |
|
|
49
|
+
| `$disabled-text` | `#a3a3a3` | disabled text and marks |
|
|
50
|
+
| `$disabled-border` | `#d4d4d4` | disabled borders |
|
|
51
|
+
| `$error` | `#dc3545` | error text and borders |
|
|
52
|
+
| `$font-family` | `'Helvetica Neue', Helvetica, Arial, 'Liberation Sans', sans-serif` | type stack |
|
|
53
|
+
| `$radius` | `0` | corner radius |
|
|
54
|
+
| `$min-height` | `2.75rem` | touch target |
|
|
55
|
+
| `$focus-color` | `$black` | focus color |
|
|
56
|
+
| `$focus-width` | `1px` | focus ring width |
|
|
57
|
+
| `$transition-duration` | `0.2s` | color and border transitions |
|
|
58
|
+
| `$label-font-size` | `0.6875rem` | field label size |
|
|
59
|
+
| `$label-font-weight` | `700` | field label weight |
|
|
60
|
+
| `$label-letter-spacing` | `0.1em` | field label tracking |
|
|
61
|
+
| `$arrow-size` | `1rem` | dropdown arrow size |
|
|
62
|
+
| `$arrow-offset` | `0.75rem` | dropdown arrow inset |
|
|
63
|
+
| `$arrow-color` | `$muted` | dropdown arrow color |
|
|
64
|
+
| `$arrow-color-active` | `$black` | dropdown arrow on hover and when open |
|
|
65
|
+
| `$arrow-color-disabled` | `$disabled-text` | dropdown arrow when disabled |
|
|
66
|
+
| `$arrow-transition` | `rotate` and `color`, `$transition-duration` | dropdown arrow motion |
|
|
67
|
+
| `$arrow-rotate-open` | `180deg` | dropdown arrow rotation when open |
|
|
68
|
+
|
|
69
|
+
**Recommended for apps:** configure Bootstrap from the tokens, so the app and the Carissa components share one palette.
|
|
70
|
+
Needs `sass-embedded` (or `sass`) and a bundler whose Sass importer respects package `exports` (Vite does):
|
|
71
|
+
```scss
|
|
72
|
+
@use '@carissa-io/theme-default/scss/tokens' as theme;
|
|
73
|
+
@use 'bootstrap/scss/bootstrap' with (
|
|
74
|
+
$primary: theme.$black,
|
|
75
|
+
$font-family-sans-serif: theme.$font-family,
|
|
76
|
+
$body-bg: theme.$surface
|
|
77
|
+
);
|
|
78
|
+
```
|
|
79
|
+
Outside a bundler, put `node_modules` on the Sass load path (`sass --load-path=node_modules`).
|
|
80
|
+
|
|
81
|
+
Every theme repo has its own tokens, with the same names. Switching theme means the same `@use` path with another package
|
|
82
|
+
name (`@carissa-io/theme-<name>/scss/tokens`). A theme that does not define a token must not be used with code that expects
|
|
83
|
+
it: check the names against the theme's `scss/_tokens.scss` before you switch.
|
|
84
|
+
|
|
28
85
|
## What it configures
|
|
29
86
|
`components-input`, `-button`, `-checkbox`, `-switch`, `-radio-group`, `-slider`, `-popover`, `-listbox`, `-select`,
|
|
30
87
|
`-combobox`, `-upload`, `-calendar`, `-date-picker` and `-search`. `components-email`, `-password`, `-url` and `-textarea`
|
|
@@ -32,7 +89,7 @@ are styled through the input.
|
|
|
32
89
|
|
|
33
90
|
## Change a value
|
|
34
91
|
The palette and the values shared by every component (radius, minimum height, focus ring, transition, label style, dropdown
|
|
35
|
-
arrow) are Sass variables
|
|
92
|
+
arrow) are the Sass variables of `scss/_tokens.scss` (the [tokens](#tokens)); each component has one `@use ... with (...)` block of overrides
|
|
36
93
|
below. Change the value, run `npm run build`, and update [DESIGN.md](DESIGN.md) if the decision changes.
|
|
37
94
|
|
|
38
95
|
## Develop
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carissa-io/theme-default",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Carissa UI: the default theme (Swiss minimalism) as SCSS variable overrides of the Carissa components, with a compiled CSS build",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"style": "dist/index.css",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": "./dist/index.css",
|
|
14
14
|
"./css": "./dist/index.css",
|
|
15
|
-
"./scss": "./scss/index.scss"
|
|
15
|
+
"./scss": "./scss/index.scss",
|
|
16
|
+
"./scss/tokens": "./scss/_tokens.scss"
|
|
16
17
|
},
|
|
17
18
|
"sideEffects": [
|
|
18
19
|
"*.css"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Carissa Default theme tokens: the palette and the values shared by every component, as Sass variables only.
|
|
2
|
+
// This file emits no CSS. The variable names below are the PUBLIC TOKEN API: consumers (apps, other tools) may
|
|
3
|
+
// `@use '@carissa-io/theme-default/scss/tokens' as theme;` and read `theme.$black`, `theme.$font-family`...
|
|
4
|
+
// Renaming or removing a token is a breaking change (major release); adding one is a minor release.
|
|
5
|
+
// Every Carissa theme exposes the same names, so switching theme only changes the package name in the `@use`.
|
|
6
|
+
// Neutral scale = Tailwind's neutral palette values, written out as plain colors.
|
|
7
|
+
|
|
8
|
+
// Palette (Tailwind's neutral scale as plain colors), named by role so a theme is changed in one place.
|
|
9
|
+
$black: #000; // primary, hover and focus
|
|
10
|
+
$white: #fff;
|
|
11
|
+
$text: #171717;
|
|
12
|
+
$muted: #737373; // labels, field borders, placeholders (4.7:1 on white)
|
|
13
|
+
$surface: #f5f5f5; // hover surface, disabled background
|
|
14
|
+
$surface-active: #e5e5e5;
|
|
15
|
+
$primary-hover: #262626;
|
|
16
|
+
$primary-active: #404040;
|
|
17
|
+
$disabled-text: #a3a3a3;
|
|
18
|
+
$disabled-border: #d4d4d4;
|
|
19
|
+
$error: #dc3545;
|
|
20
|
+
|
|
21
|
+
// Values shared by every component, so the whole theme moves together.
|
|
22
|
+
$font-family: ('Helvetica Neue', Helvetica, Arial, 'Liberation Sans', sans-serif);
|
|
23
|
+
$radius: 0;
|
|
24
|
+
$min-height: 2.75rem; // 44px touch target
|
|
25
|
+
$focus-color: $black;
|
|
26
|
+
$focus-width: 1px;
|
|
27
|
+
$transition-duration: 0.2s;
|
|
28
|
+
$label-font-size: 0.6875rem;
|
|
29
|
+
$label-font-weight: 700;
|
|
30
|
+
$label-letter-spacing: 0.1em;
|
|
31
|
+
|
|
32
|
+
// The dropdown arrow of Select and Combobox: 16px, muted, black on hover and when open, turns over with the list.
|
|
33
|
+
$arrow-size: 1rem;
|
|
34
|
+
$arrow-offset: 0.75rem;
|
|
35
|
+
$arrow-color: $muted;
|
|
36
|
+
$arrow-color-active: $black;
|
|
37
|
+
$arrow-color-disabled: $disabled-text;
|
|
38
|
+
$arrow-transition: (rotate $transition-duration ease, color $transition-duration ease);
|
|
39
|
+
$arrow-rotate-open: 180deg;
|
package/scss/index.scss
CHANGED
|
@@ -1,38 +1,8 @@
|
|
|
1
1
|
// Carissa Default theme: Swiss minimalism (see DESIGN.md). Only variable overrides, no component code.
|
|
2
2
|
// Neutral scale = Tailwind's neutral palette values, written out as plain colors.
|
|
3
3
|
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
$white: #fff;
|
|
7
|
-
$text: #171717;
|
|
8
|
-
$muted: #737373; // labels, field borders, placeholders (4.7:1 on white)
|
|
9
|
-
$surface: #f5f5f5; // hover surface, disabled background
|
|
10
|
-
$surface-active: #e5e5e5;
|
|
11
|
-
$primary-hover: #262626;
|
|
12
|
-
$primary-active: #404040;
|
|
13
|
-
$disabled-text: #a3a3a3;
|
|
14
|
-
$disabled-border: #d4d4d4;
|
|
15
|
-
$error: #dc3545;
|
|
16
|
-
|
|
17
|
-
// Values shared by every component, so the whole theme moves together.
|
|
18
|
-
$font-family: ('Helvetica Neue', Helvetica, Arial, 'Liberation Sans', sans-serif);
|
|
19
|
-
$radius: 0;
|
|
20
|
-
$min-height: 2.75rem; // 44px touch target
|
|
21
|
-
$focus-color: $black;
|
|
22
|
-
$focus-width: 1px;
|
|
23
|
-
$transition-duration: 0.2s;
|
|
24
|
-
$label-font-size: 0.6875rem;
|
|
25
|
-
$label-font-weight: 700;
|
|
26
|
-
$label-letter-spacing: 0.1em;
|
|
27
|
-
|
|
28
|
-
// The dropdown arrow of Select and Combobox: 16px, muted, black on hover and when open, turns over with the list.
|
|
29
|
-
$arrow-size: 1rem;
|
|
30
|
-
$arrow-offset: 0.75rem;
|
|
31
|
-
$arrow-color: $muted;
|
|
32
|
-
$arrow-color-active: $black;
|
|
33
|
-
$arrow-color-disabled: $disabled-text;
|
|
34
|
-
$arrow-transition: (rotate $transition-duration ease, color $transition-duration ease);
|
|
35
|
-
$arrow-rotate-open: 180deg;
|
|
4
|
+
// The palette and the shared values live in _tokens.scss (the public token API); the blocks below only use them.
|
|
5
|
+
@use 'tokens' as *;
|
|
36
6
|
|
|
37
7
|
@use '@carissa-io/components-input/scss' as input with (
|
|
38
8
|
// Typography: neutral grotesque stack (no webfont to load), label = bold, uppercase, tracking-widest
|