@gridkitjs/theme-tailwind 0.3.1 → 0.4.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.
Files changed (3) hide show
  1. package/README.md +34 -3
  2. package/package.json +1 -1
  3. package/src/styles.css +100 -33
package/README.md CHANGED
@@ -23,13 +23,33 @@ them directly. Nothing needs to scan the component source.
23
23
 
24
24
  ## Dark mode
25
25
 
26
- The `dark:` variant is bound to a `.dark` class rather than the OS preference,
27
- so you drive the theme yourself:
26
+ GridKit doesn't register its own `dark:` variant — it follows whatever your
27
+ app's Tailwind build already resolves `dark:` to. Out of the box that's the
28
+ OS preference. For the common class-toggle pattern, declare it yourself,
29
+ same as any Tailwind v4 app would:
30
+
31
+ ```css
32
+ @import "tailwindcss";
33
+ @custom-variant dark (&:where(.dark, .dark *));
34
+ @import "@gridkitjs/theme-tailwind/styles.css";
35
+ ```
28
36
 
29
37
  ```js
30
38
  document.documentElement.classList.toggle("dark", isDark);
31
39
  ```
32
40
 
41
+ ### Forcing a theme on one grid
42
+
43
+ `.gridkit-light` / `.gridkit-dark` pin a grid to one palette regardless of
44
+ the ambient `dark:` state. Put either on any ancestor of the grid, including
45
+ the grid's own root:
46
+
47
+ ```tsx
48
+ <div className="gridkit-dark">
49
+ <DataGridComponent ... />
50
+ </div>
51
+ ```
52
+
33
53
  ## Theming
34
54
 
35
55
  Every colour is a CSS custom property, so overriding one is plain CSS — no
@@ -54,7 +74,18 @@ Tailwind config:
54
74
  | `--gridkit-selected` | Selected row, column or cell |
55
75
  | `--gridkit-selected-strong` | A selected row or cell also hovered |
56
76
 
57
- Redefine them under `.dark` to change the dark palette too.
77
+ Redefine them inside `@variant dark { }` (or under `.gridkit-dark`) to change
78
+ the dark palette too:
79
+
80
+ ```css
81
+ :root {
82
+ --gridkit-accent: oklch(0.6 0.17 145);
83
+
84
+ @variant dark {
85
+ --gridkit-accent: oklch(0.7 0.15 145);
86
+ }
87
+ }
88
+ ```
58
89
 
59
90
  `--gridkit-selected-strong` earns its place because hover already claims
60
91
  `--gridkit-surface-muted`: with one token a selected row would lose its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridkitjs/theme-tailwind",
3
- "version": "0.3.1",
3
+ "version": "0.4.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
@@ -4,50 +4,103 @@
4
4
  */
5
5
 
6
6
  /*
7
- * Tailwind's `dark:` variant follows the OS preference by default. Bind it to
8
- * a `.dark` class instead so consumers can drive the theme themselves.
9
- */
10
- @custom-variant dark (&:where(.dark, .dark *));
11
-
12
- /*
13
- * The palette. Light is the default; `.dark` redefines the same names, so a
14
- * token means "the header background", not "light grey".
7
+ * The palette. Each token is a raw `--gridkit-<name>-light` / `-dark` pair,
8
+ * defined once below; every rule in this file reads the live
9
+ * `--gridkit-<name>` name instead, which gets pointed at one pair by
10
+ * whichever of these applies:
11
+ *
12
+ * - `:root`, by default — light.
13
+ * - `@variant dark` nested inside it — whatever the app's own `dark:`
14
+ * variant currently resolves to. GridKit does not register a
15
+ * `@custom-variant dark` of its own, so it never conflicts with an app
16
+ * that already has one (a class, a `data-` attribute, anything) —
17
+ * absent one, this falls back to Tailwind's own `prefers-color-scheme`
18
+ * default.
19
+ * - `.gridkit-light` / `.gridkit-dark` — an explicit, per-instance
20
+ * override. Put either on any ancestor of the grid, including the
21
+ * grid's own root, to pin one grid to a palette regardless of the
22
+ * ambient state. No specificity trick needed: custom properties inherit
23
+ * from the nearest matching ancestor, so a wrapper closer to the grid
24
+ * than `:root` simply wins.
15
25
  */
