@splendidlabz/styles 4.16.0 → 4.17.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/README.md CHANGED
@@ -11,12 +11,16 @@ npm install @splendidlabz/styles
11
11
  ## The quickest way — everything
12
12
 
13
13
  ```css
14
+ @layer reset, theme, base, components, utilities;
15
+
14
16
  @import 'tailwindcss';
15
17
  @import '@splendidlabz/styles';
16
18
  ```
17
19
 
18
20
  That's the whole system: reset, theme, styled HTML, utilities, and the CSS components (`prose`, `card`, `table`, and friends). Tailwind tree-shakes whatever you don't use, so most projects want this and nothing else.
19
21
 
22
+ The `@layer` line puts Splendid's reset below everything else. Leave it out and the reset beats your utilities: `p-4` gets no padding.
23
+
20
24
  ## Keep your own reset — just the classes
21
25
 
22
26
  Already have your own reset and base styles? Take Splendid's utilities and components without letting it touch your HTML:
@@ -39,6 +43,8 @@ If you're pulling in components from `@splendidlabz/astro` or `@splendidlabz/sve
39
43
  @source "../node_modules/@splendidlabz/astro";
40
44
  @source "../node_modules/@splendidlabz/svelte";
41
45
 
46
+ @layer reset, theme, base, components, utilities;
47
+
42
48
  @import 'tailwindcss';
43
49
 
44
50
  /* 2. A base + the framework component styles. */
package/catalog.md CHANGED
@@ -9,7 +9,27 @@ This file lists every utility group `@splendidlabz/styles` ships for Tailwind CS
9
9
 
10
10
  ## Entry points
11
11
 
12
- Import `tailwindcss` first. Then import the full bundle alone, or a foundation followed by any component layer. A foundation is `base` or `utilities`. A component layer is `components/css`, `components/astro`, `components/svelte` or `components`.
12
+ Set up your main stylesheet in this order, as the block below shows:
13
+
14
+ 1. When you import the full bundle or `base`, declare the layer order before any import, so Splendid's reset has the lowest priority.
15
+ 2. When you import the full bundle or `base`, import Tailwind's theme and utilities into their layers instead of `@import 'tailwindcss'`, because Splendid's reset replaces Tailwind's preflight. On `utilities`, keep your own reset and use `@import 'tailwindcss'` as usual.
16
+ 3. Import either the full bundle (`@splendidlabz/styles`) alone, or a foundation followed by any component entry point.
17
+ - A foundation is `base` or `utilities`.
18
+ - A component entry point is `components/css`, `components/astro`, `components/svelte` or `components`.
19
+ 4. When the project uses `@splendidlabz/astro` or `@splendidlabz/svelte`, add an `@source` line for each, with a path relative to the stylesheet. Tailwind skips `node_modules`, so without the line it doesn't build the classes those components use.
20
+
21
+ ```css
22
+ @layer reset, theme, base, components, utilities;
23
+
24
+ @import 'tailwindcss/theme.css' layer(theme);
25
+ @import 'tailwindcss/utilities.css' layer(utilities);
26
+
27
+ @import '@splendidlabz/styles/base';
28
+ @import '@splendidlabz/styles/components';
29
+
30
+ @source '../../node_modules/@splendidlabz/astro';
31
+ @source '../../node_modules/@splendidlabz/svelte';
32
+ ```
13
33
 
14
34
  - `@splendidlabz/styles`: the full bundle of reset, theme variables, bare-HTML styles, tools, layouts, effects and the CSS components.
15
35
  - `@splendidlabz/styles/base`: the full bundle without the CSS components. Use it under `components/astro` or `components/svelte`.
@@ -21,7 +41,7 @@ Import `tailwindcss` first. Then import the full bundle alone, or a foundation f
21
41
  - `@splendidlabz/styles/tools`, `/pigment`, `/variables`: the tools, pigment alone, or the theme variables alone.
22
42
  - `@splendidlabz/styles/scripts`: the browser scripts listed at the end of this file.
23
43
 
24
- Import `base` or `utilities`, never both. Import no component layer after the full bundle, since it already carries the CSS components. Tailwind doesn't dedupe a repeated `@import`, so either mistake ships the shared utilities twice.
44
+ Import `base` or `utilities`, never both. Import no component entry point after the full bundle, since it already carries the CSS components. Tailwind doesn't dedupe a repeated `@import`, so either mistake ships the shared utilities twice.
25
45
 
