@venix-sistemas/jade 1.0.1 β†’ 1.2.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 (57) hide show
  1. package/README.md +350 -254
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +32 -35
  4. package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +1 -1
  5. package/dist/runtime/components/VenixThemeSwitcher.vue +242 -99
  6. package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +1 -1
  7. package/dist/runtime/composables/useThemeColors.d.ts +6 -0
  8. package/dist/runtime/composables/useThemeColors.js +24 -9
  9. package/dist/runtime/composables/useThemeCookies.d.ts +9 -2
  10. package/dist/runtime/composables/useThemeCookies.js +24 -6
  11. package/dist/runtime/composables/useThemeLocale.d.ts +5 -0
  12. package/dist/runtime/composables/useThemeLocale.js +12 -18
  13. package/dist/runtime/composables/useThemeSeasonal.d.ts +2 -2
  14. package/dist/runtime/composables/useThemeSeasonal.js +1 -1
  15. package/dist/runtime/composables/useVenixTheme.d.ts +20 -0
  16. package/dist/runtime/composables/useVenixTheme.js +174 -112
  17. package/dist/runtime/nitro/theme-init.js +8 -5
  18. package/dist/runtime/plugins/theme-init.server.js +7 -12
  19. package/dist/runtime/plugins/vuetify-theme.js +8 -11
  20. package/dist/runtime/scripts/theme-init.d.ts +23 -10
  21. package/dist/runtime/scripts/theme-init.js +42 -62
  22. package/dist/shared/constants.d.ts +18 -3
  23. package/dist/shared/constants.js +6 -1
  24. package/dist/shared/css/colors.js +2 -2
  25. package/dist/shared/css/cursor.js +9 -2
  26. package/dist/shared/css/index.d.ts +1 -7
  27. package/dist/shared/css/index.js +9 -9
  28. package/dist/shared/css/transition.d.ts +1 -1
  29. package/dist/shared/theme.json +302 -192
  30. package/dist/shared/types/color-options.d.ts +26 -2
  31. package/dist/shared/types/colors.d.ts +64 -7
  32. package/dist/shared/types/index.d.ts +1 -1
  33. package/dist/shared/types/runtime-config.d.ts +4 -2
  34. package/dist/shared/utils/icon-refs.d.ts +7 -3
  35. package/dist/shared/utils/icon-refs.js +1 -1
  36. package/dist/shared/utils/icon.d.ts +6 -2
  37. package/dist/shared/utils/icon.js +8 -3
  38. package/dist/shared/utils/index.d.ts +5 -3
  39. package/dist/shared/utils/index.js +12 -5
  40. package/dist/shared/utils/inline-script.d.ts +6 -0
  41. package/dist/shared/utils/inline-script.js +3 -0
  42. package/dist/shared/utils/load.d.ts +0 -1
  43. package/dist/shared/utils/load.js +7 -16
  44. package/dist/shared/utils/merge-themes.d.ts +41 -0
  45. package/dist/shared/utils/merge-themes.js +106 -0
  46. package/dist/shared/utils/normalize.d.ts +0 -10
  47. package/dist/shared/utils/normalize.js +0 -12
  48. package/dist/shared/utils/theme-config.d.ts +13 -4
  49. package/dist/shared/utils/theme-config.js +28 -13
  50. package/dist/shared/utils/theme-resolve.d.ts +19 -19
  51. package/dist/shared/utils/theme-resolve.js +25 -42
  52. package/dist/shared/utils/theme-resolver.d.ts +46 -0
  53. package/dist/shared/utils/theme-resolver.js +139 -0
  54. package/package.json +13 -10
  55. package/README-default.md +0 -84
  56. package/dist/runtime/plugin.d.ts +0 -2
  57. package/dist/runtime/plugin.js +0 -3
package/README.md CHANGED
@@ -13,7 +13,14 @@
13
13
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
14
14
  </p>
15
15
 
16
- A complete centralized theming system for Nuxt applications: colors, typography, cursor, scrollbar, internationalization and seasonal themes, with UnoCSS, Vuetify and Iconify integrations.
16
+ <p align="center">
17
+ The UI foundation for Nuxt applications, in a single module: color themes (including seasonal ones),<br>
18
+ typography, scrollbar, cursor, icons and interface translations, with UnoCSS and Vuetify integrations.
19
+ </p>
20
+
21
+ <p align="center">
22
+ <img src="./docs/images/readme/theme-switcher.webp" alt="VenixThemeSwitcher going through the dark themes (Carnival, Easter, Christmas, Halloween, Ocean), then light mode and back" width="800">
23
+ </p>
17
24
 
18
25
  ## Features
19
26
 
@@ -21,7 +28,8 @@ A complete centralized theming system for Nuxt applications: colors, typography,
21
28
  * πŸ–±οΈ **Cursor customization**
22
29
  * πŸ“œ **Scrollbar customization**
23
30
  * 🎨 **Color customization**, with dark and light themes included
24
- * πŸ–₯️ **System theme preference detection**, including seasonal overrides
31
+ * πŸŒ— **Theme and mode picked separately**: any theme (Venix Sistemas, Carnival, Christmas…) in light or dark, each following the system or fixed
32
+ * πŸ–₯️ **System preference detection**, including seasonal themes by date
25
33
  * πŸŽƒ **Seasonal themes**: Carnival, Halloween, Christmas and more
26
34
  * πŸ’Ύ **Cookie-consent-aware persistence**: nothing is written until the user opts in
27
35
  * 🌐 **i18n**: internationalization and locale detection for theme names and your own strings
@@ -32,25 +40,18 @@ A complete centralized theming system for Nuxt applications: colors, typography,
32
40
 
33
41
  ## Installation
34
42
 
35
- Install the package using your preferred package manager:
36
-
37
- ```bash
38
- npm install @venix-sistemas/jade
39
- ```
40
-
41
- Or with pnpm:
42
-
43
43
  ```bash
44
44
  pnpm add @venix-sistemas/jade
45
+ # or
46
+ npm install @venix-sistemas/jade
45
47
  ```
46
48
 
47
49
  ## Quick Setup
48
50
 
49
51
  ### 1. Add the module
50
52
 
51
- Add `@venix-sistemas/jade` to the `modules` section of your `nuxt.config.ts`:
52
-
53
53
  ```typescript
54
+ // nuxt.config.ts
54
55
  export default defineNuxtConfig({
55
56
  modules: ['@venix-sistemas/jade'],
56
57
 
@@ -66,110 +67,234 @@ export default defineNuxtConfig({
66
67
  })
67
68
  ```
68
69
 
