@gridkitjs/theme-tailwind 0.7.0 → 0.8.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 +32 -20
  2. package/package.json +1 -1
  3. package/src/styles.css +381 -29
package/README.md CHANGED
@@ -46,7 +46,7 @@ the grid's own root:
46
46
 
47
47
  ```tsx
48
48
  <div className="gridkit-dark">
49
- <DataGridComponent ... />
49
+ <DataGrid ... />
50
50
  </div>
51
51
  ```
52
52
 
@@ -62,17 +62,17 @@ Tailwind config:
62
62
  }
63
63
  ```
64
64
 
65
- | Token | What it colours |
66
- | --------------------------- | ----------------------------------- |
67
- | `--gridkit-surface` | Header background |
68
- | `--gridkit-surface-muted` | Hover background |
69
- | `--gridkit-line` | Borders |
70
- | `--gridkit-hover-line` | Cell hover outline, resize edge |
71
- | `--gridkit-fg` | Text |
72
- | `--gridkit-fg-muted` | Secondary text, resize grip |
73
- | `--gridkit-accent` | Accent, drop indicator, focus ring |
74
- | `--gridkit-selected` | Selected row, column or cell |
75
- | `--gridkit-selected-strong` | A selected row or cell also hovered |
65
+ | Token | What it colours |
66
+ | --------------------------- | ------------------------------------------------------------------------ |
67
+ | `--gridkit-surface` | Header background |
68
+ | `--gridkit-surface-muted` | Hover background |
69
+ | `--gridkit-line` | Borders |
70
+ | `--gridkit-hover-line` | Cell hover outline, resize edge |
71
+ | `--gridkit-fg` | Text |
72
+ | `--gridkit-fg-muted` | Secondary text and icons |
73
+ | `--gridkit-accent` | Focus rings, drop indicators, and the active sort, group and check marks |
74
+ | `--gridkit-selected` | Selected row, column or cell |
75
+ | `--gridkit-selected-strong` | A selected row or cell also hovered |
76
76
 
77
77
  Redefine them inside `@variant dark { }` (or under `.gridkit-dark`) to change
78
78
  the dark palette too:
@@ -95,18 +95,30 @@ highlight under the pointer.
95
95
 
96
96
  The grid marks its own state, so a consumer's CSS can reach it too:
97
97
 
98
- | Class | On |
99
- | ------------------------------------------------------------- | --------------------------------------------------- |
100
- | `is-selected` | A selected `grid-row`, `header-cell` or `grid-cell` |
101
- | `is-resizing` / `is-dragging` | The column being resized or dragged |
102
- | `is-drop-before` / `is-drop-after` | Where a dragged column would land |
103
- | `is-reorderable` / `is-wrapped` | A header that drags; a cell that wraps |
104
- | `selectable-rows` / `selectable-columns` / `selectable-cells` | On the grid, per `selectable` |
105
- | `no-hover-rows` / `no-hover-columns` / `no-hover-cells` | On the grid, per `hoverable` |
98
+ | Class | On |
99
+ | ------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
100
+ | `is-selected` | A selected `grid-row`, `header-cell` or `grid-cell` |
101
+ | `is-resizing` / `is-dragging` | The column being resized or dragged |
102
+ | `is-drop-before` / `is-drop-after` | Where a dragged column would land |
103
+ | `is-reorderable` / `is-wrapped` | A header that drags; a cell that wraps |
104
+ | `selectable-rows` / `selectable-columns` / `selectable-cells` | On the grid, per `selectable` |
105
+ | `no-hover-rows` / `no-hover-columns` / `no-hover-cells` | On the grid, per `hoverable` |
106
+ | `is-sorted-asc` / `is-sorted-desc` | A header's `header-sort-toggle` while its column sorts |
107
+ | `is-grouped` | A header's `header-group-toggle` while its column is grouped |
108
+ | `is-expanded` | A group row's `group-toggle` while the group is open |
109
+ | `is-drag-target` / `is-drag-blocked` | The group-by bar while a drag can drop on it; while a header already grouped is dragged at it |
106
110
 
107
111
  The `selectable-*` classes enable and the `no-hover-*` classes disable, because
108
112
  selection is off by default and hover is on — each follows its own default.
109
113
 
114
+ The toolbar (`gridkit-toolbar`), the overlay around every menu and panel
115
+ (`gridkit-overlay`), menus (`gridkit-menu`) and the column chooser
116
+ (`gridkit-column-chooser`) mark their state with ARIA attributes rather than
117
+ classes — `aria-disabled`, `aria-pressed`, `aria-checked`, `aria-expanded` —
118
+ and the stylesheet targets those. An overlay renders into `document.body` and
119
+ carries the grid's `gridkit-light`/`gridkit-dark`, so its selectors are
120
+ top-level, not under `gridkit-data-grid`.
121
+
110
122
  ## License
111
123
 
112
124
  MIT © Blagoja Blazhevski
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridkitjs/theme-tailwind",
3
- "version": "0.7.0",
3
+ "version": "0.8.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
@@ -275,6 +275,23 @@
275
275
  opacity: 0.5;
276
276
  }
277
277
 
278
+ /*
279
+ * A header, cell or group row that opens the grid's context menu — its
280
+ * `aria-keyshortcuts` names Shift+F10 then — takes a long-press for that
281
+ * menu, so iOS must not show its own callout, or start selecting the text
282
+ * under the finger, on the same press.
283
+ */
284
+ .gridkit-data-grid [aria-keyshortcuts~="Shift+F10"] {
285
+ -webkit-touch-callout: none;
286
+ }
287
+
288
+ @media (pointer: coarse) {
289
+ .gridkit-data-grid [aria-keyshortcuts~="Shift+F10"] {
290
+ -webkit-user-select: none;
291
+ user-select: none;
292
+ }
293
+ }
294
+
278
295
  /*
279
296
  * The header trailing the pointer. It sits on the body rather than in the
280
297
  * table, so it restates what a header cell gets from its place in the grid.
@@ -325,33 +342,6 @@
325
342
  box-shadow: inset -2px 0 0 0 var(--gridkit-accent);
326
343
  }
327
344
 
328
- /*
329
- * `pointer-events: none` keeps the grab zone exactly the handle's 6px — the
330
- * grip only says where to click.
331
- */
332
- .gridkit-data-grid .header-resize-grip {
333
- position: absolute;
334
- top: 50%;
335
- right: 0;
336
- transform: translateY(-50%);
337
- color: var(--gridkit-fg-muted);
338
- fill: currentColor;
339
- opacity: 0;
340
- pointer-events: none;
341
- }
342
-
343
- /*
344
- * Unscoped by `no-hover-columns`: the grip is a resize affordance, not part
345
- * of the hover styling a consumer can turn off.
346
- */
347
- .gridkit-data-grid .grid-header .header-cell:hover .header-resize-grip {
348
- opacity: 1;
349
- }
350
-
351
- .gridkit-data-grid .header-cell.is-resizing .header-resize-grip {
352
- opacity: 0;
353
- }
354
-
355
345
  /*
356
346
  * Docked to the header's own right edge, absolutely — like the resize
357
347
  * handle, and for the same reason: sitting in the label's normal flow, a
@@ -383,8 +373,7 @@
383
373
 
384
374
  /*
385
375
  * Hidden until the column has a direction or the header is hovered or
386
- * focused — an unsorted, un-hovered header stays quiet, the same restraint
387
- * `.header-resize-grip` uses.
376
+ * focused — an unsorted, un-hovered header stays quiet.
388
377
  */
389
378
  .gridkit-data-grid
390
379
  .header-sort-toggle:not(.is-sorted-asc):not(.is-sorted-desc) {
@@ -751,6 +740,148 @@
751
740
  border-bottom: none;
752
741
  }
753
742
 
743
+ /*
744
+ * The toolbar: the grid's first child, above the group-by bar, and unscoped
745
+ * by `.gridkit-data-grid` for the same reason that bar is. The grid scrolls
746
+ * sideways with everything in it, so the toolbar sticks to its start edge
747
+ * and stays in view while the tables scroll on under it.
748
+ *
749
+ * Its entries keep to one row at their own widths, which is what the
750
+ * overflow measures: what does not fit goes into "More", and `overflow:
751
+ * hidden` keeps the frame before that from spilling out of the toolbar.
752
+ */
753
+ .gridkit-toolbar {
754
+ position: sticky;
755
+ inset-inline-start: 0;
756
+ display: flex;
757
+ align-items: center;
758
+ gap: 0.5rem;
759
+ padding: 0.5rem;
760
+ overflow: hidden;
761
+ font-size: 0.8125rem;
762
+ color: var(--gridkit-fg);
763
+ background-color: var(--gridkit-surface);
764
+ border-bottom: 1px solid var(--gridkit-line);
765
+ }
766
+
767
+ .gridkit-toolbar > * {
768
+ flex-shrink: 0;
769
+ }
770
+
771
+ /*
772
+ * The search box and custom entries never move into "More", so together
773
+ * they can be wider than the toolbar. "More" then sticks to its end edge,
774
+ * over what is clipped there, rather than being clipped itself.
775
+ */
776
+ .gridkit-toolbar > .toolbar-more {
777
+ position: sticky;
778
+ /* Counted from the toolbar's padding edge, so its padding again. */
779
+ inset-inline-end: 0.5rem;
780
+ }
781
+
782
+ /* A command, a dropdown, or "More". */
783
+ .toolbar-button {
784
+ display: inline-flex;
785
+ align-items: center;
786
+ gap: 0.375rem;
787
+ padding: 0.25rem 0.625rem;
788
+ font: inherit;
789
+ color: var(--gridkit-fg);
790
+ white-space: nowrap;
791
+ cursor: pointer;
792
+ background-color: var(--gridkit-surface);
793
+ border: 1px solid var(--gridkit-line);
794
+ border-radius: 0.25rem;
795
+ }
796
+
797
+ .toolbar-button:hover:not([aria-disabled="true"]),
798
+ .toolbar-button[aria-expanded="true"] {
799
+ background-color: var(--gridkit-surface-muted);
800
+ }
801
+
802
+ .toolbar-button:focus-visible {
803
+ outline: 2px solid var(--gridkit-accent);
804
+ outline-offset: 1px;
805
+ }
806
+
807
+ /* Still focusable, as a menu's disabled item is, so a screen reader finds it. */
808
+ .toolbar-button[aria-disabled="true"] {
809
+ color: var(--gridkit-fg-muted);
810
+ cursor: default;
811
+ opacity: 0.5;
812
+ }
813
+
814
+ /* A toggle that is on. */
815
+ .toolbar-button[aria-pressed="true"],
816
+ .toolbar-button[aria-pressed="true"]:hover {
817
+ background-color: var(--gridkit-selected-strong);
818
+ border-color: var(--gridkit-accent);
819
+ }
820
+
821
+ .toolbar-button-icon,
822
+ .toolbar-button-indicator {
823
+ display: inline-flex;
824
+ color: var(--gridkit-fg-muted);
825
+ }
826
+
827
+ /* An icon key the grid has no glyph for draws nothing, and takes no room. */
828
+ .toolbar-button-icon:empty {
829
+ display: none;
830
+ }
831
+
832
+ .toolbar-button-icon svg,
833
+ .toolbar-button-indicator svg {
834
+ width: 1rem;
835
+ height: 1rem;
836
+ }
837
+
838
+ .toolbar-button-indicator {
839
+ margin-inline-end: -0.25rem;
840
+ }
841
+
842
+ /*
843
+ * Narrower in a narrow toolbar, by the toolbar's width alone — never by
844
+ * what else is in it, which the overflow would measure as a width of its
845
+ * own — so it leaves room for "More" beside it.
846
+ */
847
+ .toolbar-search {
848
+ width: 12rem;
849
+ max-width: 50%;
850
+ padding: 0.25rem 0.5rem;
851
+ font: inherit;
852
+ color: var(--gridkit-fg);
853
+ background-color: var(--gridkit-surface);
854
+ border: 1px solid var(--gridkit-line);
855
+ border-radius: 0.25rem;
856
+ }
857
+
858
+ .toolbar-search::placeholder {
859
+ color: var(--gridkit-fg-muted);
860
+ }
861
+
862
+ .toolbar-search:focus-visible {
863
+ outline: 2px solid var(--gridkit-accent);
864
+ outline-offset: 1px;
865
+ }
866
+
867
+ .toolbar-separator {
868
+ align-self: stretch;
869
+ width: 1px;
870
+ margin: 0.125rem 0;
871
+ background-color: var(--gridkit-line);
872
+ }
873
+
874
+ /* Takes the free space, pushing what follows it to the far end. */
875
+ .gridkit-toolbar > .toolbar-spacer {
876
+ flex: 1 1 0;
877
+ }
878
+
879
+ /* Holds what `renderToolbarItem` drew. */
880
+ .toolbar-custom {
881
+ display: inline-flex;
882
+ align-items: center;
883
+ }
884
+
754
885
  /*
755
886
  * The group-by bar. A sibling of the table, not a row inside it — see
756
887
  * `GroupByBar.tsx`'s own note on why — so it's unscoped by `.gridkit-data-grid`
@@ -971,4 +1102,225 @@
971
1102
  outline: 2px solid var(--gridkit-accent);
972
1103
  outline-offset: 1px;
973
1104
  }
1105
+
1106
+ /*
1107
+ * Overlays — the grid's menus and panels — render into `document.body`, outside the
1108
+ * grid and any scrolling ancestor that would clip them, so every selector
1109
+ * from here on is top-level rather than under `.gridkit-data-grid`. The
1110
+ * grid copies the `.gridkit-light`/`.gridkit-dark` it sits under onto the
1111
+ * overlay, since the portal leaves that ancestor's token scope.
1112
+ *
1113
+ * Fixed from the start, so the overlay never takes room at the end of the
1114
+ * page before it is placed; above the grid's own drag ghosts.
1115
+ */
1116
+ .gridkit-overlay {
1117
+ position: fixed;
1118
+ top: 0;
1119
+ left: 0;
1120
+ z-index: 60;
1121
+ color: var(--gridkit-fg);
1122
+ }
1123
+
1124
+ /*
1125
+ * A menu too tall for the viewport scrolls inside itself — a scroll there
1126
+ * does not dismiss it, as one outside would.
1127
+ */
1128
+ .gridkit-menu {
1129
+ min-width: 12rem;
1130
+ max-height: 100vh;
1131
+ overflow-y: auto;
1132
+ padding: 0.25rem 0;
1133
+ font-size: 0.875rem;
1134
+ background-color: var(--gridkit-surface);
1135
+ border: 1px solid var(--gridkit-line);
1136
+ border-radius: 0.375rem;
1137
+ box-shadow: 0 4px 12px oklch(0 0 0 / 0.15);
1138
+ }
1139
+
1140
+ .menu-item {
1141
+ display: flex;
1142
+ align-items: center;
1143
+ gap: 0.5rem;
1144
+ padding: 0.375rem 0.75rem;
1145
+ white-space: nowrap;
1146
+ cursor: pointer;
1147
+ user-select: none;
1148
+ }
1149
+
1150
+ /*
1151
+ * `:focus` rather than `:focus-visible`: the pointer moves focus to the
1152
+ * item under it, so focus is the hover state too, and has to show
1153
+ * whichever moved it.
1154
+ */
1155
+ .menu-item:focus {
1156
+ outline: none;
1157
+ background-color: var(--gridkit-selected);
1158
+ }
1159
+
1160
+ /*
1161
+ * The item whose submenu is open, while focus is in that submenu — the
1162
+ * trail back to it.
1163
+ */
1164
+ .menu-item[aria-expanded="true"]:not(:focus) {
1165
+ background-color: var(--gridkit-surface-muted);
1166
+ }
1167
+
1168
+ /*
1169
+ * Still focusable, so a screen reader finds it: muted, and marked only
1170
+ * faintly when focused, since choosing it does nothing.
1171
+ */
1172
+ .menu-item[aria-disabled="true"] {
1173
+ color: var(--gridkit-fg-muted);
1174
+ cursor: default;
1175
+ }
1176
+
1177
+ .menu-item[aria-disabled="true"]:focus {
1178
+ background-color: var(--gridkit-surface-muted);
1179
+ }
1180
+
1181
+ /*
1182
+ * Always there, empty for an item without an icon, so every label in a
1183
+ * menu starts at the same place. A checked item shows its check here.
1184
+ */
1185
+ .menu-item-icon {
1186
+ display: inline-flex;
1187
+ flex-shrink: 0;
1188
+ align-items: center;
1189
+ justify-content: center;
1190
+ width: 1rem;
1191
+ height: 1rem;
1192
+ color: var(--gridkit-fg-muted);
1193
+ }
1194
+
1195
+ .menu-item-icon svg,
1196
+ .menu-submenu-indicator svg {
1197
+ width: 1rem;
1198
+ height: 1rem;
1199
+ }
1200
+
1201
+ .menu-item[aria-checked="true"] .menu-item-icon {
1202
+ color: var(--gridkit-accent);
1203
+ }
1204
+
1205
+ .menu-item-label {
1206
+ flex: 1;
1207
+ }
1208
+
1209
+ .menu-item-shortcut {
1210
+ margin-inline-start: 1.5rem;
1211
+ font-size: 0.75rem;
1212
+ color: var(--gridkit-fg-muted);
1213
+ }
1214
+
1215
+ .menu-submenu-indicator {
1216
+ display: inline-flex;
1217
+ margin-inline-end: -0.25rem;
1218
+ color: var(--gridkit-fg-muted);
1219
+ }
1220
+
1221
+ .menu-separator {
1222
+ height: 1px;
1223
+ margin: 0.25rem 0;
1224
+ background-color: var(--gridkit-line);
1225
+ }
1226
+
1227
+ /*
1228
+ * The column chooser, an overlay like the menus: a search box, "Show all",
1229
+ * then a checkbox per column. A fixed width, so the panel does not jump
1230
+ * sideways as a search narrows the list.
1231
+ */
1232
+ .gridkit-column-chooser {
1233
+ display: flex;
1234
+ flex-direction: column;
1235
+ gap: 0.375rem;
1236
+ width: 16rem;
1237
+ padding: 0.5rem;
1238
+ font-size: 0.875rem;
1239
+ background-color: var(--gridkit-surface);
1240
+ border: 1px solid var(--gridkit-line);
1241
+ border-radius: 0.375rem;
1242
+ box-shadow: 0 4px 12px oklch(0 0 0 / 0.15);
1243
+ }
1244
+
1245
+ .column-chooser-search {
1246
+ box-sizing: border-box;
1247
+ width: 100%;
1248
+ padding: 0.25rem 0.5rem;
1249
+ font: inherit;
1250
+ color: var(--gridkit-fg);
1251
+ background-color: var(--gridkit-surface);
1252
+ border: 1px solid var(--gridkit-line);
1253
+ border-radius: 0.25rem;
1254
+ }
1255
+
1256
+ .column-chooser-search::placeholder {
1257
+ color: var(--gridkit-fg-muted);
1258
+ }
1259
+
1260
+ .column-chooser-search:focus-visible {
1261
+ outline: 2px solid var(--gridkit-accent);
1262
+ outline-offset: 1px;
1263
+ }
1264
+
1265
+ /*
1266
+ * Past about ten columns the list scrolls inside itself — a scroll there
1267
+ * does not dismiss the chooser, as one outside would — while the search
1268
+ * box and "Show all" stay put above it.
1269
+ */
1270
+ .column-chooser-list {
1271
+ max-height: 17.5rem;
1272
+ margin: 0;
1273
+ padding: 0;
1274
+ overflow-y: auto;
1275
+ list-style: none;
1276
+ }
1277
+
1278
+ /* One checkbox and its label: "Show all", or a column. */
1279
+ .column-chooser-option {
1280
+ display: flex;
1281
+ align-items: center;
1282
+ gap: 0.5rem;
1283
+ padding: 0.25rem;
1284
+ border-radius: 0.25rem;
1285
+ cursor: pointer;
1286
+ user-select: none;
1287
+ }
1288
+
1289
+ .column-chooser-option:hover {
1290
+ background-color: var(--gridkit-surface-muted);
1291
+ }
1292
+
1293
+ /* "Show all", set apart from the columns it acts on. */
1294
+ .column-chooser-all {
1295
+ padding-bottom: 0.375rem;
1296
+ border-bottom: 1px solid var(--gridkit-line);
1297
+ border-radius: 0;
1298
+ }
1299
+
1300
+ .column-chooser-option input {
1301
+ flex-shrink: 0;
1302
+ margin: 0;
1303
+ accent-color: var(--gridkit-accent);
1304
+ }
1305
+
1306
+ .column-chooser-option input:focus-visible {
1307
+ outline: 2px solid var(--gridkit-accent);
1308
+ outline-offset: 1px;
1309
+ }
1310
+
1311
+ /* A column that cannot be hidden, or the last one shown. */
1312
+ .column-chooser-option:has(> input:disabled) {
1313
+ color: var(--gridkit-fg-muted);
1314
+ cursor: default;
1315
+ }
1316
+
1317
+ .column-chooser-option:has(> input:disabled):hover {
1318
+ background-color: transparent;
1319
+ }
1320
+
1321
+ .column-chooser-empty {
1322
+ margin: 0;
1323
+ padding: 0.25rem;
1324
+ color: var(--gridkit-fg-muted);
1325
+ }
974
1326
  }