26
46
  ## Layouts
27
47
 
@@ -116,7 +136,7 @@ In `effects`, `base`, `utilities` and the full bundle. Source: `src/effects/`.
116
136
  In every foundation, `theming`, `layouts`, `effects` and `tools`. Source: `src/tools/`.
117
137
 
118
138
  - `interact:` and `interact-within:` variants: styles for hover, focus-visible, active, selected, checked, current, pressed and expanded states, on the element or anything inside it.
119
- - `pigment`, `pigment-without-border`, `pigment-svg`, `pigment-with-svg`, `pigment-outline`, `pigment-ghost` (also in `/pigment`): colours that change by state, from `--bg-color`, `--text-color`, `--border-color` and their `-hover-`, `-focus-`, `-active-` and `-selected-` versions.
139
+ - `pigment`, `pigment-without-border`, `pigment-svg`, `pigment-with-svg`, `pigment-outline`, `pigment-ghost` (also in `/pigment`): colours that change by state, from `--bg-color`, `--text-color`, `--border-color` and their `-hover-`, `-focus-`, `-active-` and `-selected-` versions. `--bg-alpha`, `--text-alpha` and `--border-alpha` (0 to 1) fade that colour in every state, including the borders `card-divided`, `divider-between-*` and `Tabs` draw. `--bg-alpha` fades a colour only. A gradient background disappears when it's set.
120
140
  - `transition-scaffold`, `transition-scaffold-extended`, `transition-svg`: transitions on the common properties, timed by `--transition-duration`, `--transition-delay` and `--transition-easing`.
121
141
  - `outline-scaffold`, `focus-within`, `preserve-outlines`: focus outlines from the `--outline-*` variables.
122
142
  - `border-scaffold`, `padding-scaffold`, `margin-scaffold`: border, padding and margin from their variables.