69
- Translation, color, scrollbar, cursor and typography are all on by default with sensible built-in values β€” the example above only overrides what it needs to. See [Configuration](#configuration) for the full reference.
70
+ Every module except Vuetify is on by default with built-in values, so you only configure what you want to change β€” the example above just swaps the dark theme's primary color. See [Modules](#modules) for what each one does.
70
71
 
71
72
  ### 2. Use the theme
72
73
 
73
- You can access the theme utilities directly from your components via the auto-imported `useVenixTheme()` composable (named this way, rather than `useTheme`, to avoid colliding with the composable UI libraries like Vuetify auto-import under that same name):
74
+ The auto-imported `useVenixTheme()` composable gives access to the theme. It isn't called `useTheme` to avoid colliding with UI libraries (like Vuetify) that auto-import a composable with that name.
75
+
76
+ The **theme** (Venix Sistemas, Carnival, Christmas…) and the **mode** (light or dark) are chosen independently; the applied colors are the theme's variant for that mode. Either can be `'system'`: an automatic theme follows the calendar ([seasonal themes](#seasonal-themes)), an automatic mode follows the OS.
74
77
 
75
78
  ```vue
76
79
  <template>
77
- <div>
78
- <button @click="theme.toggle('dark')">
79
- Dark
80
- </button>
81
-
82
- <button @click="theme.toggle('light')">
83
- Light
84
- </button>
85
- </div>
80
+ <button @click="mode.set('dark')">Dark</button>
81
+ <button @click="mode.set('light')">Light</button>
82
+ <button @click="theme.set('natal')">Christmas</button>
86
83
  </template>
87
84
 
88
85
  <script setup lang="ts">
89
- const { theme } = useVenixTheme()
86
+ const { theme, mode } = useVenixTheme()
90
87
  </script>
91
88
  ```
92
89
 
93
- `useVenixTheme()` returns four grouped values:
90
+ It returns:
94
91
 
95
- - `theme` β€” current state and controls: `value` (resolved theme), `preference` (user's raw choice, including `'system'`), `data` (the active theme's `{ value, name, icon }`), `toggle(name?)`, `isSeasonalActive`, `activeSeasonalTheme`, `shouldApplyColors`, `colors` (the raw theme config).
96
- - `themes` β€” the full list of selectable themes, ready to render a picker (see [Theme icons](#theme-icons)).
97
- - `locale` β€” `{ current, set }` for the module's i18n state.
98
- - `persistence` β€” cookie-consent gating for the theme cookies (see [Cookie Consent](#cookie-consent)): `hasConsent`, `grant()`, `revoke()`, plus the lower-level `enable()`/`disable()`.
92
+ - `theme` β€” the theme choice:
93
+ - `preference`: the chosen theme (`'system'`, `'venix'`, `'carnaval'`…)
94
+ - `value`: the variant actually applied, as in `data-theme` (e.g. `'natal-light'`, or `'dark'` for Venix Sistemas in dark mode)
95
+ - `data`: the chosen theme's `{ value, name, icon }`
96
+ - `set(name)`: picks a theme, keeping the mode
97
+ - `toggle(name?)`: kept for compatibility β€” without a name switches the mode; `'dark'`/`'light'` select Venix Sistemas in that mode; `'system'` makes both theme and mode automatic
98
+ - `isSeasonalActive`, `activeSeasonalTheme`: whether a [seasonal theme](#seasonal-themes) is currently in effect, and which one
99
+ - `shouldApplyColors`, `colors`: whether the module applies colors, and the resolved color config
100
+ - `themes` β€” every selectable theme as `{ value, name, icon, custom }`, ready to render a picker (see [Theme icons](#theme-icons)); `custom` is `true` for themes your project added in `color.themes`.
101
+ - `mode` β€” the mode choice: `preference` (`'system'`, `'light'`, `'dark'`), `value` (the mode applied, `'light'` or `'dark'`), `data`, `set(mode)` and `toggle()`.
102
+ - `modes` β€” the three mode options with names and icons, ready to render.
103
+ - `locale` β€” `current`, `set()` and `translate()` (see [Translation](#translation)).
104
+ - `persistence` β€” cookie consent controls (see [Saving the theme](#saving-the-theme-cookie-consent)).
99
105
 
100
- `useVenixTheme()`'s preference is shared app-wide (via Nuxt's `useState`) β€” calling it from multiple components (e.g. your own page and `<VenixThemeSwitcher>` below) always reads/writes the same active theme, they never go out of sync.
106
+ The state is shared app-wide (via Nuxt's `useState`): every component calling `useVenixTheme()` reads and writes the same theme, so they never go out of sync.
101
107
 
102
108
  ### 3. Ready-made component
103
109
 
104
- `<VenixThemeSwitcher>` is an auto-imported, framework-agnostic (no Vuetify/UI-kit dependency) dropdown for picking a color theme, using `<VenixIcon>` internally for each theme's icon:
110
+ `<VenixThemeSwitcher>` is an auto-imported dropdown with a **Mode** section (Automatic, Dark, Light) and a **Theme** section (Automatic, Venix Sistemas and the seasonal themes), followed, below a divider, by the themes your project adds itself. It has no dependency on Vuetify or any other UI kit:
111
+
112
+ <p align="center">
113
+ <picture>
114
+ <source media="(prefers-color-scheme: light)" srcset="./docs/images/readme/switcher-light.png">
115
+ <img src="./docs/images/readme/switcher-dark.png" alt="VenixThemeSwitcher open next to the page: Mode, Theme and Custom theme sections" width="800">
116
+ </picture>
117
+ </p>
105
118
 
106
119
  ```vue
107
120
  <template>
108
- <VenixThemeSwitcher label="Color theme" />
121
+ <VenixThemeSwitcher label="Website color" />
109
122
  </template>
110
123
  ```
111
124
 
112
- Props:
125
+ | Prop | Type | Default | Description |
126
+ | ----------- | --------- | ----------------------- | --------------------------------------------------- |
127
+ | `label` | `string` | translated, per locale | Accessible label for the button and the menu |
128
+ | `showLabel` | `boolean` | `false` | Show the theme and mode names next to the icon |
129
+
130
+ - **Accessible:** arrow keys, Home/End and Esc navigate the menu, focus returns to the button on close, and each change is announced to screen readers.
131
+ - **Always legible:** the menu uses fixed neutral colors (dark surface, light text) instead of the active theme's, so every option stays readable whatever theme is applied. The button itself follows the active theme.
132
+ - **Lively:** animated icons (e.g. `line-md`) replay on every switch, and the button fades in on mount. The button shows the mode's icon on the base theme, and the theme's own icon when a seasonal or other theme is in effect.
133
+ - **Quick:** picking a mode keeps the menu open, so mode and theme can be set in one go; picking a theme closes it.
134
+
135
+ It ships with minimal CSS of its own. To restyle it, target `.venix-theme-switcher`, `.venix-theme-switcher__trigger`, `.venix-theme-switcher__menu`, `.venix-theme-switcher__subheading` and `.venix-theme-switcher__item` (`--mode` for the mode buttons) (see [`VenixThemeSwitcher.vue`](./src/runtime/components/VenixThemeSwitcher.vue)).
136
+
137
+ ## Modules
138
+
139
+ Jade is a set of independent modules, each configured under its own key in `venixTheme`. Every key accepts `false` (disable), `true` (enable with defaults) or an object (enable and customize):
140
+
141
+ | Module | Key | Default | What it does |
142
+ | --------------------------- | ------------- | ------- | --------------------------------------------------------------------- |
143
+ | [Colors](#colors) | `color` | `true` | Color themes (built-in, seasonal, custom) in light and dark mode, saved per user, as CSS variables and a UnoCSS preset |
144
+ | [Translation](#translation) | `translation` | `true` | Detects the user's locale and translates theme names and your own strings |
145
+ | [Icons](#icons) | `icon` | `true` | `<VenixIcon>`: emoji, Iconify (bundled offline) or inline SVG through one component |
146
+ | [Typography](#typography) | `typography` | `true` | Base font family, font size and `@font-face` rules |
147
+ | [Scrollbar](#scrollbar) | `scrollbar` | `true` | A custom scrollbar that follows the active theme |
148
+ | [Cursor](#cursor) | `cursor` | `true` | Custom cursor images |
149
+ | [Vuetify](#vuetify) | `vuetify` | `false` | Registers the color themes with Vuetify and keeps it in sync |
150
+
151
+ ## Colors
152
+
153
+ Every theme has a light and a dark palette, exposed as CSS variables (`--color-primary`, `--color-background2`…):
154
+
155
+ <p align="center">
156
+ <img src="./docs/images/readme/palettes.png" alt="Color palettes: Venix Sistemas dark and light, Halloween dark, Christmas light" width="800">
157
+ </p>
158
+
159
+ | Option | Type | Default | Description |
160
+ | ---------------- | --------------------------- | -------- | ------------------------------------------------------------- |
161
+ | `apply` | `boolean` | `true` | Apply the resolved theme to `<html>` (`data-theme` and class) |
162
+ | `defaultColor` | `string` | `'dark'` | Initial choice with no saved preference: a theme (mode follows the OS), a variant id like `'dark'` (that theme in that mode) or `'system'` |
163
+ | `themes` | `object` | `{}` | Override or add themes β€” see [Themes](#themes) |
164
+ | `iconFormat` | `'emote' \| 'css' \| 'svg'` | `'svg'` | Preferred theme icon variant β€” see [Theme icons](#theme-icons) |
165
+ | `requireConsent` | `boolean` | `true` | Only save the chosen theme after cookie consent β€” see [Saving the theme](#saving-the-theme-cookie-consent) |
166
+ | `seasonal` | `boolean` | `true` | Seasonal themes β€” `false` removes them entirely, see [Seasonal themes](#seasonal-themes) |
167
+
168
+ ### Themes
169
+
170
+ Each theme has a `light` and a `dark` variant, plus a name (`translations`) and an `icon` shared by both. The module ships with **Venix Sistemas** (`venix`) and the [seasonal themes](#seasonal-themes), all in both modes. `color.themes` extends that set:
171
+
172
+ - An **existing** name overrides only the properties you set; the rest of the theme (the other variant, other colors, translations, icon) stays as shipped.
173
+ - A **new** name adds a theme that works like a built-in one: its own CSS variables, an entry in `useVenixTheme().themes` (so it appears in `<VenixThemeSwitcher>`), and UnoCSS/Vuetify support when enabled. A theme with only one variant uses it in both modes.
174
+
175
+ ```typescript
176
+ color: {
177
+ themes: {
178
+ // Overrides only `primary` of the built-in theme in dark mode
179
+ venix: {
180
+ dark: { primary: '#FF6B6B' },
181
+ },
182
+
183
+ // Adds a project-specific theme
184
+ summerSale: {
185
+ translations: { 'en-US': 'Summer sale', 'pt-BR': 'LiquidaΓ§Γ£o de verΓ£o' },
186
+ icon: 'πŸ–οΈ',
187
+ light: { primary: '#FF8A00', background: '#FFF8EE' },
188
+ dark: { primary: '#FFB04C', background: '#1A1206' },
189
+ },
190
+ },
191
+ }
192
+ ```
193
+
194
+ Available colors: `primary`, `secondary`, `accent`, `error`, `info`, `success`, `warning`, `background`, `background2`, `background3`. Each becomes a `--color-<name>` CSS variable, plus `--color-inverse` (white on dark variants, black on light ones).
195
+
196
+ Each variant is applied as `<html data-theme="<id>">`, and the id is also its Vuetify theme name. It defaults to `<theme>-<mode>` (`summerSale-light`); set `id` on a variant to choose it. The built-in themes keep the ids they had before light/dark became separate: `dark` and `light` for Venix Sistemas, `carnaval`, `natal` and `halloween` for the dark seasonal variants (their light ones are `carnaval-light` and so on). Easter, added later, uses the default `pascoa-light` and `pascoa-dark`.
113
197
 
114
- | Prop | Type | Default | Description |
115
- | ----------- | --------- | ------------------------------ | -------------------------------------------------------------- |
116
- | `label` | `string` | auto (translated, see below) | Accessible label for the trigger button and the menu heading |
117
- | `showLabel` | `boolean` | `false` | Also show the active theme's name next to the icon on the button |
198
+ #### Flat format (deprecated)
118
199
 
119
- Without a `label`, it picks one of its own built-in translations based on the resolved locale (same detection as theme-name translations β€” see [Internationalization](#internationalization)), so it isn't stuck in a single hardcoded language.
200
+ Before themes had two variants, each one was a single flat set of colors with a `dark` flag (`summerSale: { dark: false, primary: '#FF8A00' }`), and built-in themes were overridden by variant name (`dark: { primary: '#FF6B6B' }`). Both still work: a flat theme becomes a theme with only that variant (same `data-theme` id as before), and an override by variant name lands on that variant. Each one logs a `[jade]` warning at build time pointing at the new format; the flat format will be removed in 2.0.
120
201
 
121
- A few behaviors worth knowing about:
202
+ ### Seasonal themes
122
203
 
123
- - The trigger's icon key changes on every theme switch, forcing it to remount β€” so animated icons (Iconify `line-md`, etc.) replay their animation each time instead of staying frozen mid-frame.
124
- - The trigger fades in from `opacity: 0` on mount rather than popping in.
125
- - The dropdown's item names and icons use fixed, hardcoded neutral colors (a dark surface with light text) instead of the active theme's `--color-*` variables β€” on purpose, so the list of themes stays equally legible no matter which theme is currently applied. The trigger button itself is unaffected and still uses the active theme's colors.
126
- - Selecting a theme announces the change to screen readers via a visually-hidden live region, and keyboard users get arrow-key/Home/End navigation between items (`role="menu"` + `role="menuitemradio"`), with focus returning to the trigger on close.
204
+ Built in: 🎭 Carnival, 🐰 Easter, πŸŽƒ Halloween and πŸŽ„ Christmas, each in light and dark. While the theme is `'system'` (Automatic) and today is inside a seasonal theme's `dateRange`, it replaces the base theme, in the variant matching the mode. Seasonal themes can also be picked directly, any day.
127
205
 
128
- It ships with minimal, self-contained CSS, so it looks reasonable out of the box in any project β€” style it further with `.venix-theme-switcher`, `.venix-theme-switcher__trigger`, `.venix-theme-switcher__menu` and `.venix-theme-switcher__item` (see [`VenixThemeSwitcher.vue`](./src/runtime/components/VenixThemeSwitcher.vue)).
206
+ Add your own with `seasonal: true` and a `dateRange`. The range is inclusive and wraps across the new year when `end` comes before `start`. Each bound is a fixed `MM-DD` date or, for movable holidays, a number of days relative to Easter Sunday (`easter`, `easter-47`, `easter+1`):
207
+
208
+ ```typescript
209
+ color: {
210
+ themes: {
211
+ blackFriday: {
212
+ seasonal: true,
213
+ dateRange: { start: '11-24', end: '11-30' },
214
+ dark: { primary: '#FFD400', background: '#000000' },
215
+ light: { primary: '#111111', background: '#FFF8D6' },
216
+ },
217
+ corpusChristi: {
218
+ seasonal: true,
219
+ dateRange: { start: 'easter+60', end: 'easter+60' }, // a single day, every year
220
+ light: { primary: '#B8860B', background: '#FFFBEF' },
221
+ dark: { primary: '#F2C94C', background: '#17130A' },
222
+ },
223
+ },
224
+ }
225
+ ```
226
+
227
+ A seasonal theme with a single variant only takes over automatically when the mode matches it.
228
+
229
+ To turn seasonal themes off, set `color.seasonal: false`. All of them, built-in and custom, are removed: they get no CSS, aren't listed in pickers and never take over by date. "Automatic" then always means the base theme, so it's left out of the theme list too.
230
+
231
+ The built-in Carnival theme uses `easter-65` to `easter-46`: 20 days, from the pre-Carnival weeks up to Ash Wednesday. Easter uses `easter-7` to `easter+1`: from Palm Sunday to Easter Monday.
129
232
 
130
233
  ### Theme transition
131
234
 
132
- Switching themes (via `theme.toggle()`, the switcher above, or a system/seasonal auto-change) is animated with the browser's native [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) β€” a soft cross-fade between the old and new appearance, no extra setup needed. It falls back to an instant swap on browsers without support, and is skipped automatically when the user has `prefers-reduced-motion: reduce` set.
235
+ Every theme switch β€” manual, through the switcher, or an automatic system/seasonal change β€” cross-fades using the browser's native [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API), with no setup. Browsers without support switch instantly, and the animation is skipped for users with `prefers-reduced-motion: reduce`.
133
236
 
134
- ## Configuration
237
+ ### Saving the theme (cookie consent)
135
238
 
136
- ### Module Options
239
+ Three cookies remember the user's choice between visits, for a year:
137
240
 
138
- Every feature (`translation`, `color`, `scrollbar`, `cursor`, `typography`) is configured through a single key that accepts either a `boolean` (quick enable/disable) or a config object (which also enables the feature):
241
+ | Cookie | Stores |
242
+ | ------------------------ | ------------------------------------------------------------------------------------------------------- |
243
+ | `venix-theme-preference` | The chosen theme (`'system'`, `'venix'`, a custom theme…) |
244
+ | `venix-theme-mode` | The chosen mode (`'system'`, `'light'`, `'dark'`) |
245
+ | `venix-theme-resolved` | The variant last applied (e.g. `'natal-light'`) β€” lets SSR guess light or dark when the mode is `'system'` |
139
246
 
140
- | Option | Type | Default | Description |
141
- | ------------- | -------------------- | ------- | ----------------------------------------------- |
142
- | `translation` | `boolean \| object` | `true` | Enable or configure locale detection/i18n |
143
- | `color` | `boolean \| object` | `true` | Enable or configure the color system |
144
- | `scrollbar` | `boolean \| object` | `true` | Enable or configure the custom scrollbar |
145
- | `cursor` | `boolean \| object` | `true` | Enable or configure the custom cursor |
146
- | `typography` | `boolean \| object` | `true` | Enable or configure typography |
147
- | `vuetify` | `boolean \| object` | `false` | Auto-configure Vuetify's theme with the theme colors |
148
- | `icon` | `boolean \| object` | `true` | Install and configure `@nuxt/icon`, register `<VenixIcon>` / `useVenixIcon` |
247
+ The theme itself is always recomputed from the first two (with `'system'`, by today's date and the OS color scheme), so a saved seasonal theme never outlives its season.
149
248
 
150
- #### `translation` object
249
+ Choices saved before theme and mode were separate (e.g. a theme cookie of `'dark'`) are read as the equivalent theme and mode, so users keep their theme.
151
250
 
152
- | Property | Type | Default | Description |
153
- | -------------- | --------- | -------------------- | -------------------------------------------------- |
154
- | `locale` | `string` | β€” | Force a specific locale |
155
- | `defaultLocale`| `string` | `'en-US'` | Default fallback locale |
156
- | `cookieSync` | `string` | `'i18n_redirected'` | Cookie used to persist/sync the selected locale |
157
- | `manageHtmlLang` | `boolean` | `false` | Keep `<html lang>` in sync with the resolved locale (see [Internationalization](#internationalization)) |
251
+ By default, none of them is written without consent. Switching themes always works; without consent it just isn't remembered on the next visit. In development, the first unsaved theme change logs a `[jade]` warning in the console, so a missing consent setup doesn't go unnoticed.
252
+
253
+ Consent is read from `localStorage['venix-cookie-consent']`, a JSON object with a `functionality: boolean` field β€” the "functional cookies" category most consent banners already use. The module never writes this key by itself. For a minimal banner, use the built-in helpers:
254
+
255
+ ```vue
256
+ <script setup lang="ts">
257
+ const { persistence } = useVenixTheme()
258
+ </script>
158
259
 
159
- Setting `translation: false` fully disables locale detection and stops `locale.set()` from ever writing to the locale cookie β€” theme names and `<VenixThemeSwitcher>`'s own strings always render in `defaultLocale` instead. Useful if you don't need theme-name translations at all and want this module to leave locale-related state alone entirely, not just because another module also reads that cookie (reading it is harmless either way β€” this module only ever writes to it through `locale.set()`, which nothing calls automatically).
260
+ <template>
261
+ <p>Cookies: {{ persistence.hasConsent.value ? 'allowed' : 'not allowed' }}</p>
262
+ <button @click="persistence.grant()">Allow cookies</button>
263
+ <button @click="persistence.revoke()">Revoke cookies</button>
264
+ </template>
265
+ ```
160
266
 
161
- #### `color` object
267
+ - `persistence.hasConsent` β€” reactive `Ref<boolean>`, shared app-wide.
268
+ - `persistence.grant()` β€” records consent and saves the current theme to the cookies right away.
269
+ - `persistence.revoke()` β€” records the refusal and deletes the theme cookies right away.
270
+ - `persistence.enable()` / `persistence.disable()` β€” lower-level: write or delete the cookies directly (`enable()` still does nothing without consent).
162
271
 
163
- | Property | Type | Default | Description |
164
- | ------------- | --------- | -------- | ----------------------------------------------------- |
165
- | `apply` | `boolean` | `true` | Automatically apply the resolved theme (`data-theme`) |
166
- | `defaultColor`| `string` | `'dark'` | Name of the theme used when no preference is set |
167
- | `themes` | `object` | `{}` | Override or add custom color themes |
168
- | `iconFormat` | `'emote' \| 'css' \| 'svg'` | `'svg'` | Preferred variant for themes with an `icon` object β€” see [Theme icons](#theme-icons) |
272
+ If you already have a consent banner or CMP, have it write the same key and then dispatch `venix-cookie-preferences-updated` on `window`, so the module re-syncs immediately:
169
273
 
170
- ## UnoCSS integration
274
+ ```ts
275
+ localStorage.setItem('venix-cookie-consent', JSON.stringify({ functionality: true }))
276
+ window.dispatchEvent(new Event('venix-cookie-preferences-updated'))
277
+ ```
171
278
 
172
- `jade` ships a UnoCSS preset that exposes the theme's color variables under `theme.colors` β€” add it to your own `uno.config.ts`:
279
+ For apps without a consent banner β€” e.g. an internal tool β€” turn the requirement off, and the theme is always saved:
280
+
281
+ ```typescript
282
+ venixTheme: {
283
+ color: {
284
+ requireConsent: false,
285
+ },
286
+ }
287
+ ```
288
+
289
+ Consent is then ignored for the theme cookies and for the locale cookie written by `locale.set()` (see [Translation](#translation)): `persistence.revoke()` no longer deletes them. Whether that's acceptable is a decision for each app.
290
+
291
+ ### Content-Security-Policy
292
+
293
+ To avoid a wrong-theme flash, a small inline script in `<head>` applies the theme before the page renders. Under a strict CSP that blocks inline scripts, it needs the request's nonce: with [`nuxt-security`](https://nuxt-security.vercel.app) and nonces enabled, the module adds it automatically (from `event.context.security.nonce`).
294
+
295
+ ### UnoCSS preset
296
+
297
+ Add the preset to your `uno.config.ts` to use the theme colors as utilities (`text-primary`, `bg-background2`, `border-accent`, …):
173
298
 
174
299
  ```typescript
175
300
  // uno.config.ts
@@ -184,75 +309,98 @@ export default defineConfig({
184
309
  })
185
310
  ```
186
311
 
187
- `venixUnoPreset()` is equivalent to writing this yourself:
312
+ It maps every [theme color](#themes), plus `inverse`, to its CSS variable (`primary: 'var(--color-primary)'`, …), so utilities follow the active theme. Colors you define yourself in `uno.config.ts` take precedence.
188
313
 
189
- ```typescript
190
- theme: {
191
- colors: {
192
- primary: 'var(--color-primary)',
193
- secondary: 'var(--color-secondary)',
194
- accent: 'var(--color-accent)',
195
- error: 'var(--color-error)',
196
- info: 'var(--color-info)',
197
- success: 'var(--color-success)',
198
- warning: 'var(--color-warning)',
199
- background: 'var(--color-background)',
200
- background2: 'var(--color-background2)',
201
- background3: 'var(--color-background3)',
202
- inverse: 'var(--color-inverse)',
203
- },
204
- }
205
- ```
314
+ The preset has to be added by hand: `@unocss/nuxt` re-reads `uno.config.ts` from disk and discards a `theme` injected by other modules whenever your file declares its own `theme` key. As a preset in your own file, the colors survive that.
206
315
 
207
- This means utilities like `text-primary`, `bg-background2` or `border-accent` work out of the box. If you already define any of these colors yourself in `uno.config.ts`, your values take precedence.
316
+ ## Translation
208
317
 
209
- This has to be added manually rather than auto-injected: `@unocss/nuxt` reloads `uno.config.ts` from disk on its own (to support HMR) and shallow-merges that file against anything injected through the `unocss:config` hook, which silently discards a hook-injected `theme` whenever your `uno.config.ts` already declares its own `theme` key β€” even one without any colors in it. As a preset living inside your own `presets` array, these colors become part of what's actually read from the file, so they survive that merge.
318
+ Detects the user's locale to translate the theme names (each theme's `translations`), `<VenixThemeSwitcher>`'s own strings and, optionally, your own strings.
210
319
 
211
- ## Vuetify integration
320
+ | Option | Type | Default | Description |
321
+ | ---------------- | --------- | ------------------- | -------------------------------------------------------- |
322
+ | `locale` | `string` | β€” | Force a locale, skipping detection |
323
+ | `defaultLocale` | `string` | `'en-US'` | Fallback when no locale can be detected |
324
+ | `cookieSync` | `string` | `'i18n_redirected'` | Cookie the locale is read from (and written by `locale.set()`) |
325
+ | `manageHtmlLang` | `boolean` | `false` | Keep `<html lang>` in sync β€” see [below](#integrating-with-a-routing-based-i18n-module-eg-nuxtjsi18n) |
212
326
 
213
- If [`vuetify-nuxt-module`](https://nuxt.vuetifyjs.com) is installed, enabling `vuetify: true` registers every color theme as a Vuetify `ThemeDefinition` and keeps Vuetify's active theme in sync with the cookie the rest of the module uses β€” no more hand-written `theme.themes` mapping in `nuxt.config.ts`:
327
+ The locale is detected in this order:
214
328
 
215
- ```typescript
216
- export default defineNuxtConfig({
217
- modules: [
218
- '@venix-sistemas/jade', // must come before the Vuetify module
219
- 'vuetify-nuxt-module',
220
- ],
221
- venixTheme: {
222
- vuetify: true,
223
- },
224
- })
329
+ 1. `translation.locale`, if set (skips every other step)
330
+ 2. The locale cookie (`translation.cookieSync`)
331
+ 3. The URL's locale prefix (e.g. `/en/...`), if a theme has a translation for it
332
+ 4. The `Accept-Language` header (SSR) or `navigator.language` (client)
333
+ 5. `translation.defaultLocale`
334
+
335
+ With `translation: false`, detection is off: theme names and the switcher's strings always use `defaultLocale`, and `locale.set()` never writes the cookie. When it's on, `locale.set()` only writes the cookie after [cookie consent](#saving-the-theme-cookie-consent), unless `color.requireConsent` is `false`.
336
+
337
+ ### Using your own translations
338
+
339
+ `locale.translate()` applies the same matching and fallbacks to your own strings:
340
+
341
+ ```ts
342
+ const { locale } = useVenixTheme()
343
+
344
+ locale.translate({ 'en-US': 'Hello', 'pt-BR': 'OlΓ‘' }, 'Hello') // second argument: fallback
225
345
  ```
226
346
 
227
- Unlike the UnoCSS integration (which points at CSS variables), Vuetify computes contrast and `on-*` colors in JavaScript, so it needs real hex values β€” the module passes the actual colors from each theme, not `var(...)` strings. `background2` is also mapped to Vuetify's `surface` slot (used by cards, toolbars, etc.), since that's the closest match in this module's color system, and every color is still available under its own name too (`bg-background2`, `text-inverse`, ...).
347
+ ### Integrating with a routing-based i18n module (e.g. `@nuxtjs/i18n`)
228
348
 
229
- `vuetify: true` also adds a small runtime plugin that keeps Vuetify's active theme in sync at every point: it resolves the same `theme-preference`/`theme-resolved` cookies used elsewhere in the module so Vuetify's `defaultTheme` matches what's rendered from the first paint (server and client), and it applies every later runtime switch (`theme.toggle()`, the switcher, a system/seasonal auto-change) via `theme.change()` (the current, non-deprecated API), inside the same View Transition the rest of the module uses rather than racing it as a separate update.
349
+ `translation.cookieSync` defaults to `'i18n_redirected'`, the same cookie `@nuxtjs/i18n` uses, so theme names follow your app's locale with no extra setup. If you renamed the cookie on either side, point `cookieSync` at the same name.
230
350
 
231
- In SPA mode (`ssr: false`), the same plugin also closes a first-paint gap: with unhead present, Vuetify hands its theme stylesheet (`<style id="vuetify-theme-stylesheet">`, with the `--v-theme-*` variables) to `head.push()`, and unhead only writes it to the DOM after the first render β€” so the page would show for a moment without Vuetify's theme colors. The plugin writes a copy of that stylesheet (`<style id="venix-vuetify-theme-early">`) into `<head>` before the app mounts, and removes it as soon as unhead's own stylesheet reaches the DOM. With SSR the stylesheet already comes in the HTML, so the plugin does nothing there.
351
+ `<html lang>` isn't touched by default. If your app has **no** routing i18n module, turn on `manageHtmlLang` so `lang` reflects the resolved locale (WCAG 3.1.1 β€” screen readers pronounce the theme names correctly):
232
352
 
233
- **This must come before the Vuetify module in your `modules` array** β€” the registration happens through Vuetify's own [`vuetify:registerModule`](https://nuxt.vuetifyjs.com/guide/advanced/layers-and-hooks.html) build hook, which only picks up registrations made before Vuetify resolves its configuration. If you already define `vuetify.vuetifyOptions.theme.themes` yourself, your values take precedence over the generated ones (merged per color, not replaced wholesale).
353
+ ```ts
354
+ venixTheme: {
355
+ translation: {
356
+ manageHtmlLang: true,
357
+ },
358
+ }
359
+ ```
234
360
 
235
- `vuetify` defaults to `false` β€” unlike the other integrations, it ships a runtime plugin, so it's opt-in rather than automatic. There's no hard dependency on Vuetify: if `vuetify-nuxt-module` isn't installed, enabling this option is a no-op. Tested against Vuetify `^4.2.1` with `vuetify-nuxt-module@1.0.0-rc.6` β€” as that module is still pre-1.0, its hooks may still change between releases.
361
+ Keep it off with `@nuxtjs/i18n` or similar: that module follows the current route and should own `lang`, while this module's detection can briefly disagree with it (e.g. right after navigating to a localized route) and the two would fight over the attribute.
236
362
 
237
363
  ## Icons
238
364
 
239
- `jade` installs and configures [`@nuxt/icon`](https://github.com/nuxt/icon) automatically and registers `<VenixIcon>` (and the equivalent `useVenixIcon()` composable), which accept **one single `icon` value** in any of three formats:
365
+ <p align="center">
366
+ <img src="./docs/images/readme/icons.png" alt="VenixIcon rendering an animated Iconify icon, an emoji, inline SVG and aliases" width="800">
367
+ </p>
368
+
369
+ Installs and configures [`@nuxt/icon`](https://github.com/nuxt/icon), so every [Iconify](https://icon-sets.iconify.design/) icon is available in your app.
370
+
371
+ **For regular icons, use `@nuxt/icon`'s own `<Icon>`** β€” Jade doesn't replace it, and the Iconify aliases from `icon.aliases` work there too:
372
+
373
+ ```vue
374
+ <template>
375
+ <Icon name="mdi:home" />
376
+ <Icon name="line-md:home" mode="svg" /> <!-- `mode="svg"` is needed for line-md's animations -->
377
+ </template>
378
+ ```
379
+
380
+ **For special cases, use `<VenixIcon>`** (or the matching `useVenixIcon()` composable): when the same value may be an Iconify name, an emoji or an inline SVG β€” for example an icon that comes from configuration or data, like the [theme icons](#theme-icons):
240
381
 
241
382
  ```vue
242
383
  <template>
243
- <VenixIcon icon="🎨" />
244
384
  <VenixIcon icon="line-md:home" />
245
- <VenixIcon icon="<svg viewBox=\"0 0 24 24\">...</svg>" />
385
+ <VenixIcon icon="<svg viewBox=&quot;0 0 24 24&quot;>...</svg>" />
386
+ <VenixIcon icon="🎨" />
246
387
  </template>
247
388
  ```
248
389
 
249
- * **Emoji** β€” any other string, rendered as text.
250
- * **Iconify icon name** β€” `collection:name` format (e.g. `line-md:home`, `mdi:home`). Includes full support for [`line-md`](https://icon-sets.iconify.design/line-md/)'s animated icons.
251
- * **Inline SVG** β€” a string starting with `<svg`, rendered via `v-html`. Only pass SVGs you or your theme config author, not end-user input β€” like any other `v-html` usage, this is not sanitized.
390
+ - **Iconify name** β€” `collection:name` (e.g. `line-md:home`, `mdi:home`), rendered with `<Icon>` in CSS mode by default (lighter, but never animated); pass `mode="svg"` for a real `<svg>`, needed for animations.
391
+ - **Inline SVG** β€” a string starting with `<svg`, rendered with `v-html`. It isn't sanitized, so only pass SVGs you control, never user input.
392
+ - **Emoji or text** β€” anything else.
393
+
394
+ | Option | Type | Default | Description |
395
+ | ------------- | ------------------------ | ------------- | -------------------------------------------------- |
396
+ | `collections` | `string[]` | `['line-md']` | Iconify collections bundled whole β€” see [below](#offline-icon-collections) |
397
+ | `aliases` | `Record<string, string>` | `{}` | Short names for any icon value β€” see [below](#aliases) |
398
+
399
+ Set `icon: false` to skip `@nuxt/icon` entirely, e.g. if your project already configures it. `<VenixIcon>` isn't registered then, and theme icons always use their emoji (`emote`), so `<VenixThemeSwitcher>` keeps working.
252
400
 
253
401
  ### Aliases
254
402
 
255
- Define short names for any of the three formats through `icon.aliases`, so consuming components don't need to remember full Iconify names:
403
+ `icon.aliases` gives short names to any of the three formats:
256
404
 
257
405
  ```typescript
258
406
  venixTheme: {
@@ -272,7 +420,11 @@ venixTheme: {
272
420
 
273
421
  ### Offline icon collections
274
422
 
275
- By default, the `line-md` collection is bundled at build time via `@iconify-json/line-md` (a direct dependency of this module) β€” icons resolve from the published package itself, not from the Iconify API, so they keep working the same way in the playground and once this module is installed as a dependency elsewhere, including offline. `@iconify-json/mdi` is also a direct dependency for the same reason: the built-in themes' `css` icon variant uses `mdi:*` names (see [Theme icons](#theme-icons)), and switching `color.iconFormat` to `'css'` pulls from it β€” only the handful of `mdi` icons actually referenced get bundled (see the tree-shaking note below), not the whole collection. Add more collections with `icon.collections` (each one needs its matching `@iconify-json/<collection>` package installed in your project β€” this fully bundles the whole collection, so any icon from it can be used anywhere in your app, not just in theme icons):
423
+ Icons are bundled at build time, so they work offline instead of being fetched from the Iconify API:
424
+
425
+ - **`line-md`** is bundled whole by default.
426
+ - **Icons used in theme `icon`s or in `icon.aliases`** are detected automatically, and only those icons are bundled, not their whole collection. That's how the built-in themes' `mdi` icons are included. The collection is looked up in this module's dependencies first, then in your project's `node_modules`.
427
+ - **To use any icon of a collection anywhere in your app**, install its `@iconify-json/<collection>` package and list it in `icon.collections` to bundle it whole. The list replaces the default, so keep `line-md` in it if you still want it:
276
428
 
277
429
  ```typescript
278
430
  venixTheme: {
@@ -282,47 +434,27 @@ venixTheme: {
282
434
  }
283
435
  ```
284
436
 
285
- Independently of `icon.collections`, any `collection:name` value used in a theme's `icon` (see [Theme icons](#theme-icons) below) or in `icon.aliases` β€” `mdi` included β€” is detected automatically and bundled offline with **only the icons actually referenced**, the same tree-shaking `mdi` gets by default (via [`@iconify/utils`](https://iconify.design/docs/libraries/utils/)). This lookup tries this module's own dependencies first, then your project's `node_modules`, so a collection you install yourself for a custom theme icon (without adding it to `icon.collections`) is found and tree-shaken the same way. If a referenced collection isn't found in either place, `@nuxt/icon` falls back to fetching it from the Iconify API at runtime (needs internet).
286
-
287
- Setting `icon: false` skips installing `@nuxt/icon` entirely β€” useful if your project already configures it directly.
437
+ If a referenced collection can't be found, `@nuxt/icon` fetches it from the Iconify API at runtime, which needs internet.
288
438
 
289
439
  ### Theme icons
290
440
 
291
- Each color theme's `icon` (used by `useVenixTheme().themes` for things like a theme picker) can be a plain emoji string, like the built-in themes ship by default:
292
-
293
- ```json
294
- "dark": {
295
- "icon": "πŸŒ™"
296
- }
297
- ```
298
-
299
- ...or an object offering up to three variants, letting the app pick the best one for its needs:
441
+ A theme's `icon` (shown by pickers such as `<VenixThemeSwitcher>`) is either a plain emoji, like `"icon": "πŸŒ™"`, or an object with up to three variants:
300
442
 
301
443
  ```json
302
- "light": {
444
+ "natal": {
303
445
  "icon": {
304
- "emote": "β˜€οΈ",
305
- "css": "mdi:sun-compass",
306
- "svg": "line-md:sunny-filled-loop"
446
+ "emote": "πŸŽ„",
447
+ "css": "mdi:pine-tree-variant",
448
+ "svg": "line-md:star-filled"
307
449
  }
308
450
  }
309
451
  ```
310
452
 
311
- * `emote` β€” an emoji, always required as the fallback.
312
- * `css` β€” an Iconify icon name rendered via `@nuxt/icon` in **CSS mode** (background/mask, no animation, lighter weight).
313
- * `svg` β€” an Iconify icon name rendered via `@nuxt/icon` in **SVG mode** (a real `<svg>` element β€” required for animated icons like `line-md`'s to actually animate).
453
+ - `emote` β€” an emoji. Required, it's the fallback.
454
+ - `css` β€” an Iconify name rendered in CSS mode: lighter, but never animated.
455
+ - `svg` β€” an Iconify name rendered as a real `<svg>`, needed for animated icons like `line-md`'s.
314
456
 
315
- Which variant gets used is controlled globally by `color.iconFormat` (`'emote' | 'css' | 'svg'`, defaults to `'svg'`) β€” it falls back to `emote` automatically for any theme that doesn't define the chosen format (including themes that just use a plain string):
316
-
317
- ```typescript
318
- venixTheme: {
319
- color: {
320
- iconFormat: 'css', // lighter weight, no animation β€” trade the default 'svg' for this if you don't need line-md's animated icons
321
- },
322
- }
323
- ```
324
-
325
- `useVenixTheme().themes` exposes the already-resolved icon as `{ format, value }`, ready to feed into `<VenixIcon>`:
457
+ `color.iconFormat` picks the variant for every theme (default `'svg'`, so the built-in `line-md` icons animate). When a theme doesn't define it, the other Iconify variant is tried before the emoji: `svg` β†’ `css` β†’ `emote` (or `css` β†’ `svg` β†’ `emote`). The mode options (Automatic, Light, Dark) use the same formats. `useVenixTheme().themes` and `.modes` already resolve it to `{ format, value }`, ready for `<VenixIcon>`:
326
458
 
327
459
  ```vue
328
460
  <VenixIcon
@@ -332,143 +464,107 @@ venixTheme: {
332
464
  />
333
465
  ```
334
466
 
335
- ## Themes
467
+ ## Typography
336
468
 
337
- The module ships with a built-in set of color themes (`dark`, `light`, plus the [seasonal ones](#seasonal-themes)) and can be extended through `color.themes`, which does two different things depending on the key:
469
+ Sets the base font for the whole app: `--font-family-base` and `--font-size-base` on `:root`, plus an `@font-face` rule for each custom font.
338
470
 
339
- - An **existing** name (`dark`, `light`, or any seasonal one) overrides only the properties you give it, keeping the rest of that theme intact.
340
- - A **new** name registers a theme that doesn't exist in the built-in set at all β€” nothing further to opt into, it works the same as any built-in theme: real CSS variables, its own entry in `useVenixTheme().themes` (so it shows up in `<VenixThemeSwitcher>`), and Vuetify/UnoCSS integration if those are enabled. Useful for a theme specific to your project, e.g. a brand color scheme or a one-off campaign theme with no equivalent in the base set.
471
+ <p align="center">
472
+ <img src="./docs/images/readme/typography.png" alt="The Iceberg font at several sizes" width="800">
473
+ </p>
341
474
 
342
475
  ```typescript
343
- color: {
344
- themes: {
345
- // Overrides an existing theme β€” the rest of `dark` stays as shipped
346
- dark: {
347
- primary: '#FF6B6B',
348
- },
349
-
350
- // Registers a brand new one, project-specific β€” 'summerSale' isn't a
351
- // built-in theme name, so this doesn't override anything
352
- summerSale: {
353
- dark: false,
354
- primary: '#FF8A00',
355
- background: '#FFF8EE',
356
- },
476
+ venixTheme: {
477
+ typography: {
478
+ defaultFonts: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif", // default
479
+ fontSize: '16px', // default
480
+ customFonts: [
481
+ { name: 'MyFont', sources: { woff2: '/fonts/MyFont.woff2' }, weight: 'normal', style: 'normal' },
482
+ ],
357
483
  },
358
484
  }
359
485
  ```
360
486
 
361
- This is currently the only supported way to customize colors β€” there's no option yet to load a completely custom theme file in place of the built-in one.
362
-
363
- ## Cookie Consent
364
-
365
- The module writes two cookies to remember the user's choice across visits:
366
-
367
- | Cookie | Purpose |
368
- | -------------------------- | ------------------------------------------------- |
369
- | `venix-theme-preference` | The user's raw choice (`'dark'`, `'system'`, a custom theme name, …) |
370
- | `venix-theme-resolved` | The actually-applied theme (e.g. `'system'` resolved to `'dark'`) β€” lets SSR render the right theme on the next visit without a flash |
371
-
372
- Neither is written until cookie consent is granted β€” **switching themes always works immediately for the current visit either way**; without consent it just isn't remembered on the next one. (The module's own locale cookie, used for `@nuxtjs/i18n` interop, is a separate concern β€” see [Integrating with a routing-based i18n module](#integrating-with-a-routing-based-i18n-module-eg-nuxtjsi18n).)
487
+ Custom fonts come first in `--font-family-base`, with `defaultFonts` as the fallback. The same font list also goes to Vuetify's `--v-font-body`/`--v-font-heading`, since Vuetify components don't inherit `font-family` from the page.
373
488
 
374
- Consent is read from `localStorage['venix-cookie-consent']` (a JSON object with a `functionality: boolean` field) β€” the same format most cookie-consent banners already use for a "functional cookies" category. This module never writes that key on its own; either wire your own consent banner to it, or use the convenience methods below for a minimal one:
489
+ ## Scrollbar
375
490
 
376
- ```vue
377
- <script setup lang="ts">
378
- const { persistence } = useVenixTheme()
379
- </script>
491
+ A custom scrollbar whose colors follow the active theme. The values below are the defaults:
380
492
 
381
- <template>
382
- <p>Cookies: {{ persistence.hasConsent.value ? 'allowed' : 'not allowed' }}</p>
383
- <button @click="persistence.grant()">Allow cookies</button>
384
- <button @click="persistence.revoke()">Revoke cookies</button>
385
- </template>
386
- ```
387
-
388
- - `persistence.hasConsent` β€” reactive `Ref<boolean>`, current consent state (shared app-wide, like `theme.preference`).
389
- - `persistence.grant()` β€” records consent (`{ functionality: true }`) and immediately persists the current theme preference to cookies.
390
- - `persistence.revoke()` β€” records the opposite and immediately deletes both cookies.
391
-
392
- If you already have your own consent-management setup (a full CMP, a custom banner, etc.), skip `grant()`/`revoke()` and just make sure it writes the same `localStorage` key/shape and dispatches a `window` event named `venix-cookie-preferences-updated` after any change β€” the module listens for that event (from any source) to re-sync immediately, rather than waiting for the next theme change:
393
-
394
- ```ts
395
- localStorage.setItem('venix-cookie-consent', JSON.stringify({ functionality: true }))
396
- window.dispatchEvent(new Event('venix-cookie-preferences-updated'))
397
- ```
398
-
399
- `persistence.enable()` / `persistence.disable()` remain available as the lower-level primitives (`enable()` still checks the stored consent before writing, so it's safe to call speculatively β€” it's a no-op without consent).
400
-
401
- ## Internationalization
402
-
403
- The module supports locale detection and can integrate with the application's internationalization setup β€” it's used to translate each color theme's name (`theme.colors.themes.<name>.translations`) and the built-in strings of `<VenixThemeSwitcher>`.
404
-
405
- The locale resolution can use:
406
-
407
- 1. The explicitly configured locale (`translation.locale`), if set β€” forces that locale everywhere, skipping every other step
408
- 2. The persisted locale cookie (`translation.cookieSync`, default `'i18n_redirected'`)
409
- 3. The current URL's locale prefix (e.g. `/en/...`), if it matches one of the theme's available locales β€” covers the case where a user opens a locale-prefixed route (e.g. via `@nuxtjs/i18n`) with no cookie yet and a browser language that disagrees with the URL
410
- 4. The `Accept-Language` header (SSR) / `navigator.language` (client)
411
- 5. The configured default locale (`translation.defaultLocale`)
412
-
413
- ### Using your own translations
414
-
415
- `useVenixTheme().locale` also exposes the same resolution/fallback logic the module uses internally for theme names, in case you want to translate your own strings the same way:
416
-
417
- ```ts
418
- const { locale } = useVenixTheme()
493
+ <p align="center">
494
+ <img src="./docs/images/readme/scrollbar.png" alt="Vertical and horizontal scrollbars in the theme colors" width="800">
495
+ </p>
419
496
 
420
- locale.translate({ 'en-US': 'Hello', 'pt-BR': 'OlΓ‘' }, 'Hello') // fallback if no match
497
+ ```typescript
498
+ venixTheme: {
499
+ scrollbar: {
500
+ width: 'auto',
501
+ borderRadius: '8px',
502
+ borderWidth: '3px',
503
+ // A theme color name (follows the active theme) or any CSS color
504
+ colors: { thumb: 'primary', thumbHover: 'secondary', track: 'background2', border: 'background3' },
505
+ },
506
+ }
421
507
  ```
422
508
 
423
- ### Integrating with a routing-based i18n module (e.g. `@nuxtjs/i18n`)
509
+ ## Cursor
424
510
 
425
- `translation.cookieSync` defaults to `'i18n_redirected'` β€” the same cookie `@nuxtjs/i18n` uses by default β€” so theme-name translations automatically follow whichever locale your app's i18n module resolves, with no extra wiring in the common case. If you've customized either side's cookie name, point `cookieSync` at the same one.
511
+ Replaces the default, pointer and text cursors with images. On by default, using the module's own cursor images; point it at yours to customize, or set `cursor: false` to keep the browser's cursors:
426
512
 
427
- By default, this module does **not** touch `<html lang>`. If your app has no routing-based i18n module and you still want `<html lang>` to reflect the resolved locale (recommended for accessibility β€” WCAG 3.1.1 β€” so screen readers pronounce translated theme names correctly), turn it on explicitly:
513
+ <p align="center">
514
+ <img src="./docs/images/readme/cursor.png" alt="The default, pointer and text cursors" width="800">
515
+ </p>
428
516
 
429
- ```ts
517
+ ```typescript
430
518
  venixTheme: {
431
- translation: {
432
- manageHtmlLang: true,
519
+ cursor: {
520
+ // Images served from `public/`; `hotspot` is the click point ("x y")
521
+ cursors: {
522
+ default: { path: '/cursors/default.png', hotspot: '0 0' },
523
+ pointer: { path: '/cursors/pointer.png', hotspot: '0 0' },
524
+ text: { path: '/cursors/text.png', hotspot: '0 0' },
525
+ },
433
526
  },
434
527
  }
435
528
  ```
436
529
 
437
- Leave it off (the default) if you use `@nuxtjs/i18n` or a similar module: that module's locale reflects the current route and is the correct source of truth for `<html lang>`, while this module's own locale detection (cookie/header/browser) can briefly disagree with it (e.g. right after navigating to a localized route, before any cookie write happens) β€” having both write to `lang` would make them fight over it.
530
+ > [!NOTE]
531
+ > Keep cursor images at **32Γ—32 pixels or smaller**. Browsers accept larger cursors (Chromium up to 128Γ—128), but Chromium falls back to the system cursor whenever a cursor larger than 32Γ—32 would overlap the browser UI, so it flickers near the edges of the window.
532
+ >
533
+ > Browser-drawn UI ignores the CSS `cursor` property and always shows the system cursor. That includes native scrollbars, `<select>` dropdowns, date and color pickers, and the `<textarea>` resize handle.
438
534
 
439
- ## Seasonal Themes
535
+ ## Vuetify
440
536
 
441
- Built in: 🎭 Carnival, πŸŽƒ Halloween, πŸŽ„ Christmas β€” applied automatically, in place of `dark`/`light`, when the `'system'` preference is active and today falls inside their date range.
442
-
443
- Add your own through `color.themes`, the same as any other custom theme β€” `seasonal: true` and `dateRange` (`MM-DD`, inclusive, wraps across year-end if `end` < `start`) opt it into this rotation instead of making it directly selectable. `dark` still matters here: it decides which system mode (light/dark) the theme pairs with.
537
+ With [`vuetify-nuxt-module`](https://nuxt.vuetifyjs.com) installed, `vuetify: true` registers every color theme with Vuetify and keeps its active theme in sync β€” no hand-written `theme.themes` mapping:
444
538
 
445
539
  ```typescript
446
- color: {
447
- themes: {
448
- blackFriday: {
449
- dark: true,
450
- seasonal: true,
451
- dateRange: { start: '11-24', end: '11-30' },
452
- primary: '#111111',
453
- background: '#000000',
454
- },
540
+ export default defineNuxtConfig({
541
+ modules: [
542
+ '@venix-sistemas/jade', // must come before the Vuetify module
543
+ 'vuetify-nuxt-module',
544
+ ],
545
+ venixTheme: {
546
+ vuetify: true,
455
547
  },
456
- }
548
+ })
457
549
  ```
458
550
 
459
- ## Development
551
+ - **Order matters:** the themes are registered through Vuetify's [`vuetify:registerModule`](https://nuxt.vuetifyjs.com/guide/advanced/layers-and-hooks.html) hook, which only sees modules listed before Vuetify.
552
+ - **Real colors:** Vuetify computes contrast and `on-*` colors in JavaScript, so it receives the actual hex values, not `var(...)`. `background2` also fills Vuetify's `surface` slot (cards, toolbars, …).
553
+ - **Your values win:** anything you set in `vuetify.vuetifyOptions.theme.themes` is merged per color on top of the generated themes.
554
+ - **Always in sync:** a small runtime plugin starts Vuetify on the same theme the page gets (so the first paint is right, with or without SSR) and applies every later switch with `theme.change()`, inside the same View Transition as the rest of the page.
555
+ - **No flash in SPA mode** (`ssr: false`): Vuetify's theme stylesheet only reaches the DOM after the first render there, so the plugin writes a temporary copy into `<head>` before mount and removes it once Vuetify's own arrives.
460
556
 
461
- Clone the repository, then:
557
+ It's opt-in because it adds a runtime plugin, and it does nothing if `vuetify-nuxt-module` isn't installed. Tested with Vuetify `^4.2.1` and `vuetify-nuxt-module@1.0.0-rc.6`; that module is still pre-1.0, so its hooks may change.
462
558
 
463
- | Command | Description |
464
- | ------- | ----------- |
465
- | `pnpm install` | Install dependencies |
466
- | `pnpm dev` | Start the playground |
467
- | `pnpm test` | Run the tests |
468
- | `pnpm lint` | Run the linter |
469
- | `pnpm prepack` | Build the package |
559
+ ## Development
470
560
 
471
- See the [Configuration](#configuration) section above for the full options reference, and the [Playground](./playground) for a working example.
561
+ | Command | Description |
562
+ | -------------- | -------------------- |
563
+ | `pnpm install` | Install dependencies |
564
+ | `pnpm dev` | Start the [playground](./playground) |
565
+ | `pnpm test` | Run the tests |
566
+ | `pnpm lint` | Run the linter |
567
+ | `pnpm prepack` | Build the package |
472
568
 
473
569
  ## Brand
474
570