@gridkitjs/theme-tailwind 0.2.3 → 0.3.1

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.
Files changed (3) hide show
  1. package/README.md +31 -9
  2. package/package.json +1 -1
  3. package/src/styles.css +158 -9
package/README.md CHANGED
@@ -42,18 +42,40 @@ Tailwind config:
42
42
  }
43
43
  ```
44
44
 
45
- | Token | What it colours |
46
- | ------------------------- | ------------------------------- |
47
- | `--gridkit-surface` | Header background |
48
- | `--gridkit-surface-muted` | Hover background |
49
- | `--gridkit-line` | Borders |
50
- | `--gridkit-hover-line` | Cell hover outline, resize edge |
51
- | `--gridkit-fg` | Text |
52
- | `--gridkit-fg-muted` | Secondary text, resize grip |
53
- | `--gridkit-accent` | Accent |
45
+ | Token | What it colours |
46
+ | --------------------------- | ----------------------------------- |
47
+ | `--gridkit-surface` | Header background |
48
+ | `--gridkit-surface-muted` | Hover background |
49
+ | `--gridkit-line` | Borders |
50
+ | `--gridkit-hover-line` | Cell hover outline, resize edge |
51
+ | `--gridkit-fg` | Text |
52
+ | `--gridkit-fg-muted` | Secondary text, resize grip |
53
+ | `--gridkit-accent` | Accent, drop indicator, focus ring |
54
+ | `--gridkit-selected` | Selected row, column or cell |
55
+ | `--gridkit-selected-strong` | A selected row or cell also hovered |
54
56
 
55
57
  Redefine them under `.dark` to change the dark palette too.
56
58
 
59
+ `--gridkit-selected-strong` earns its place because hover already claims
60
+ `--gridkit-surface-muted`: with one token a selected row would lose its
61
+ highlight under the pointer.
62
+
63
+ ## State classes
64
+
65
+ The grid marks its own state, so a consumer's CSS can reach it too:
66
+
67
+ | Class | On |
68
+ | ------------------------------------------------------------- | --------------------------------------------------- |
69
+ | `is-selected` | A selected `grid-row`, `header-cell` or `grid-cell` |
70
+ | `is-resizing` / `is-dragging` | The column being resized or dragged |
71
+ | `is-drop-before` / `is-drop-after` | Where a dragged column would land |
72
+ | `is-reorderable` / `is-wrapped` | A header that drags; a cell that wraps |
73
+ | `selectable-rows` / `selectable-columns` / `selectable-cells` | On the grid, per `selectable` |
74
+ | `no-hover-rows` / `no-hover-columns` / `no-hover-cells` | On the grid, per `hoverable` |
75
+
76
+ The `selectable-*` classes enable and the `no-hover-*` classes disable, because
77
+ selection is off by default and hover is on — each follows its own default.
78
+
57
79
  ## License
58
80
 
59
81
  MIT © Blagoja Blazhevski
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridkitjs/theme-tailwind",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
4
4
  "description": "Tailwind v4 theme for GridKit — palette tokens, dark mode and grid styles.",
5
5
  "license": "MIT",
6
6
  "author": "Blagoja Blazhevski",
package/src/styles.css CHANGED
@@ -23,6 +23,8 @@
23
23
  --gridkit-fg: oklch(0.21 0.01 250);
24
24
  --gridkit-fg-muted: oklch(0.55 0.015 250);
25
25
  --gridkit-accent: oklch(0.6 0.17 255);
26
+ --gridkit-selected: oklch(0.94 0.03 255);
27
+ --gridkit-selected-strong: oklch(0.9 0.05 255);
26
28
  }
27
29
 
28
30
  .dark {
@@ -35,6 +37,8 @@
35
37
  --gridkit-fg: oklch(0.97 0.003 250);
36
38
  --gridkit-fg-muted: oklch(0.7 0.015 250);
37
39
  --gridkit-accent: oklch(0.7 0.15 255);
40
+ --gridkit-selected: oklch(0.32 0.05 255);
41
+ --gridkit-selected-strong: oklch(0.38 0.07 255);
38
42
  }
39
43
 
40
44
  /*
@@ -52,6 +56,8 @@
52
56
  --color-fg: var(--gridkit-fg);
53
57
  --color-fg-muted: var(--gridkit-fg-muted);
54
58
  --color-accent: var(--gridkit-accent);
59
+ --color-selected: var(--gridkit-selected);
60
+ --color-selected-strong: var(--gridkit-selected-strong);
55
61
  }
56
62
 
57
63
  /*
@@ -67,6 +73,26 @@
67
73
  overflow-x: auto;
68
74
  }
69
75
 
76
+ /*
77
+ * Read but not seen — the grid's live region, which reports a reorder or a
78
+ * resize that only a sighted user could otherwise notice.
79
+ *
80
+ * Clipped to nothing rather than hidden with `display: none` or
81
+ * `visibility: hidden`, either of which would take it out of the
82
+ * accessibility tree along with the announcement.
83
+ */
84
+ .gridkit-sr-only {
85
+ position: absolute;
86
+ width: 1px;
87
+ height: 1px;
88
+ margin: -1px;
89
+ padding: 0;
90
+ overflow: hidden;
91
+ clip-path: inset(50%);
92
+ white-space: nowrap;
93
+ border-width: 0;
94
+ }
95
+
70
96
  /*
71
97
  * `fixed` is what makes a width a width. Under the default `auto` layout the
72
98
  * browser treats the colgroup as a hint and re-apportions space by content,
@@ -137,21 +163,33 @@
137
163
  * `box-shadow` rather than `border-right`: under `borders="none"` there is no
138
164
  * border to recolour, and adding one would shift the cell's content by a
139
165
  * pixel mid-drag.
140
- *
141
- * Focus gets the same line as far as CSS can reach — the handle is tabbable
142
- * and resizes with the arrow keys, so it has to say which edge it is on.
143
166
  */
144
167
  .gridkit-data-grid .header-cell.is-resizing,
145
- .gridkit-data-grid .grid-cell.is-resizing,
146
- .gridkit-data-grid .header-cell:has(.header-resize-handle:focus-visible) {
168
+ .gridkit-data-grid .grid-cell.is-resizing {
147
169
  box-shadow: inset -2px 0 0 0 var(--gridkit-hover-line);
148
170
  }
149
171
 
172
+ /*
173
+ * The grid is one tab stop and the arrow keys move within it, so the focused
174
+ * cell is the only sign of where that stop currently is — without this ring a
175
+ * keyboard user is navigating blind.
176
+ *
177
+ * Inset because the viewport clips its overflow: an outline drawn outwards
178
+ * would be cut off on the first and last columns.
179
+ */
180
+ .gridkit-data-grid .header-cell:focus-visible,
181
+ .gridkit-data-grid .grid-cell:focus-visible {
182
+ outline: 2px solid var(--gridkit-accent);
183
+ outline-offset: -2px;
184
+ }
185
+
150
186
  /*
151
187
  * A reorderable header is the grab zone for its own drag, so a press on it
152
- * must not select the label instead.
188
+ * must not select the label instead. Asked for by name: every header is
189
+ * focusable now that the grid roves one tab stop, so a `tabindex` no longer
190
+ * distinguishes the ones that drag.
153
191
  */
154
- .gridkit-data-grid .header-cell[tabindex] {
192
+ .gridkit-data-grid .header-cell.is-reorderable {
155
193
  cursor: grab;
156
194
  touch-action: none;
157
195
  user-select: none;
@@ -231,8 +269,7 @@
231
269
  * Unscoped by `no-hover-columns`: the grip is a resize affordance, not part
232
270
  * of the hover styling a consumer can turn off.
233
271
  */
234
- .gridkit-data-grid .grid-header .header-cell:hover .header-resize-grip,
235
- .gridkit-data-grid .header-resize-handle:focus-visible .header-resize-grip {
272
+ .gridkit-data-grid .grid-header .header-cell:hover .header-resize-grip {
236
273
  opacity: 1;
237
274
  }
238
275
 
@@ -240,6 +277,67 @@
240
277
  opacity: 0;
241
278
  }
242
279
 
280
+ /*
281
+ * Docked to the header's own right edge, absolutely — like the resize
282
+ * handle, and for the same reason: sitting in the label's normal flow, a
283
+ * long label under `text-overflow: ellipsis` pushes the toggle out past
284
+ * where `overflow: hidden` clips it, leaving it unclickable (a real click
285
+ * there lands on the header cell instead and selects the column). Docked
286
+ * to a fixed offset, it stays inside the clipped area — and clear of the
287
+ * resize handle's own 6px strip at `right: 0`, so a resizable, sortable
288
+ * column keeps two independent hit targets rather than one shadowing the
289
+ * other.
290
+ */
291
+ .gridkit-data-grid .header-sort-toggle {
292
+ display: inline-flex;
293
+ position: absolute;
294
+ top: 50%;
295
+ right: 0.75rem;
296
+ transform: translateY(-50%);
297
+ align-items: center;
298
+ gap: 0.125rem;
299
+ cursor: pointer;
300
+ color: var(--gridkit-fg-muted);
301
+ }
302
+
303
+ .gridkit-data-grid .header-sort-toggle svg {
304
+ width: 14px;
305
+ height: 14px;
306
+ flex-shrink: 0;
307
+ }
308
+
309
+ /*
310
+ * Hidden until the column has a direction or the header is hovered or
311
+ * focused — an unsorted, un-hovered header stays quiet, the same restraint
312
+ * `.header-resize-grip` uses.
313
+ */
314
+ .gridkit-data-grid
315
+ .header-sort-toggle:not(.is-sorted-asc):not(.is-sorted-desc) {
316
+ opacity: 0;
317
+ }
318
+
319
+ .gridkit-data-grid .grid-header .header-cell:hover .header-sort-toggle,
320
+ .gridkit-data-grid .header-cell:focus-visible .header-sort-toggle {
321
+ opacity: 1;
322
+ }
323
+
324
+ .gridkit-data-grid .header-sort-toggle.is-sorted-asc,
325
+ .gridkit-data-grid .header-sort-toggle.is-sorted-desc {
326
+ opacity: 1;
327
+ color: var(--gridkit-accent);
328
+ }
329
+
330
+ /* One chevron covers both directions; `desc` is `asc` turned upside down. */
331
+ .gridkit-data-grid .header-sort-toggle.is-sorted-desc svg {
332
+ transform: rotate(180deg);
333
+ }
334
+
335
+ .gridkit-data-grid .header-sort-priority {
336
+ font-size: 0.625rem;
337
+ font-weight: 700;
338
+ line-height: 1;
339
+ }
340
+
243
341
  .gridkit-data-grid:not(.no-hover-columns) .grid-header .header-cell:hover {
244
342
  background-color: var(--gridkit-surface-muted);
245
343
  }
@@ -257,6 +355,57 @@
257
355
  background-color: var(--gridkit-surface-muted);
258
356
  }
259
357
 
358
+ /*
359
+ * Selection, after the hover rules so that a selected row hovered stays
360
+ * selected — the two would otherwise be the same colour, since hover already
361
+ * claims `--gridkit-surface-muted`.
362
+ *
363
+ * A selected cell wins over its row and its column: it is the more specific
364
+ * thing the user pointed at, and the rule below it says so by ordering.
365
+ */
366
+ .gridkit-data-grid .grid-row.is-selected,
367
+ .gridkit-data-grid .header-cell.is-selected,
368
+ .gridkit-data-grid .grid-cell.is-selected {
369
+ background-color: var(--gridkit-selected);
370
+ }
371
+
372
+ .gridkit-data-grid:not(.no-hover-rows) .grid-row.is-selected:hover,
373
+ .gridkit-data-grid:not(.no-hover-cells) .grid-cell.is-selected:hover,
374
+ .gridkit-data-grid:not(.no-hover-columns)
375
+ .grid-header
376
+ .header-cell.is-selected:hover {
377
+ background-color: var(--gridkit-selected-strong);
378
+ }
379
+
380
+ /*
381
+ * Only where a press does something. A grid that merely displays data keeps
382
+ * the default cursor, which is what says it is not interactive.
383
+ *
384
+ * A reorderable header keeps its `grab`: it is the rarer affordance and the
385
+ * one a user would not otherwise guess, and its header still selects.
386
+ */
387
+ .gridkit-data-grid.selectable-rows .grid-row,
388
+ .gridkit-data-grid.selectable-cells .grid-cell,
389
+ .gridkit-data-grid.selectable-columns
390
+ .grid-header
391
+ .header-cell:not(.is-reorderable) {
392
+ cursor: pointer;
393
+ }
394
+
395
+ /*
396
+ * A Shift-click takes a range of rows, and would otherwise take a range of
397
+ * text along with it — leaving the browser's own highlight smeared across
398
+ * every cell it crossed.
399
+ *
400
+ * The cost is that the text no longer drags out to be copied, which is why
401
+ * this is scoped to a grid that asked for selection rather than applied to
402
+ * all of them.
403
+ */
404
+ .gridkit-data-grid.selectable-rows .grid-row,
405
+ .gridkit-data-grid.selectable-cells .grid-cell {
406
+ user-select: none;
407
+ }
408
+
260
409
  /* Horizontal borders */
261
410
  .gridkit-data-grid.borders-horizontal .grid-header .header-cell,
262
411
  .gridkit-data-grid.borders-horizontal .grid-cell {