@alexandregme/zljs 3.21.0 → 3.23.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/CHANGELOG.md +48 -1
- package/README.md +49 -8
- package/dist/{chunk-DM4EKQGH.js → chunk-NHCD5NHZ.js} +393 -225
- package/dist/{chunk-VW4GICIJ.js → chunk-US6IUIXD.js} +2 -2
- package/dist/index.d.ts +83 -11
- package/dist/index.js +39 -29
- package/dist/next/index.js +4 -2
- package/dist/rhf/index.js +1 -1
- package/dist/styles/colors.css +58 -29
- package/dist/styles/scrollbar.css +12 -3
- package/dist/styles/theme.css +17 -0
- package/dist/styles.css +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,51 @@ A change that needs action in an app has a **Migration** note. When updating, re
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [3.23.0] - 2026-11-24
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- A dark theme. With no setup an app follows the theme of the device, and the user can choose another: the choice is kept in the browser and `RootLayout` applies it before the page is drawn, so the page never flashes in the wrong theme
|
|
16
|
+
- `Sidebar` and `TopNav`, and so `Navigation`, show the theme buttons over the share button: the system, the light and the dark theme, with the one in use marked. In a collapsed `Sidebar` the three become one button that goes to the next theme on each click. `theme` takes their texts: `label`, `systemLabel`, `lightLabel` and `darkLabel`, all with English defaults
|
|
17
|
+
- `ThemeToggle`, the buttons `Sidebar` and `TopNav` use, for an app that puts the theme somewhere else, and the type `ThemeToggleProps`. `label` is the accessible name of the group and is required, and `iconOnly` shows the one button
|
|
18
|
+
- `useTheme`, the theme the user chose and the function that changes it, for an app that draws its own control, and `setTheme`, the same function for code outside a component. The types `Theme` (`system`, `light` or `dark`) and `UseTheme` come with them
|
|
19
|
+
- The neutral colors, for the page and what sits on it: `--color-zl-page`, `--color-zl-surface`, `--color-zl-surface-muted`, `--color-zl-surface-hover`, `--color-zl-border`, `--color-zl-border-strong`, `--color-zl-text` and `--color-zl-text-soft`. An app uses them in its own pages (`bg-zl-surface`, `text-zl-text-soft`, `border-zl-border`) so they follow the theme
|
|
20
|
+
- `aria-pressed` on `Button`, for a button that stays on, such as the chosen one of a group. `ghost` draws it with a background
|
|
21
|
+
- `Icon` has the `Monitor`, `Sun` and `Moon` icons
|
|
22
|
+
- Storybook has a theme switch in its toolbar
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- Every `--color-zl-*` value is a `light-dark()` pair: the first color for the light theme and the second for the dark. The light values are the ones the components had, so nothing changes on a device in the light theme. In the dark theme the colors are lighter, `-strong` and `-hover` get lighter instead of darker, and `-on` is near black instead of white
|
|
27
|
+
- The components use the neutral colors where they had fixed grays, so `Card`, `Modal`, `Tabs`, `Disclosure`, `DataGrid`, the toasts, the fields and the neutral `Button` follow the theme. The tints of a colored `Modal` and of a toast are mixed with the surface instead of with white
|
|
28
|
+
- `Sidebar` and `TopNav` follow the theme: a white surface with a line beside the page in the light theme, where they were dark, and a dark one in the dark theme
|
|
29
|
+
- `RootLayout` paints the page: `--color-zl-page` (`gray-50`) behind and `--color-zl-text` (`gray-900`) as the text, where it had no color of its own. It covers a background the app sets on `body`
|
|
30
|
+
- The scrollbar thumb uses the theme colors, so it shows on a light and on a dark page
|
|
31
|
+
- The styles set `color-scheme: light dark` on `:root`, which also turns the scrollbars and the native fields of the browser with the theme
|
|
32
|
+
- The dark theme needs a browser with the CSS `light-dark()` function: Chrome 123, Safari 17.5 and Firefox 120, or newer
|
|
33
|
+
|
|
34
|
+
#### Migration
|
|
35
|
+
|
|
36
|
+
After updating, the app follows the theme of the device, so on a device in the dark theme it is dark. Do one of the two:
|
|
37
|
+
|
|
38
|
+
1. **Keep the app light until its pages are ready.** After the import of the styles, in the app's CSS, add `:root { color-scheme: light; }`. The system theme is then always the light one. The theme buttons still let the user choose the dark one.
|
|
39
|
+
2. **Make the app's own pages follow the theme.**
|
|
40
|
+
- Find the fixed colors: search the app's source for `bg-white`, `bg-gray-`, `bg-slate-`, `bg-neutral-`, `text-gray-`, `text-slate-`, `text-black`, `border-gray-`, `border-slate-`, and for `background-color` and `color:` in its CSS. Replace each with the neutral value of the same role: `bg-zl-page`, `bg-zl-surface`, `bg-zl-surface-muted`, `text-zl-text`, `text-zl-text-soft`, `text-zl-muted`, `border-zl-border` or `border-zl-border-strong`. A color that is the same in both themes on purpose, such as white text on a photo, stays.
|
|
41
|
+
- Remove a `background-color` set on `html` or `body`: `RootLayout` now paints the page. To change the color of the page, set `--color-zl-page` in `@theme`.
|
|
42
|
+
- Find the colors the app redefines: search its CSS for `--color-zl-`. Give each a pair, `light-dark(<light>, <dark>)`, as in `--color-zl-primary: light-dark(#2e7d32, #81c784);`. A single color is used in both themes: one dark enough for text on a light page is too dark on a dark one, and as a button it gets near black text in the dark theme. Check the pair against the minimums in the `Foundations/Colors` page of the Storybook.
|
|
43
|
+
|
|
44
|
+
An app in another language passes the texts of the theme buttons: `theme={{ label: "Tema", systemLabel: "Sistema", lightLabel: "Claro", darkLabel: "Escuro" }}` on `Navigation`, `Sidebar` or `TopNav`. What stays: the names of the existing values, the classes of the components and their props.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- `Checkbox` draws keyboard focus with an outline in the `primary` color, as `Radio` does. It had a ring in a fixed blue, which an app with its own `primary` didn't change and forced colors mode dropped
|
|
49
|
+
|
|
50
|
+
## [3.22.0] - 2026-11-24
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
|
|
54
|
+
- `Icon` has the `SiSupabase` icon
|
|
55
|
+
|
|
11
56
|
## [3.21.0] - 2026-11-21
|
|
12
57
|
|
|
13
58
|
### Added
|
|
@@ -617,7 +662,9 @@ Replace the shade with the class of the `color` being tested, for example `/(^|\
|
|
|
617
662
|
|
|
618
663
|
The message of `Error` is `text-zl-danger`. `none` and `ghost` didn't change.
|
|
619
664
|
|
|
620
|
-
[Unreleased]: https://github.com/alexandregme/zljs/compare/v3.
|
|
665
|
+
[Unreleased]: https://github.com/alexandregme/zljs/compare/v3.23.0...HEAD
|
|
666
|
+
[3.23.0]: https://github.com/alexandregme/zljs/compare/v3.22.0...v3.23.0
|
|
667
|
+
[3.22.0]: https://github.com/alexandregme/zljs/compare/v3.21.0...v3.22.0
|
|
621
668
|
[3.21.0]: https://github.com/alexandregme/zljs/compare/v3.20.0...v3.21.0
|
|
622
669
|
[3.20.0]: https://github.com/alexandregme/zljs/compare/v3.19.0...v3.20.0
|
|
623
670
|
[3.19.0]: https://github.com/alexandregme/zljs/compare/v3.18.0...v3.19.0
|
package/README.md
CHANGED
|
@@ -69,22 +69,63 @@ The components work with no setup, using the default colors. To use your own, re
|
|
|
69
69
|
@import "@alexandregme/zljs/styles.css";
|
|
70
70
|
|
|
71
71
|
@theme {
|
|
72
|
-
--color-zl-primary: #2e7d32;
|
|
72
|
+
--color-zl-primary: light-dark(#2e7d32, #81c784);
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
Every value is a `light-dark()` pair: the first color is used in the light theme and the second in the dark one. A single color is used in both, and one dark enough for text on a light page is too dark on a dark one, so give a pair.
|
|
77
|
+
|
|
76
78
|
`primary`, `success`, `danger`, `warning`, `info` and `muted` each take one value (`--color-zl-<color>`), used for text and the focus outline. The others follow it, and you can redefine them too:
|
|
77
79
|
|
|
78
|
-
| Value | Used for | Default
|
|
79
|
-
| --------------------------- | ----------------------- |
|
|
80
|
-
| `--color-zl-<color>-strong` | Link hover and Tag text | 30% darker
|
|
81
|
-
| `--color-zl-<color>-bg` | Button background | The color itself (`warning`: `yellow-500`)
|
|
82
|
-
| `--color-zl-<color>-hover` | Button hover | The background, 15%
|
|
83
|
-
| `--color-zl-<color>-on` | Text on the background | White (`warning`: `gray-900`)
|
|
80
|
+
| Value | Used for | Default |
|
|
81
|
+
| --------------------------- | ----------------------- | ------------------------------------------------------------------------- |
|
|
82
|
+
| `--color-zl-<color>-strong` | Link hover and Tag text | 30% further from the page: darker in the light theme, lighter in the dark |
|
|
83
|
+
| `--color-zl-<color>-bg` | Button background | The color itself (`warning`: `yellow-500`) |
|
|
84
|
+
| `--color-zl-<color>-hover` | Button hover | The background, 15% further from the page |
|
|
85
|
+
| `--color-zl-<color>-on` | Text on the background | White, and near black in the dark theme (`warning`: `gray-900`) |
|
|
84
86
|
|
|
85
87
|
A `Tag` also takes the auxiliary colors `orange`, `pink` and `purple`, which have no meaning of their own: use them to tell categories apart. Each has only `--color-zl-<color>` and `--color-zl-<color>-strong`. The first, at 15%, is the `Tag` background, and the second is its text.
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
The neutral values are the page and what sits on it. Use them in your own pages (`bg-zl-surface`, `text-zl-text-soft`, `border-zl-border`), so they follow the theme too:
|
|
90
|
+
|
|
91
|
+
| Value | Used for | Light / dark |
|
|
92
|
+
| -------------------------- | ------------------------------------------------------ | -------------------------- |
|
|
93
|
+
| `--color-zl-page` | The page, behind everything. `RootLayout` paints it | `gray-50` / `neutral-950` |
|
|
94
|
+
| `--color-zl-surface` | What sits on the page: card, modal, field | White / `neutral-900` |
|
|
95
|
+
| `--color-zl-surface-muted` | A surface that recedes: disabled field, neutral button | `gray-100` / `neutral-800` |
|
|
96
|
+
| `--color-zl-surface-hover` | Hover of the neutral button | `gray-200` / `neutral-700` |
|
|
97
|
+
| `--color-zl-border` | A line between surfaces | `gray-200` / `neutral-700` |
|
|
98
|
+
| `--color-zl-border-strong` | The border of a field | `gray-500` / `neutral-400` |
|
|
99
|
+
| `--color-zl-text` | Text | `gray-900` / `neutral-100` |
|
|
100
|
+
| `--color-zl-text-soft` | A label or a description | `gray-700` / `neutral-300` |
|
|
101
|
+
|
|
102
|
+
Only the defaults are checked for contrast. Check your own choice, in both themes: 4.5:1 for text, on `--color-zl-<color>` against the page and on `-on` against `-bg`, and 3:1 for the focus outline. A value set on a nested element doesn't reach the values derived from it, so set them in `@theme` or `:root`.
|
|
103
|
+
|
|
104
|
+
## Themes
|
|
105
|
+
|
|
106
|
+
The components have a light and a dark theme. With no setup an app follows the theme of the device, and the user changes it in the navigation: `Sidebar` and `TopNav` show a `ThemeToggle` over the share button, with the system, the light and the dark theme. The choice is kept in the browser (`localStorage`, under `zljs-theme`), and `RootLayout` applies it before the page is drawn.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { ThemeToggle, useTheme } from "@alexandregme/zljs";
|
|
110
|
+
|
|
111
|
+
<ThemeToggle label="Theme" />;
|
|
112
|
+
|
|
113
|
+
// Or your own control:
|
|
114
|
+
const { theme, setTheme } = useTheme(); // "system" | "light" | "dark"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
An app whose own pages aren't ready for the dark theme keeps the system theme light, and the user can still choose the dark one:
|
|
118
|
+
|
|
119
|
+
```css
|
|
120
|
+
@import "tailwindcss";
|
|
121
|
+
@import "@alexandregme/zljs/styles.css";
|
|
122
|
+
|
|
123
|
+
:root {
|
|
124
|
+
color-scheme: light;
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The themes use the CSS `light-dark()` function: Chrome 123, Safari 17.5 and Firefox 120, or newer.
|
|
88
129
|
|
|
89
130
|
## Updating
|
|
90
131
|
|