@gridkitjs/theme-tailwind 0.2.3 → 0.3.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
@@ -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.0",
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
 
@@ -257,6 +294,57 @@
257
294
  background-color: var(--gridkit-surface-muted);
258
295
  }
259
296
 
297
+ /*
298
+ * Selection, after the hover rules so that a selected row hovered stays
299
+ * selected — the two would otherwise be the same colour, since hover already
300
+ * claims `--gridkit-surface-muted`.
301
+ *
302
+ * A selected cell wins over its row and its column: it is the more specific
303
+ * thing the user pointed at, and the rule below it says so by ordering.
304
+ */
305
+ .gridkit-data-grid .grid-row.is-selected,
306
+ .gridkit-data-grid .header-cell.is-selected,
307
+ .gridkit-data-grid .grid-cell.is-selected {
308
+ background-color: var(--gridkit-selected);
309
+ }
310
+
311
+ .gridkit-data-grid:not(.no-hover-rows) .grid-row.is-selected:hover,
312
+ .gridkit-data-grid:not(.no-hover-cells) .grid-cell.is-selected:hover,
313
+ .gridkit-data-grid:not(.no-hover-columns)
314
+ .grid-header
315
+ .header-cell.is-selected:hover {
316
+ background-color: var(--gridkit-selected-strong);
317
+ }
318
+
319
+ /*
320
+ * Only where a press does something. A grid that merely displays data keeps
321
+ * the default cursor, which is what says it is not interactive.
322
+ *
323
+ * A reorderable header keeps its `grab`: it is the rarer affordance and the
324
+ * one a user would not otherwise guess, and its header still selects.
325
+ */
326
+ .gridkit-data-grid.selectable-rows .grid-row,
327
+ .gridkit-data-grid.selectable-cells .grid-cell,
328
+ .gridkit-data-grid.selectable-columns
329
+ .grid-header
330
+ .header-cell:not(.is-reorderable) {
331
+ cursor: pointer;
332
+ }
333
+
334
+ /*
335
+ * A Shift-click takes a range of rows, and would otherwise take a range of
336
+ * text along with it — leaving the browser's own highlight smeared across
337
+ * every cell it crossed.
338
+ *
339
+ * The cost is that the text no longer drags out to be copied, which is why
340
+ * this is scoped to a grid that asked for selection rather than applied to
341
+ * all of them.
342
+ */
343
+ .gridkit-data-grid.selectable-rows .grid-row,
344
+ .gridkit-data-grid.selectable-cells .grid-cell {
345
+ user-select: none;
346
+ }
347
+
260
348
  /* Horizontal borders */
261
349
  .gridkit-data-grid.borders-horizontal .grid-header .header-cell,
262
350
  .gridkit-data-grid.borders-horizontal .grid-cell {