@aortl/admin-css 0.13.1 → 0.14.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@aortl/admin-css",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "description": "Pre-built CSS design system. Drop in via <link> and use semantic class names.",
5
5
  "keywords": [
6
6
  "components",
@@ -1,6 +1,9 @@
1
1
  @layer components {
2
2
  .alert {
3
3
  @apply flex flex-col gap-1 w-full px-3 py-2 rounded-md border text-sm text-text;
4
+ /* Inherited by the title, description, and any bare-text body so long
5
+ words/URLs break instead of overflowing the (often grid-tracked) body. */
6
+ overflow-wrap: break-word;
4
7
  }
5
8
 
6
9
  /* Leading icon as a direct child switches the layout to a two-column grid:
@@ -9,7 +12,9 @@
9
12
  or any other inline SVG. */
10
13
  .alert:has(> :is(i, svg):first-child) {
11
14
  display: grid;
12
- grid-template-columns: auto 1fr;
15
+ /* `minmax(0, 1fr)` (not the default `minmax(auto, 1fr)`) lets the text
16
+ column shrink below its longest word so the body wraps. */
17
+ grid-template-columns: auto minmax(0, 1fr);
13
18
  column-gap: 0.5rem;
14
19
  row-gap: 0.25rem;
15
20
  align-items: center;
@@ -33,8 +38,12 @@
33
38
  grid-row: 1 / -1;
34
39
  }
35
40
 
41
+ /* Grid items default to `min-width: auto` and won't shrink below their
42
+ longest word; `min-width: 0` lets the title/description wrap inside the
43
+ text column. */
36
44
  .alert > :is(.alert-title, .alert-description) {
37
45
  grid-column: 2;
46
+ min-width: 0;
38
47
  }
39
48
 
40
49
  .alert-info {
@@ -0,0 +1,311 @@
1
+ @layer components {
2
+ /*
3
+ * Charts — three pure-CSS primitives driven entirely by inline custom
4
+ * properties (never data-* attributes: CSS can't read an attribute as a
5
+ * number for calc() cross-browser yet). No JS, no axes/ticks/gridlines.
6
+ * They serve two altitudes: dense inline micro-viz (a swatch in a table
7
+ * cell) and compact dashboard cards.
8
+ *
9
+ * Data contract:
10
+ * - bars: container `--chart-max` (default 100), each bar `--value`;
11
+ * the fill sizes to `var(--value) / var(--chart-max) * 100%`.
12
+ * - stack: each segment `--value`, sized by `flex` (no max — the ratios
13
+ * are intrinsic to the flex grow factors).
14
+ * - donut: one pre-built cumulative conic-gradient stop string in
15
+ * `--donut-segments` (CSS can't sum a variable-length sibling
16
+ * list, so the string arrives whole).
17
+ *
18
+ * Colour: single-series follows `currentColor` (default `--color-primary`,
19
+ * recoloured by the `.chart-success`/etc. variants like `.progress`).
20
+ * Multi-series colours are set inline per bar/segment (`--bar-color` /
21
+ * `--segment-color` / legend `--legend-color`); there is no chart token
22
+ * layer. role="img" + aria-label carries the semantics; a native `title`
23
+ * on each bar/segment gives a hover read-out.
24
+ */
25
+
26
+ /* Shared base — sizing knobs + the single-series fill colour. Any chart
27
+ type reads these; size modifiers below just remap them. */
28
+ .chart {
29
+ --chart-max: 100;
30
+ --chart-height: 8rem; /* bar track cross-axis size (md) */
31
+ --chart-size: 8rem; /* donut diameter (md) */
32
+ --chart-gap: 0.25rem;
33
+ color: var(--color-primary);
34
+ }
35
+
36
+ /* Single-series semantic variants — recolour currentColor, like progress. */
37
+ .chart-success {
38
+ color: var(--color-success);
39
+ }
40
+ .chart-warning {
41
+ color: var(--color-warning);
42
+ }
43
+ .chart-danger {
44
+ color: var(--color-danger);
45
+ }
46
+ .chart-info {
47
+ color: var(--color-info);
48
+ }
49
+
50
+ /* --------------------------------------------------------------------- *
51
+ * BAR CHART — horizontal (default) *
52
+ * --------------------------------------------------------------------- *
53
+ * Three-column grid: [label | track (1fr) | value]. Each `.chart-bar` is
54
+ * a `subgrid` spanning all three, so the label gutter and the value column
55
+ * stay aligned across every row. The fill lives in the `1fr` track — a
56
+ * definite width once the grid resolves, which is exactly what lets its
57
+ * `inline-size: %` transition (see the transition note). Values sit in the
58
+ * trailing column, so a short bar never clips its number and a full bar
59
+ * never overflows. */
60
+ .chart-bars {
61
+ display: grid;
62
+ grid-template-columns: auto 1fr auto;
63
+ row-gap: var(--chart-gap);
64
+ align-items: center;
65
+ inline-size: 100%;
66
+ }
67
+
68
+ .chart-bar {
69
+ display: grid;
70
+ grid-template-columns: subgrid;
71
+ grid-column: 1 / -1;
72
+ align-items: center;
73
+ }
74
+
75
+ /* Category label — only emitted when the datum carries one. The empty
76
+ `auto` column collapses to 0 when no bar has a label. */
77
+ .chart-bar-label {
78
+ @apply text-xs text-text-muted;
79
+ grid-column: 1;
80
+ text-align: end;
81
+ padding-inline-end: 0.5rem;
82
+ white-space: nowrap;
83
+ }
84
+
85
+ .chart-bar-track {
86
+ grid-column: 2;
87
+ min-inline-size: 0;
88
+ }
89
+
90
+ .chart-bar-fill {
91
+ block-size: 0.75rem;
92
+ inline-size: calc(var(--value) / var(--chart-max) * 100%);
93
+ background: var(--bar-color, currentColor);
94
+ border-radius: 2px;
95
+ /* Transition the resolved length (NOT --value, which isn't registered):
96
+ a percentage length transitions because the track has a definite size.
97
+ Both axes are listed so the vertical fill animates too. */
98
+ transition:
99
+ inline-size 200ms ease,
100
+ block-size 200ms ease;
101
+ }
102
+
103
+ /* Value label — trailing aligned column. Opt-in via `.chart-values`. */
104
+ .chart-bar-value {
105
+ @apply text-xs text-text-muted tabular-nums;
106
+ grid-column: 3;
107
+ text-align: end;
108
+ padding-inline-start: 0.5rem;
109
+ white-space: nowrap;
110
+ }
111
+ .chart:not(.chart-values) .chart-bar-value {
112
+ display: none;
113
+ }
114
+
115
+ /* --------------------------------------------------------------------- *
116
+ * BAR CHART — vertical modifier *
117
+ * --------------------------------------------------------------------- *
118
+ * Flex row of equal columns inside a fixed-height box. Each column is a
119
+ * flex column [value | track | label]; the track (`flex: 1`) gets a
120
+ * definite block-size so the fill's `block-size: %` resolves and animates.
121
+ * Bars grow up from the floor (`justify-content: end`). */
122
+ .chart-bars-vertical {
123
+ display: flex;
124
+ flex-direction: row;
125
+ align-items: stretch;
126
+ gap: var(--chart-gap);
127
+ block-size: var(--chart-height);
128
+ inline-size: 100%;
129
+ }
130
+
131
+ .chart-bars-vertical .chart-bar {
132
+ display: flex;
133
+ flex-direction: column;
134
+ flex: 1 1 0;
135
+ min-inline-size: 0;
136
+ align-items: stretch;
137
+ gap: 0.25rem;
138
+ }
139
+
140
+ .chart-bars-vertical .chart-bar-value {
141
+ order: 0;
142
+ grid-column: auto;
143
+ text-align: center;
144
+ padding: 0;
145
+ }
146
+
147
+ .chart-bars-vertical .chart-bar-track {
148
+ order: 1;
149
+ flex: 1 1 auto;
150
+ min-block-size: 0;
151
+ display: flex;
152
+ flex-direction: column;
153
+ justify-content: end;
154
+ }
155
+
156
+ .chart-bars-vertical .chart-bar-fill {
157
+ inline-size: 100%;
158
+ block-size: calc(var(--value) / var(--chart-max) * 100%);
159
+ }
160
+
161
+ .chart-bars-vertical .chart-bar-label {
162
+ order: 2;
163
+ text-align: center;
164
+ padding: 0;
165
+ }
166
+
167
+ /* --------------------------------------------------------------------- *
168
+ * STACKED / PROPORTION BAR *
169
+ * --------------------------------------------------------------------- *
170
+ * A single rounded track partitioned by `flex: var(--value)`. No max
171
+ * needed — proportions are the flex-grow ratios. A hairline in the
172
+ * surface colour separates adjacent segments. */
173
+ .chart-stack {
174
+ display: flex;
175
+ flex-direction: row;
176
+ inline-size: 100%;
177
+ block-size: 0.75rem;
178
+ border-radius: 9999px;
179
+ overflow: hidden;
180
+ background: var(--color-surface-strong);
181
+ }
182
+
183
+ .chart-segment {
184
+ flex: var(--value) 1 0;
185
+ min-inline-size: 0;
186
+ background: var(--segment-color, currentColor);
187
+ transition: flex-grow 200ms ease;
188
+ }
189
+ .chart-segment + .chart-segment {
190
+ box-shadow: -1px 0 0 0 var(--color-surface);
191
+ }
192
+
193
+ /* --------------------------------------------------------------------- *
194
+ * DONUT / PIE *
195
+ * --------------------------------------------------------------------- *
196
+ * A conic-gradient circle with the centre punched out by a radial-gradient
197
+ * mask. `--donut-thickness` is the ring width as a % of the diameter; the
198
+ * hole's inner radius is `50% - thickness`, so thickness=50% leaves no hole
199
+ * (a solid pie). The same stop position twice gives a crisp ring edge.
200
+ *
201
+ * The centre label must NOT be a child of the ring — `mask` clips the whole
202
+ * subtree, so a child sitting in the hole would be invisible. It's a sibling
203
+ * overlay: the figure is an inline-grid and both the ring and the label
204
+ * occupy the same cell. */
205
+ .chart-donut-figure {
206
+ position: relative;
207
+ inline-size: var(--chart-size);
208
+ aspect-ratio: 1;
209
+ display: inline-grid;
210
+ place-items: center;
211
+ }
212
+
213
+ .chart-donut {
214
+ --donut-thickness: 33%;
215
+ inline-size: var(--chart-size);
216
+ aspect-ratio: 1;
217
+ border-radius: 50%;
218
+ background: conic-gradient(var(--donut-segments, currentColor 0 100%));
219
+ -webkit-mask: radial-gradient(
220
+ circle at center,
221
+ transparent calc(50% - var(--donut-thickness)),
222
+ #000 calc(50% - var(--donut-thickness))
223
+ );
224
+ mask: radial-gradient(
225
+ circle at center,
226
+ transparent calc(50% - var(--donut-thickness)),
227
+ #000 calc(50% - var(--donut-thickness))
228
+ );
229
+ }
230
+
231
+ .chart-donut-figure > .chart-donut {
232
+ grid-area: 1 / 1;
233
+ inline-size: 100%;
234
+ }
235
+
236
+ /* Solid pie — no hole. */
237
+ .chart-donut-pie {
238
+ --donut-thickness: 50%;
239
+ }
240
+
241
+ .chart-donut-center {
242
+ @apply text-center text-sm font-semibold tabular-nums leading-tight;
243
+ grid-area: 1 / 1;
244
+ z-index: 1;
245
+ pointer-events: none;
246
+ }
247
+
248
+ /* --------------------------------------------------------------------- *
249
+ * LEGEND (donut + stack) *
250
+ * --------------------------------------------------------------------- */
251
+ .chart-legend {
252
+ @apply flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-text-muted;
253
+ list-style: none;
254
+ margin: 0;
255
+ padding: 0;
256
+ }
257
+
258
+ .chart-legend-item {
259
+ @apply inline-flex items-center gap-1.5;
260
+ }
261
+ .chart-legend-item::before {
262
+ content: "";
263
+ inline-size: 0.625rem;
264
+ block-size: 0.625rem;
265
+ border-radius: 2px;
266
+ background: var(--legend-color, currentColor);
267
+ flex-shrink: 0;
268
+ }
269
+
270
+ /* --------------------------------------------------------------------- *
271
+ * SIZES — remap the cross-axis / diameter knobs *
272
+ * --------------------------------------------------------------------- */
273
+ .chart-sm {
274
+ --chart-height: 4rem;
275
+ --chart-size: 4rem;
276
+ }
277
+ .chart-lg {
278
+ --chart-height: 12rem;
279
+ --chart-size: 12rem;
280
+ }
281
+
282
+ /* --------------------------------------------------------------------- *
283
+ * INLINE — micro-viz that sits in running text / a table cell *
284
+ * --------------------------------------------------------------------- *
285
+ * Inline-flex, baseline-nudged, and em-relative so the swatch tracks the
286
+ * surrounding font size. */
287
+ .chart-inline {
288
+ display: inline-flex;
289
+ vertical-align: middle;
290
+ --chart-height: 1em;
291
+ --chart-size: 1.25em;
292
+ }
293
+ .chart-inline .chart-stack {
294
+ inline-size: 6em;
295
+ block-size: 0.5em;
296
+ }
297
+ .chart-inline .chart-bars,
298
+ .chart-inline.chart-bars {
299
+ inline-size: 6em;
300
+ }
301
+
302
+ /* --------------------------------------------------------------------- *
303
+ * REDUCED MOTION *
304
+ * --------------------------------------------------------------------- */
305
+ @media (prefers-reduced-motion: reduce) {
306
+ .chart-bar-fill,
307
+ .chart-segment {
308
+ transition: none;
309
+ }
310
+ }
311
+ }
@@ -34,3 +34,4 @@
34
34
  @import "./table.css";
35
35
  @import "./tooltip.css";
36
36
  @import "./code-block.css";
37
+ @import "./chart.css";
@@ -28,13 +28,21 @@
28
28
  @apply text-text-muted;
29
29
  }
30
30
 
31
+ /* `min-width: 0` lets the value's grid track shrink below its content; pair
32
+ it with `overflow-wrap` so long unbreakable values (IDs, hashes, emails,
33
+ URLs, file paths) break instead of overflowing the column. */
31
34
  .property-list-value {
32
35
  gap: 0.5rem;
33
36
  min-width: 0;
37
+ overflow-wrap: break-word;
34
38
  }
35
39
 
36
40
  /* Compact density — tighter rows for sidebar info blocks or very many
37
41
  short attributes. */
42
+ .property-list-compact .property-list-title {
43
+ @apply mb-1;
44
+ }
45
+
38
46
  .property-list-compact .property-list-label,
39
47
  .property-list-compact .property-list-value {
40
48
  padding: 0.125rem 0.5rem;
package/src/fonts.css CHANGED
@@ -1,14 +1,16 @@
1
1
  /*
2
2
  * IBM Plex Sans + Mono — the default UI typeface for this design system.
3
3
  *
4
- * Hosted on Google's CDN (fonts.gstatic.com), latin + latin-ext subsets
5
- * only. Plex Sans is served as a variable font (one file covers weights
6
- * 400–600 via the wght axis); Plex Mono ships as discrete weight files.
4
+ * Hosted on Google's CDN (fonts.gstatic.com), latin + latin-ext subsets only.
5
+ * Plex Sans is served as a variable font (one file covers weights 400–600 via
6
+ * the wght axis); Plex Mono ships as discrete weight files.
7
7
  *
8
- * `font-display: optional` the browser uses the fallback stack from
9
- * `--font-sans` / `--font-mono` if Plex isn't ready in ~100ms, then
10
- * caches it for the next page load. No FOUT, no layout shift, and on
11
- * fast networks the typeface still wins on first paint.
8
+ * `font-display: swap` paints text immediately. Layout shift on swap is
9
+ * neutralised by the metric-matched fallback faces below ("IBM Plex Sans
10
+ * Fallback" / "IBM Plex Mono Fallback"): they alias a local system font but
11
+ * override its metrics to occupy Plex's exact box, so the swap changes glyph
12
+ * shapes without moving anything. The fallback families are wired into
13
+ * `--font-sans` / `--font-mono` in theme.css, ahead of the generic stack.
12
14
  *
13
15
  * Opt out by overriding `--font-sans` / `--font-mono`, or by importing
14
16
  * admin-css's source files individually and skipping this one.
@@ -19,7 +21,7 @@
19
21
  font-family: "IBM Plex Sans";
20
22
  font-style: normal;
21
23
  font-weight: 400 600;
22
- font-display: optional;
24
+ font-display: swap;
23
25
  src: url(https://fonts.gstatic.com/s/ibmplexsans/v23/zYXzKVElMYYaJe8bpLHnCwDKr932-G7dytD-Dmu1syxQKYbABA.woff2)
24
26
  format("woff2");
25
27
  unicode-range:
@@ -31,7 +33,7 @@
31
33
  font-family: "IBM Plex Sans";
32
34
  font-style: normal;
33
35
  font-weight: 400 600;
34
- font-display: optional;
36
+ font-display: swap;
35
37
  src: url(https://fonts.gstatic.com/s/ibmplexsans/v23/zYXzKVElMYYaJe8bpLHnCwDKr932-G7dytD-Dmu1syxeKYY.woff2)
36
38
  format("woff2");
37
39
  unicode-range:
@@ -44,7 +46,7 @@
44
46
  font-family: "IBM Plex Mono";
45
47
  font-style: normal;
46
48
  font-weight: 400;
47
- font-display: optional;
49
+ font-display: swap;
48
50
  src: url(https://fonts.gstatic.com/s/ibmplexmono/v20/-F63fjptAgt5VM-kVkqdyU8n1iEq129k.woff2)
49
51
  format("woff2");
50
52
  unicode-range:
@@ -56,7 +58,7 @@
56
58
  font-family: "IBM Plex Mono";
57
59
  font-style: normal;
58
60
  font-weight: 400;
59
- font-display: optional;
61
+ font-display: swap;
60
62
  src: url(https://fonts.gstatic.com/s/ibmplexmono/v20/-F63fjptAgt5VM-kVkqdyU8n1i8q1w.woff2)
61
63
  format("woff2");
62
64
  unicode-range:
@@ -67,7 +69,7 @@
67
69
  font-family: "IBM Plex Mono";
68
70
  font-style: normal;
69
71
  font-weight: 500;
70
- font-display: optional;
72
+ font-display: swap;
71
73
  src: url(https://fonts.gstatic.com/s/ibmplexmono/v20/-F6qfjptAgt5VM-kVkqdyU8n3twJwl5FgtIU.woff2)
72
74
  format("woff2");
73
75
  unicode-range:
@@ -79,10 +81,37 @@
79
81
  font-family: "IBM Plex Mono";
80
82
  font-style: normal;
81
83
  font-weight: 500;
82
- font-display: optional;
84
+ font-display: swap;
83
85
  src: url(https://fonts.gstatic.com/s/ibmplexmono/v20/-F6qfjptAgt5VM-kVkqdyU8n3twJwlBFgg.woff2)
84
86
  format("woff2");
85
87
  unicode-range:
86
88
  U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
87
89
  U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
88
90
  }
91
+
92
+ /*
93
+ * Metric-matched fallbacks — a local system font rewritten to Plex's box so
94
+ * the swap above causes no layout shift. The override numbers were computed
95
+ * once from font metrics with @capsizecss/core (`createFontStack`); the project
96
+ * doesn't depend on capsize, so if the primary font ever changes, recompute
97
+ * them with capsize rather than hand-editing. size-adjust holds in every
98
+ * engine; the ascent/descent overrides are ignored by Safari/WebKit, but
99
+ * line-gap is 0 so the residual vertical shift there is negligible.
100
+ */
101
+ /* IBM Plex Sans -> Arial */
102
+ @font-face {
103
+ font-family: "IBM Plex Sans Fallback";
104
+ src: local("Arial"), local("ArialMT");
105
+ ascent-override: 101.3184%;
106
+ descent-override: 27.183%;
107
+ line-gap-override: 0%;
108
+ size-adjust: 101.1663%;
109
+ }
110
+ /* IBM Plex Mono -> Courier New */
111
+ @font-face {
112
+ font-family: "IBM Plex Mono Fallback";
113
+ src: local("Courier New"), local("CourierNewPSMT");
114
+ ascent-override: 102.5167%;
115
+ descent-override: 27.5045%;
116
+ size-adjust: 99.9837%;
117
+ }
package/src/theme.css CHANGED
@@ -179,10 +179,11 @@
179
179
  * indirection. Override `--font-sans` to swap the entire UI font.
180
180
  */
181
181
  --font-sans:
182
- "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
182
+ "IBM Plex Sans", "IBM Plex Sans Fallback", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
183
+ Roboto, sans-serif;
183
184
  --font-mono:
184
- "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono",
185
- monospace;
185
+ "IBM Plex Mono", "IBM Plex Mono Fallback", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
186
+ Consolas, "Liberation Mono", monospace;
186
187
  }
187
188
 
188
189
  @theme static {