16
26
  :root {
27
+ --gridkit-surface-light: oklch(1 0 0);
28
+ --gridkit-surface-dark: oklch(0.21 0.01 250);
29
+ --gridkit-surface-muted-light: oklch(0.97 0.003 250);
30
+ --gridkit-surface-muted-dark: oklch(0.26 0.012 250);
31
+ --gridkit-line-light: oklch(0.92 0.005 250);
32
+ --gridkit-line-dark: oklch(0.33 0.014 250);
33
+ --gridkit-hover-line-light: oklch(0.65 0.09 255);
34
+ --gridkit-hover-line-dark: oklch(0.75 0.09 255);
35
+ --gridkit-fg-light: oklch(0.21 0.01 250);
36
+ --gridkit-fg-dark: oklch(0.97 0.003 250);
37
+ --gridkit-fg-muted-light: oklch(0.55 0.015 250);
38
+ --gridkit-fg-muted-dark: oklch(0.7 0.015 250);
39
+ --gridkit-accent-light: oklch(0.6 0.17 255);
40
+ --gridkit-accent-dark: oklch(0.7 0.15 255);
41
+ --gridkit-selected-light: oklch(0.94 0.03 255);
42
+ --gridkit-selected-dark: oklch(0.32 0.05 255);
43
+ --gridkit-selected-strong-light: oklch(0.9 0.05 255);
44
+ --gridkit-selected-strong-dark: oklch(0.38 0.07 255);
45
+
17
46
  color-scheme: light;
47
+ --gridkit-surface: var(--gridkit-surface-light);
48
+ --gridkit-surface-muted: var(--gridkit-surface-muted-light);
49
+ --gridkit-line: var(--gridkit-line-light);
50
+ --gridkit-hover-line: var(--gridkit-hover-line-light);
51
+ --gridkit-fg: var(--gridkit-fg-light);
52
+ --gridkit-fg-muted: var(--gridkit-fg-muted-light);
53
+ --gridkit-accent: var(--gridkit-accent-light);
54
+ --gridkit-selected: var(--gridkit-selected-light);
55
+ --gridkit-selected-strong: var(--gridkit-selected-strong-light);
56
+
57
+ @variant dark {
58
+ color-scheme: dark;
59
+ --gridkit-surface: var(--gridkit-surface-dark);
60
+ --gridkit-surface-muted: var(--gridkit-surface-muted-dark);
61
+ --gridkit-line: var(--gridkit-line-dark);
62
+ --gridkit-hover-line: var(--gridkit-hover-line-dark);
63
+ --gridkit-fg: var(--gridkit-fg-dark);
64
+ --gridkit-fg-muted: var(--gridkit-fg-muted-dark);
65
+ --gridkit-accent: var(--gridkit-accent-dark);
66
+ --gridkit-selected: var(--gridkit-selected-dark);
67
+ --gridkit-selected-strong: var(--gridkit-selected-strong-dark);
68
+ }
69
+ }
18
70
 
19
- --gridkit-surface: oklch(1 0 0);
20
- --gridkit-surface-muted: oklch(0.97 0.003 250);
21
- --gridkit-line: oklch(0.92 0.005 250);
22
- --gridkit-hover-line: oklch(0.65 0.09 255);
23
- --gridkit-fg: oklch(0.21 0.01 250);
24
- --gridkit-fg-muted: oklch(0.55 0.015 250);
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);
71
+ .gridkit-light {
72
+ color-scheme: light;
73
+ --gridkit-surface: var(--gridkit-surface-light);
74
+ --gridkit-surface-muted: var(--gridkit-surface-muted-light);
75
+ --gridkit-line: var(--gridkit-line-light);
76
+ --gridkit-hover-line: var(--gridkit-hover-line-light);
77
+ --gridkit-fg: var(--gridkit-fg-light);
78
+ --gridkit-fg-muted: var(--gridkit-fg-muted-light);
79
+ --gridkit-accent: var(--gridkit-accent-light);
80
+ --gridkit-selected: var(--gridkit-selected-light);
81
+ --gridkit-selected-strong: var(--gridkit-selected-strong-light);
28
82
  }