@@ -127,7 +147,7 @@ In every foundation, `theming`, `layouts`, `effects` and `tools`. Source: `src/t
127
147
 
128
148
  ## CSS components: buttons, cards, prose, headings, lists, tables, form fields, shapes and typography
129
149
 
130
- In `components/css`, both component layers and the full bundle. `button` is also in `base` and `utilities`. Source: `src/components/css/`.
150
+ In every component entry point and the full bundle. `button` is also in `base` and `utilities`. Source: `src/components/css/`.
131
151
 
132
152
  - `button`, `button-icon`, `button-round`: a button, an icon-only button, and a round one.
133
153
  - `card`, `box`, `card-divided`, `card-divided-horizontal`, `card-divided-vertical`, `card-split`: a bordered padded card, and one with lines between its parts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splendidlabz/styles",
3
- "version": "4.16.0",
3
+ "version": "4.17.0",
4
4
  "description": "",
5
5
  "license": "Elastic-2.0",
6
6
  "type": "module",
@@ -37,7 +37,7 @@
37
37
  "@splendidlabz/utils": "*"
38
38
  },
39
39
  "devDependencies": {
40
- "@splendidlabz/stylelint-config": "3.2.0",
40
+ "@splendidlabz/stylelint-config": "3.2.1",
41
41
  "@tailwindcss/cli": "^4.2.2",
42
42
  "lightningcss-cli": "^1.32.0",
43
43
  "tailwindcss": "^4.2.2",
@@ -3,37 +3,32 @@
3
3
  }
4
4
 
5
5
  @utility card {
6
- & {
7
- @apply border-scaffold;
8
- @apply padding-scaffold;
9
- }
6
+ @apply border-scaffold;
7
+ @apply padding-scaffold;
10
8
  }
11
9
 
12
10
  @utility card-divided {
13
- & {
14
- @apply border-scaffold;
15
- position: relative;
11
+ @apply border-scaffold;
12
+ position: relative;
13
+
14
+ &:is(&) {
15
+ gap: 0;
16
+ padding: 0;
17
+ }
18
+
19
+ > *:not(&),
20
+ > :where(astro-slot, astro-island, astro-content) > *:not(&) {
21
+ @apply padding-scaffold;
22
+ --fallback-padding: 1rem;
16
23
 
17
- &:is(&) {
18
- gap: 0;
19
- padding: 0;
24
+ /* Raise for nicer focus ring */
25
+ &:focus-visible {
26
+ z-index: 2;
20
27
  }
21
28
 
22
- > *:not(&),
23
- > :where(astro-slot, astro-island, astro-content) > *:not(&) {
24
- @apply padding-scaffold;
25
- --fallback-padding: 1rem;
26
-
27
- /* Raise for nicer focus ring */
28
- &:focus-visible {
29
- z-index: 2;
30
- }
31
-
32
- &:not(:focus-visible) {
33
- --z-index: 1;
34
- animation: z-index-hack var(--transition-duration)
35
- var(--transition-delay);
36
- }
29
+ &:not(:focus-visible) {
30
+ --z-index: 1;
31
+ animation: z-index-hack var(--transition-duration) var(--transition-delay);
37
32
  }
38
33
  }
39
34
  }
@@ -56,7 +51,7 @@
56
51
 
57
52
  > :where(:not(:first-child)) {
58
53
  border-left-width: var(--border-width);
59
- border-color: var(--_bc, var(--border-color));
54
+ border-color: var(--_bca, var(--_bc, var(--border-color)));
60
55
  }
61
56
 
62
57
  > :where(:first-child) {
@@ -119,7 +119,7 @@
119
119
  }
120
120
  }
121
121
 
122
- @layer utility {
122
+ @layer components {
123
123
  .checkbox,
124
124
  .radio {
125
125
  @apply checkbox-and-radio;
@@ -85,23 +85,23 @@
85
85
  @container style(--placement: top) {
86
86
  :where(.tab) {
87
87
  border-bottom-width: var(--border-width);
88
- border-right-width: 0;
89
88
  border-left-width: 0;
89
+ border-right-width: 0;
90
90
  }
91
91
  }
92
92
 
93
93
  @container style(--placement: left) {
94
94
  :where(.tab) {
95
- border-right-width: var(--border-width);
96
95
  border-bottom-width: 0;
97
96
  border-left-width: 0;
97
+ border-right-width: var(--border-width);
98
98
  }
99
99
  }
100
100
 
101
101
  @container style(--placement: right) {
102
102
  :where(.tab) {
103
- border-left-width: var(--border-width);
104
103
  border-bottom-width: 0;
104
+ border-left-width: var(--border-width);
105
105
  border-right-width: 0;
106
106
  }
107
107
  }
@@ -147,11 +147,11 @@
147
147
  @container style(--placement: top) {
148
148
  :where(.tab) {
149
149
  top: var(--border-width);
150
- right: 0;
151
150
  left: 0;
151
+ right: 0;
152
152
  border-bottom-width: 0;
153
- border-right-width: var(--border-width);
154
153
  border-left-width: var(--border-width);
154
+ border-right-width: var(--border-width);
155
155
  border-start-start-radius: var(--radius);
156
156
  border-start-end-radius: var(--radius);
157
157
  border-end-start-radius: 0;
@@ -161,31 +161,31 @@
161
161
 
162
162
  @container style(--placement: left) {
163
163
  :where(.tab) {
164
- right: var(--border-width);
165
164
  top: 0;
166
165
  left: 0;
167
- border-right-width: 0;
166
+ right: var(--border-width);
168
167
  border-bottom-width: var(--border-width);
169
168
  border-left-width: var(--border-width);
169
+ border-right-width: 0;
170
170
  border-start-start-radius: var(--radius);
171
- border-end-start-radius: var(--radius);
172
171
  border-start-end-radius: 0;
172
+ border-end-start-radius: var(--radius);
173
173
  border-end-end-radius: 0;
174
174
  }
175
175
  }
176
176
 
177
177
  @container style(--placement: right) {
178
178
  :where(.tab) {
179
- left: var(--border-width);
180
179
  top: 0;
180
+ left: var(--border-width);
181
181
  right: 0;
182
- border-left-width: 0;
183
182
  border-bottom-width: var(--border-width);
183
+ border-left-width: 0;
184
184
  border-right-width: var(--border-width);
185
- border-start-end-radius: var(--radius);
186
- border-end-end-radius: var(--radius);
187
185
  border-start-start-radius: 0;
186
+ border-start-end-radius: var(--radius);
188
187
  border-end-start-radius: 0;
188
+ border-end-end-radius: var(--radius);
189
189
  }
190
190
  }
191
191
  }
@@ -209,7 +209,7 @@
209
209
 
210
210
  &:where(:not(:first-child)) {
211
211
  border-left-width: var(--border-width);
212
- border-color: var(--_bc, var(--border-color));
212
+ border-color: var(--_bca, var(--_bc, var(--border-color)));
213
213
  }
214
214
 
215
215
  &:where(:first-child) {
@@ -232,7 +232,7 @@
232
232
 
233
233
  &:where(:not(:first-child)) {
234
234
  border-top-width: var(--border-width);
235
- border-color: var(--_bc, var(--border-color));
235
+ border-color: var(--_bca, var(--_bc, var(--border-color)));
236
236
  }
237
237
 
238
238
  &:where(:first-child) {
@@ -261,7 +261,7 @@
261
261
 
262
262
  &:where(:not(:first-child)) {
263
263
  border-left-width: var(--border-width);
264
- border-color: var(--_bc, var(--border-color));
264
+ border-color: var(--_bca, var(--_bc, var(--border-color)));
265
265
  }
266
266
 
267
267
  &:where(:first-child) {
@@ -283,7 +283,7 @@
283
283
 
284
284
  &:where(:not(:first-child)) {
285
285
  border-top-width: var(--border-width);
286
- border-color: var(--_bc, var(--border-color));
286
+ border-color: var(--_bca, var(--_bc, var(--border-color)));
287
287
  }
288
288
 
289
289
  &:where(:first-child) {
@@ -1,47 +1,41 @@
1
1
  @utility divider-scaffold {
2
- & {
3
- align-self: stretch;
4
- display: flex;
5
- align-items: center;
6
- padding: 0 !important;
7
- border-radius: 0 !important;
2
+ align-self: stretch;
3
+ display: flex;
4
+ align-items: center;
5
+ padding: 0 !important;
6
+ border-radius: 0 !important;
8
7
 
9
- &:where(:not(:empty)) {
10
- gap: var(--gap, 1rem);
11
- }
8
+ &:where(:not(:empty)) {
9
+ gap: var(--gap, 1rem);
10
+ }
12
11
 
13
- &::before,
14
- &::after {
15
- content: '';
16
- background-color: var(--border-color, currentColor);
17
- }
12
+ &::before,
13
+ &::after {
14
+ content: '';
15
+ background-color: var(--border-color, currentColor);
18
16
  }
19
17
  }
20
18
 
21
19
  @utility divider-x {
22
- & {
23
- @apply divider-scaffold;
24
- flex-grow: 1;
20
+ @apply divider-scaffold;
21
+ flex-grow: 1;
25
22
 
26
- &::before,
27
- &::after {
28
- flex-grow: 1;
29
- height: var(--border-width, 1px);
30
- }
23
+ &::before,
24
+ &::after {
25
+ flex-grow: 1;
26
+ height: var(--border-width, 1px);
31
27
  }
32
28
  }
33
29
 
34
30
  @utility divider-y {
35
- & {
36
- @apply divider-scaffold;
37
- flex-grow: 0;
38
- flex-direction: column;
31
+ @apply divider-scaffold;
32
+ flex-grow: 0;
33
+ flex-direction: column;
39
34
 
40
- &::before,
41
- &::after {
42
- flex-grow: 1;
43
- width: var(--border-width, 1px);
44
- }
35
+ &::before,
36
+ &::after {
37
+ flex-grow: 1;
38
+ width: var(--border-width, 1px);
45
39
  }
46
40
  }
47
41
 
@@ -59,27 +53,23 @@
59
53
  * Divider between *
60
54
  *********************/
61
55
  @utility divider-between-x {
62
- & {
63
- flex-direction: column;
64
- row-gap: 0;
56
+ flex-direction: column;
57
+ row-gap: 0;
65
58
 
66
- > * + *,
67
- > * + *:where(astro-island, astro-slot):not(:first-of-type) > * {
68
- border-top-width: var(--border-width, 1px);
69
- border-color: var(--_bc, var(--border-color));
70
- }
59
+ > * + *,
60
+ > * + *:where(astro-island, astro-slot):not(:first-of-type) > * {
61
+ border-top-width: var(--border-width, 1px);
62
+ border-color: var(--_bca, var(--_bc, var(--border-color)));
71
63
  }
72
64
  }
73
65
 
74
66
  @utility divider-between-y {
75
- & {
76
- column-gap: 0;
67
+ column-gap: 0;
77
68
 
78
- > * + *,
79
- > * + *:where(astro-island, astro-slot) > * {
80
- border-left-width: var(--border-width, 1px);
81
- border-color: var(--_bc, var(--border-color));
82
- }
69
+ > * + *,
70
+ > * + *:where(astro-island, astro-slot) > * {
71
+ border-left-width: var(--border-width, 1px);
72
+ border-color: var(--_bca, var(--_bc, var(--border-color)));
83
73
  }
84
74
  }
85
75
 
@@ -34,14 +34,31 @@ Usage with the Fill System
34
34
  --_bgc: var(--bg-color);
35
35
  --_tc: var(--text-color, currentcolor);
36
36
  --_bc: var(--border-color, currentcolor);
37
- border-color: var(--_bc, currentcolor);
38
- color: var(--_tc);
39
- background: var(--_bgc);
37
+
38
+ /* Fades each colour by its alpha. Stays invalid while the alpha is unset, so the property falls back to the plain colour. */
39
+ --_bga: color-mix(
40
+ in oklab,
41
+ var(--_bgc) calc(var(--bg-alpha) * 100%),
42
+ transparent
43
+ );
44
+ --_tca: color-mix(
45
+ in oklab,
46
+ var(--_tc) calc(var(--text-alpha) * 100%),
47
+ transparent
48
+ );
49
+ --_bca: color-mix(
50
+ in oklab,
51
+ var(--_bc) calc(var(--border-alpha) * 100%),
52
+ transparent
53
+ );
54
+ border-color: var(--_bca, var(--_bc, currentcolor));
55
+ color: var(--_tca, var(--_tc));
56
+ background: var(--_bga, var(--_bgc));
40
57
  }
41
58
 
42
59
  @utility pigment-svg-scaffold {
43
60
  --_fc: var(--fill-color);
44
- --_sc: var(--stroke-color, var(--text-color, currentcolor));
61
+ --_sc: var(--stroke-color, var(--_tca, var(--text-color, currentcolor)));
45
62
 
46
63
  :where(svg path) {
47
64
  @apply transition-scaffold;
@@ -61,7 +78,10 @@ Usage with the Fill System
61
78
  @utility pigment-hover-svg-scaffold {
62
79
  &:hover {
63
80
  --_fc: var(--fill-hover-color, var(--fill-color));
64
- --_sc: var(--stroke-hover-color, var(--_tc));
81
+ --_sc: var(
82
+ --stroke-hover-color,
83
+ var(--stroke-color, var(--_tca, var(--_tc)))
84
+ );
65
85
  }
66
86
  }
67
87
 
@@ -79,7 +99,10 @@ Usage with the Fill System
79
99
  @utility pigment-focus-svg-scaffold {
80
100
  &:focus {
81
101
  --_fc: var(--fill-focus-color, var(--fill-color));
82
- --_sc: var(--stroke-focus-color, var(--_tc));
102
+ --_sc: var(
103
+ --stroke-focus-color,
104
+ var(--stroke-color, var(--_tca, var(--_tc)))
105
+ );
83
106
  }
84
107
  }
85
108
 
@@ -94,7 +117,10 @@ Usage with the Fill System
94
117
  @utility pigment-active-svg-scaffold {
95
118
  &:active {
96
119
  --_fc: var(--fill-active-color, var(--fill-color, revert-layer));
97
- --_sc: var(--stroke-active-color, var(--_tc));
120
+ --_sc: var(
121
+ --stroke-active-color,
122
+ var(--stroke-color, var(--_tca, var(--_tc)))
123
+ );
98
124
  }
99
125
  }
100
126
 
@@ -119,7 +145,10 @@ Usage with the Fill System
119
145
  &[aria-pressed='true'],
120
146
  &[aria-expanded='true'] {
121
147
  --_fc: var(--fill-selected-color, var(--fill-color, revert-layer));
122
- --_sc: var(--stroke-selected-color, var(--_tc));
148
+ --_sc: var(
149
+ --stroke-selected-color,
150
+ var(--stroke-color, var(--_tca, var(--_tc)))
151
+ );
123
152
  }
124
153
  }
125
154
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  @utility border-scaffold {
15
15
  border: var(--border-width) var(--border-style)
16
- var(--_bc, var(--border-color));
16
+ var(--_bca, var(--_bc, var(--border-color)));
17
17
  border-radius: var(--radius);
18
18
  }
19
19
 
@@ -126,5 +126,6 @@
126
126
  *********************/
127
127
  @utility radius-* {
128
128
  --radius: --value([length]);
129
+ /* stylelint-disable-next-line declaration-block-no-duplicate-custom-properties -- Tailwind keeps only the declaration whose --value() matches */
129
130
  --radius: --spacing(--value(number));
130
131
  }