29
83
 
30
- .dark {
84
+ .gridkit-dark {
31
85
  color-scheme: dark;
32
-
33
- --gridkit-surface: oklch(0.21 0.01 250);
34
- --gridkit-surface-muted: oklch(0.26 0.012 250);
35
- --gridkit-line: oklch(0.33 0.014 250);
36
- --gridkit-hover-line: oklch(0.75 0.09 255);
37
- --gridkit-fg: oklch(0.97 0.003 250);
38
- --gridkit-fg-muted: oklch(0.7 0.015 250);
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);
86
+ --gridkit-surface: var(--gridkit-surface-dark);
87
+ --gridkit-surface-muted: var(--gridkit-surface-muted-dark);
88
+ --gridkit-line: var(--gridkit-line-dark);
89
+ --gridkit-hover-line: var(--gridkit-hover-line-dark);
90
+ --gridkit-fg: var(--gridkit-fg-dark);
91
+ --gridkit-fg-muted: var(--gridkit-fg-muted-dark);
92
+ --gridkit-accent: var(--gridkit-accent-dark);
93
+ --gridkit-selected: var(--gridkit-selected-dark);
94
+ --gridkit-selected-strong: var(--gridkit-selected-strong-dark);
42
95
  }
43
96
 
44
97
  /*
45
98
  * `inline` is what makes the swap work. Without it Tailwind emits
46
99
  * `--color-surface: var(--gridkit-surface)` on `:root`, which resolves once
47
- * against the light values and is then inherited already-resolved — a `.dark`
48
- * further down the tree would have nothing left to override. `inline`
49
- * substitutes the var into each utility instead, so it resolves at the element
50
- * the class sits on.
100
+ * against the light values and is then inherited already-resolved — a
101
+ * dark-mode switch further down the tree would have nothing left to
102
+ * override. `inline` substitutes the var into each utility instead, so it
103
+ * resolves at the element the class sits on.
51
104
  */
52
105
  @theme inline {
53
106
  --color-surface: var(--gridkit-surface);
@@ -412,6 +465,15 @@
412
465
  border-bottom: 1px solid var(--gridkit-line);
413
466
  }
414
467
 
468
+ /*
469
+ * The last row's bottom edge has no row below it to collapse with, so
470
+ * unlike every internal boundary it is a genuinely extra pixel — the same
471
+ * reason `borders-vertical` drops its `:last-child` border-right below.
472
+ */
473
+ .gridkit-data-grid.borders-horizontal .grid-row:last-child .grid-cell {
474
+ border-bottom: none;
475
+ }
476
+
415
477
  /* Vertical borders */
416
478
  .gridkit-data-grid.borders-vertical .grid-header .header-cell,
417
479
  .gridkit-data-grid.borders-vertical .grid-cell {
@@ -426,7 +488,8 @@
426
488
  /* Borders on all sides */
427
489
  .gridkit-data-grid.borders-all .grid-header .header-cell,
428
490
  .gridkit-data-grid.borders-all .grid-cell {
429
- border: 1px solid var(--gridkit-line);
491
+ border-bottom: 1px solid var(--gridkit-line);
492
+ border-right: 1px solid var(--gridkit-line);
430
493
  }
431
494
 
432
495
  /*
@@ -443,4 +506,8 @@
443
506
  .gridkit-data-grid.borders-all .grid-cell:last-child {
444
507
  border-right: none;
445
508
  }
509
+
510
+ .gridkit-data-grid.borders-all .grid-row:last-child .grid-cell {
511
+ border-bottom: none;
512
+ }
446
513
  }