@venix-sistemas/jade 1.0.0 โ†’ 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,56 +1,49 @@
1
- <p align="center">
2
- <img src="./docs/images/jade-transparent.png" alt="Jade logo" width="200">
3
- </p>
4
-
5
- <h1 align="center">Jade</h1>
6
-
7
- <p align="center">
8
- <code>@venix-sistemas/jade</code>
9
- </p>
10
-
11
- <p align="center">
12
- <a href="https://www.npmjs.com/package/@venix-sistemas/jade"><img src="https://badge.fury.io/js/@venix-sistemas%2Fjade.svg" alt="npm version"></a>
13
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
14
- </p>
15
-
16
- A complete centralized theming system for Nuxt applications: colors, typography, cursor, scrollbar, internationalization and seasonal themes, with UnoCSS, Vuetify and Iconify integrations.
17
-
18
- ## Features
19
-
20
- * ๐Ÿ“ **Typography and font faces customization**
21
- * ๐Ÿ–ฑ๏ธ **Cursor customization**
22
- * ๐Ÿ“œ **Scrollbar customization**
23
- * ๐ŸŽจ **Color customization**, with dark and light themes included
24
- * ๐Ÿ–ฅ๏ธ **System theme preference detection**, including seasonal overrides
25
- * ๐ŸŽƒ **Seasonal themes**: Carnival, Halloween, Christmas and more
26
- * ๐Ÿ’พ **Cookie-consent-aware persistence**: nothing is written until the user opts in
27
- * ๐ŸŒ **i18n**: internationalization and locale detection for theme names and your own strings
28
- * โšก **Nuxt-native integration**
29
- * ๐ŸŽฏ **UnoCSS preset** for the theme's color variables
30
- * ๐ŸŽญ **Vuetify 4** theme auto-configuration, kept in sync with live theme changes
31
- * โœจ **Unified icons**: emoji, Iconify (animated `line-md`, `mdi`, both bundled and tree-shaken offline) or inline SVG through one component
32
-
1
+ <p align="center">
2
+ <img src="./docs/images/jade-transparent.png" alt="Jade logo" width="200">
3
+ </p>
4
+
5
+ <h1 align="center">Jade</h1>
6
+
7
+ <p align="center">
8
+ <code>@venix-sistemas/jade</code>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@venix-sistemas/jade"><img src="https://badge.fury.io/js/@venix-sistemas%2Fjade.svg" alt="npm version"></a>
13
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
14
+ </p>
15
+
16
+ A complete centralized theming system for Nuxt applications: colors, typography, cursor, scrollbar, internationalization and seasonal themes, with UnoCSS, Vuetify and Iconify integrations.
17
+
18
+ ## Features
19
+
20
+ * ๐Ÿ“ **Typography and font faces customization**
21
+ * ๐Ÿ–ฑ๏ธ **Cursor customization**
22
+ * ๐Ÿ“œ **Scrollbar customization**
23
+ * ๐ŸŽจ **Color customization**, with dark and light themes included
24
+ * ๐Ÿ–ฅ๏ธ **System theme preference detection**, including seasonal overrides
25
+ * ๐ŸŽƒ **Seasonal themes**: Carnival, Halloween, Christmas and more
26
+ * ๐Ÿ’พ **Cookie-consent-aware persistence**: nothing is written until the user opts in
27
+ * ๐ŸŒ **i18n**: internationalization and locale detection for theme names and your own strings
28
+ * โšก **Nuxt-native integration**
29
+ * ๐ŸŽฏ **UnoCSS preset** for the theme's color variables
30
+ * ๐ŸŽญ **Vuetify 4** theme auto-configuration, kept in sync with live theme changes
31
+ * โœจ **Unified icons**: emoji, Iconify (animated `line-md`, `mdi`, both bundled and tree-shaken offline) or inline SVG through one component
32
+
33
33
  ## Installation
34
34
 
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
35
  ```bash
44
36
  pnpm add @venix-sistemas/jade
37
+ # or
38
+ npm install @venix-sistemas/jade
45
39
  ```
46
40
 
47
41
  ## Quick Setup
48
42
 
49
43
  ### 1. Add the module
50
44
 
51
- Add `@venix-sistemas/jade` to the `modules` section of your `nuxt.config.ts`:
52
-
53
45
  ```typescript
46
+ // nuxt.config.ts
54
47
  export default defineNuxtConfig({
55
48
  modules: ['@venix-sistemas/jade'],
56
49
 
@@ -66,23 +59,16 @@ export default defineNuxtConfig({
66
59
  })
67
60
  ```
68
61
 
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.
62
+ Every feature 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 [Configuration](#configuration) for every option.
70
63
 
71
64
  ### 2. Use the theme
72
65
 
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):
66
+ 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.
74
67
 
75
68
  ```vue
76
69
  <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>
70
+ <button @click="theme.toggle('dark')">Dark</button>
71
+ <button @click="theme.toggle('light')">Light</button>
86
72
  </template>
87
73
 
88
74
  <script setup lang="ts">
@@ -90,18 +76,24 @@ const { theme } = useVenixTheme()
90
76
  </script>
91
77
  ```
92
78
 
93
- `useVenixTheme()` returns four grouped values:
79
+ It returns four groups:
94
80
 
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()`.
81
+ - `theme` โ€” state and controls:
82
+ - `value`: the applied theme (e.g. `'dark'` when the preference is `'system'`)
83
+ - `preference`: the user's raw choice, including `'system'`
84
+ - `data`: the active theme's `{ value, name, icon }`
85
+ - `toggle(name?)`: switches to `name`, or between `light` and `dark` when called without one
86
+ - `isSeasonalActive`, `activeSeasonalTheme`: whether a [seasonal theme](#seasonal-themes) is currently in effect, and which one
87
+ - `shouldApplyColors`, `colors`: whether the module applies colors, and the raw color config
88
+ - `themes` โ€” every selectable theme, ready to render a picker (see [Theme icons](#theme-icons)).
89
+ - `locale` โ€” `current`, `set()` and `translate()` (see [Internationalization](#internationalization)).
90
+ - `persistence` โ€” cookie consent controls (see [Cookie Consent](#cookie-consent)).
99
91
 
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.
92
+ 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
93
 
102
94
  ### 3. Ready-made component
103
95
 
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:
96
+ `<VenixThemeSwitcher>` is an auto-imported dropdown for picking a theme, with no dependency on Vuetify or any other UI kit:
105
97
 
106
98
  ```vue
107
99
  <template>
@@ -109,148 +101,163 @@ const { theme } = useVenixTheme()
109
101
  </template>
110
102
  ```
111
103
 
112
- Props:
113
-
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 |
104
+ | Prop | Type | Default | Description |
105
+ | ----------- | --------- | ----------------------- | --------------------------------------------------- |
106
+ | `label` | `string` | translated, per locale | Accessible label for the button and the menu |
107
+ | `showLabel` | `boolean` | `false` | Show the active theme's name next to the icon |
118
108
 
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.
109
+ - **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.
110
+ - **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.
111
+ - **Lively:** animated icons (e.g. `line-md`) replay on every switch, and the button fades in on mount.
120
112
 
121
- A few behaviors worth knowing about:
122
-
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.
127
-
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)).
113
+ It ships with minimal CSS of its own. To restyle it, target `.venix-theme-switcher`, `.venix-theme-switcher__trigger`, `.venix-theme-switcher__menu` and `.venix-theme-switcher__item` (see [`VenixThemeSwitcher.vue`](./src/runtime/components/VenixThemeSwitcher.vue)).
129
114
 
130
115
  ### Theme transition
131
116
 
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.
117
+ 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
118
 
134
119
  ## Configuration
135
120
 
136
121
  ### Module Options
137
122
 
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):
123
+ Each option accepts `false` (disable), `true` (enable with defaults) or an object (enable and customize):
139
124
 
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` |
125
+ | Option | Default | Description |
126
+ | ------------- | ------- | --------------------------------------------------------------------------- |
127
+ | `translation` | `true` | Locale detection for theme names โ€” see [`translation`](#translation-object) |
128
+ | `color` | `true` | Color themes โ€” see [`color`](#color-object) and [Themes](#themes) |
129
+ | `scrollbar` | `true` | Custom scrollbar โ€” see [`scrollbar`, `cursor`, `typography`](#scrollbar-cursor-and-typography) |
130
+ | `cursor` | `true` | Custom cursor images |
131
+ | `typography` | `true` | Base font family, font size and `@font-face` rules |
132
+ | `icon` | `true` | Installs `@nuxt/icon` and registers `<VenixIcon>` โ€” see [Icons](#icons) |
133
+ | `vuetify` | `false` | Vuetify theme auto-configuration โ€” see [Vuetify](#vuetify-integration) |
149
134
 
150
135
  #### `translation` object
151
136
 
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)) |
137
+ | Property | Type | Default | Description |
138
+ | ---------------- | --------- | ------------------- | -------------------------------------------------------- |
139
+ | `locale` | `string` | โ€” | Force a locale, skipping detection |
140
+ | `defaultLocale` | `string` | `'en-US'` | Fallback when no locale can be detected |
141
+ | `cookieSync` | `string` | `'i18n_redirected'` | Cookie the locale is read from (and written by `locale.set()`) |
142
+ | `manageHtmlLang` | `boolean` | `false` | Keep `<html lang>` in sync โ€” see [Internationalization](#internationalization) |
158
143
 
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).
144
+ With `translation: false`, detection is off: theme names and the switcher's strings always use `defaultLocale`, and `locale.set()` never writes the cookie.
160
145
 
161
146
  #### `color` object
162
147
 
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) |
148
+ | Property | Type | Default | Description |
149
+ | -------------- | --------------------------- | -------- | ------------------------------------------------------------- |
150
+ | `apply` | `boolean` | `true` | Apply the resolved theme to `<html>` (`data-theme` and class) |
151
+ | `defaultColor` | `string` | `'dark'` | Theme used when there's no preference yet |
152
+ | `themes` | `object` | `{}` | Override or add themes โ€” see [Themes](#themes) |
153
+ | `iconFormat` | `'emote' \| 'css' \| 'svg'` | `'svg'` | Preferred theme icon variant โ€” see [Theme icons](#theme-icons) |
169
154
 
170
- ## UnoCSS integration
171
-
172
- `jade` ships a UnoCSS preset that exposes the theme's color variables under `theme.colors` โ€” add it to your own `uno.config.ts`:
155
+ #### `scrollbar`, `cursor` and `typography`
173
156
 
174
157
  ```typescript
175
- // uno.config.ts
176
- import { defineConfig } from 'unocss'
177
- import { venixUnoPreset } from '@venix-sistemas/jade/unocss'
178
-
179
- export default defineConfig({
180
- presets: [
181
- venixUnoPreset(),
182
- // ...your other presets
183
- ],
184
- })
158
+ venixTheme: {
159
+ scrollbar: {
160
+ width: 'auto',
161
+ borderRadius: '8px',
162
+ borderWidth: '3px',
163
+ // A theme color name (follows the active theme) or any CSS color
164
+ colors: { thumb: 'primary', thumbHover: 'secondary', track: 'background2', border: 'background3' },
165
+ },
166
+ cursor: {
167
+ // Images served from `public/`; `hotspot` is the click point ("x y")
168
+ cursors: {
169
+ default: { path: '/cursors/default.png', hotspot: '0 0' },
170
+ pointer: { path: '/cursors/pointer.png', hotspot: '0 0' },
171
+ text: { path: '/cursors/text.png', hotspot: '0 0' },
172
+ },
173
+ },
174
+ typography: {
175
+ defaultFonts: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
176
+ fontSize: '16px',
177
+ customFonts: [
178
+ { name: 'MyFont', sources: { woff2: '/fonts/MyFont.woff2' }, weight: 'normal', style: 'normal' },
179
+ ],
180
+ },
181
+ }
185
182
  ```
186
183
 
187
- `venixUnoPreset()` is equivalent to writing this yourself:
184
+ The values shown for `scrollbar` and `typography.defaultFonts`/`fontSize` are the defaults. Custom fonts come first in `--font-family-base` (also applied to Vuetify's `--v-font-body`/`--v-font-heading`), with `defaultFonts` as the fallback.
185
+
186
+ ## Themes
187
+
188
+ The module ships with `dark`, `light` and the [seasonal themes](#seasonal-themes). `color.themes` extends that set:
189
+
190
+ - An **existing** name overrides only the properties you set; the rest of the theme (other colors, translations, icon) stays as shipped.
191
+ - 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. New themes are dark unless you set `dark: false`.
188
192
 
189
193
  ```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)',
194
+ color: {
195
+ themes: {
196
+ // Overrides only `primary` of the built-in dark theme
197
+ dark: {
198
+ primary: '#FF6B6B',
199
+ },
200
+
201
+ // Adds a project-specific theme
202
+ summerSale: {
203
+ dark: false,
204
+ primary: '#FF8A00',
205
+ background: '#FFF8EE',
206
+ },
203
207
  },
204
208
  }
205
209
  ```
206
210
 
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.
211
+ 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 themes, black on light ones).
208
212
 
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.
213
+ ### Seasonal Themes
210
214
 
211
- ## Vuetify integration
215
+ Built in: ๐ŸŽญ Carnival, ๐ŸŽƒ Halloween and ๐ŸŽ„ Christmas. While the preference is `'system'` and today is inside a seasonal theme's `dateRange`, it replaces `dark` or `light` โ€” whichever matches its own `dark` flag and the user's system mode.
212
216
 
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`:
217
+ Add your own with `seasonal: true` and a `dateRange`. Seasonal themes aren't directly selectable; they only appear through `'system'`. 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`):
214
218
 
215
219
  ```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,
220
+ color: {
221
+ themes: {
222
+ blackFriday: {
223
+ dark: true,
224
+ seasonal: true,
225
+ dateRange: { start: '11-24', end: '11-30' },
226
+ primary: '#111111',
227
+ background: '#000000',
228
+ },
229
+ pascoa: {
230
+ dark: false,
231
+ seasonal: true,
232
+ dateRange: { start: 'easter-6', end: 'easter' }, // Holy Week, every year
233
+ primary: '#F4A6C0',
234
+ background: '#FFF8F0',
235
+ },
223
236
  },
224
- })
237
+ }
225
238
  ```
226
239
 
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`, ...).
228
-
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.
230
-
231
- **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).
232
-
233
- `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.
240
+ The built-in Carnival theme uses `easter-65` to `easter-46`: 20 days, from the pre-Carnival weeks up to Ash Wednesday.
234
241
 
235
242
  ## Icons
236
243
 
237
- `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:
244
+ `jade` installs and configures [`@nuxt/icon`](https://github.com/nuxt/icon) and registers `<VenixIcon>` (and the matching `useVenixIcon()` composable). A single `icon` value accepts three formats:
238
245
 
239
246
  ```vue
240
247
  <template>
241
- <VenixIcon icon="๐ŸŽจ" />
242
248
  <VenixIcon icon="line-md:home" />
243
- <VenixIcon icon="<svg viewBox=\"0 0 24 24\">...</svg>" />
249
+ <VenixIcon icon="<svg viewBox=&quot;0 0 24 24&quot;>...</svg>" />
250
+ <VenixIcon icon="๐ŸŽจ" />
244
251
  </template>
245
252
  ```
246
253
 
247
- * **Emoji** โ€” any other string, rendered as text.
248
- * **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.
249
- * **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.
254
+ - **Iconify name** โ€” `collection:name` (e.g. `line-md:home`, `mdi:home`), including [`line-md`](https://icon-sets.iconify.design/line-md/)'s animated icons.
255
+ - **Inline SVG** โ€” a string starting with `<svg`, rendered with `v-html`. It isn't sanitized, so only pass SVGs you control, never user input.
256
+ - **Emoji or text** โ€” anything else.
250
257
 
251
258
  ### Aliases
252
259
 
253
- Define short names for any of the three formats through `icon.aliases`, so consuming components don't need to remember full Iconify names:
260
+ `icon.aliases` gives short names to any of the three formats:
254
261
 
255
262
  ```typescript
256
263
  venixTheme: {
@@ -270,7 +277,11 @@ venixTheme: {
270
277
 
271
278
  ### Offline icon collections
272
279
 
273
- 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):
280
+ Icons are bundled at build time, so they work offline instead of being fetched from the Iconify API:
281
+
282
+ - **`line-md`** is bundled whole by default.
283
+ - **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`.
284
+ - **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. Keep `line-md` in the list if you still want it:
274
285
 
275
286
  ```typescript
276
287
  venixTheme: {
@@ -280,21 +291,11 @@ venixTheme: {
280
291
  }
281
292
  ```
282
293
 
283
- 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).
284
-
285
- Setting `icon: false` skips installing `@nuxt/icon` entirely โ€” useful if your project already configures it directly.
294
+ If a referenced collection can't be found, `@nuxt/icon` fetches it from the Iconify API at runtime, which needs internet. Set `icon: false` to skip `@nuxt/icon` entirely, e.g. if your project already configures it.
286
295
 
287
296
  ### Theme icons
288
297
 
289
- 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:
290
-
291
- ```json
292
- "dark": {
293
- "icon": "๐ŸŒ™"
294
- }
295
- ```
296
-
297
- ...or an object offering up to three variants, letting the app pick the best one for its needs:
298
+ 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:
298
299
 
299
300
  ```json
300
301
  "light": {
@@ -306,21 +307,11 @@ Each color theme's `icon` (used by `useVenixTheme().themes` for things like a th
306
307
  }
307
308
  ```
308
309
 
309
- * `emote` โ€” an emoji, always required as the fallback.
310
- * `css` โ€” an Iconify icon name rendered via `@nuxt/icon` in **CSS mode** (background/mask, no animation, lighter weight).
311
- * `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).
312
-
313
- 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):
310
+ - `emote` โ€” an emoji. Required, it's the fallback.
311
+ - `css` โ€” an Iconify name rendered in CSS mode: lighter, but never animated.
312
+ - `svg` โ€” an Iconify name rendered as a real `<svg>`, needed for animated icons like `line-md`'s.
314
313
 
315
- ```typescript
316
- venixTheme: {
317
- color: {
318
- iconFormat: 'css', // lighter weight, no animation โ€” trade the default 'svg' for this if you don't need line-md's animated icons
319
- },
320
- }
321
- ```
322
-
323
- `useVenixTheme().themes` exposes the already-resolved icon as `{ format, value }`, ready to feed into `<VenixIcon>`:
314
+ `color.iconFormat` picks the variant for every theme (default `'svg'`), falling back to `emote` when a theme doesn't define it. `useVenixTheme().themes` already resolves it to `{ format, value }`, ready for `<VenixIcon>`:
324
315
 
325
316
  ```vue
326
317
  <VenixIcon
@@ -330,46 +321,18 @@ venixTheme: {
330
321
  />
331
322
  ```
332
323
 
333
- ## Themes
334
-
335
- 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:
336
-
337
- - An **existing** name (`dark`, `light`, or any seasonal one) overrides only the properties you give it, keeping the rest of that theme intact.
338
- - 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.
339
-
340
- ```typescript
341
- color: {
342
- themes: {
343
- // Overrides an existing theme โ€” the rest of `dark` stays as shipped
344
- dark: {
345
- primary: '#FF6B6B',
346
- },
347
-
348
- // Registers a brand new one, project-specific โ€” 'summerSale' isn't a
349
- // built-in theme name, so this doesn't override anything
350
- summerSale: {
351
- dark: false,
352
- primary: '#FF8A00',
353
- background: '#FFF8EE',
354
- },
355
- },
356
- }
357
- ```
358
-
359
- 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.
360
-
361
324
  ## Cookie Consent
362
325
 
363
- The module writes two cookies to remember the user's choice across visits:
326
+ Two cookies remember the user's choice between visits:
364
327
 
365
- | Cookie | Purpose |
366
- | -------------------------- | ------------------------------------------------- |
367
- | `venix-theme-preference` | The user's raw choice (`'dark'`, `'system'`, a custom theme name, โ€ฆ) |
368
- | `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 |
328
+ | Cookie | Stores |
329
+ | ------------------------ | ----------------------------------------------------------------------------------- |
330
+ | `venix-theme-preference` | The user's raw choice (`'dark'`, `'system'`, a custom themeโ€ฆ) |
331
+ | `venix-theme-resolved` | The theme actually applied (e.g. `'dark'` for `'system'`), so SSR renders it with no flash |
369
332
 
370
- 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).)
333
+ Neither is written without consent. Switching themes always works; without consent it just isn't remembered on the next visit. (The locale cookie is covered in [Integrating with a routing-based i18n module](#integrating-with-a-routing-based-i18n-module-eg-nuxtjsi18n).)
371
334
 
372
- 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:
335
+ 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:
373
336
 
374
337
  ```vue
375
338
  <script setup lang="ts">
@@ -383,46 +346,43 @@ const { persistence } = useVenixTheme()
383
346
  </template>
384
347
  ```
385
348
 
386
- - `persistence.hasConsent` โ€” reactive `Ref<boolean>`, current consent state (shared app-wide, like `theme.preference`).
387
- - `persistence.grant()` โ€” records consent (`{ functionality: true }`) and immediately persists the current theme preference to cookies.
388
- - `persistence.revoke()` โ€” records the opposite and immediately deletes both cookies.
349
+ - `persistence.hasConsent` โ€” reactive `Ref<boolean>`, shared app-wide.
350
+ - `persistence.grant()` โ€” records consent and saves the current theme to the cookies right away.
351
+ - `persistence.revoke()` โ€” records the refusal and deletes both cookies right away.
352
+ - `persistence.enable()` / `persistence.disable()` โ€” lower-level: write or delete the cookies directly (`enable()` still does nothing without consent).
389
353
 
390
- 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:
354
+ 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:
391
355
 
392
356
  ```ts
393
357
  localStorage.setItem('venix-cookie-consent', JSON.stringify({ functionality: true }))
394
358
  window.dispatchEvent(new Event('venix-cookie-preferences-updated'))
395
359
  ```
396
360
 
397
- `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).
398
-
399
361
  ## Internationalization
400
362
 
401
- 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>`.
363
+ The resolved locale translates the theme names (each theme's `translations`) and `<VenixThemeSwitcher>`'s own strings. It's detected in this order:
402
364
 
403
- The locale resolution can use:
404
-
405
- 1. The explicitly configured locale (`translation.locale`), if set โ€” forces that locale everywhere, skipping every other step
406
- 2. The persisted locale cookie (`translation.cookieSync`, default `'i18n_redirected'`)
407
- 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
408
- 4. The `Accept-Language` header (SSR) / `navigator.language` (client)
409
- 5. The configured default locale (`translation.defaultLocale`)
365
+ 1. `translation.locale`, if set (skips every other step)
366
+ 2. The locale cookie (`translation.cookieSync`)
367
+ 3. The URL's locale prefix (e.g. `/en/...`), if a theme has a translation for it
368
+ 4. The `Accept-Language` header (SSR) or `navigator.language` (client)
369
+ 5. `translation.defaultLocale`
410
370
 
411
371
  ### Using your own translations
412
372
 
413
- `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:
373
+ `locale.translate()` applies the same matching and fallbacks to your own strings:
414
374
 
415
375
  ```ts
416
376
  const { locale } = useVenixTheme()
417
377
 
418
- locale.translate({ 'en-US': 'Hello', 'pt-BR': 'Olรก' }, 'Hello') // fallback if no match
378
+ locale.translate({ 'en-US': 'Hello', 'pt-BR': 'Olรก' }, 'Hello') // second argument: fallback
419
379
  ```
420
380
 
421
381
  ### Integrating with a routing-based i18n module (e.g. `@nuxtjs/i18n`)
422
382
 
423
- `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.
383
+ `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.
424
384
 
425
- 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:
385
+ `<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):
426
386
 
427
387
  ```ts
428
388
  venixTheme: {
@@ -432,41 +392,62 @@ venixTheme: {
432
392
  }
433
393
  ```
434
394
 
435
- 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.
395
+ 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.
396
+
397
+ ## UnoCSS integration
398
+
399
+ Add the preset to your `uno.config.ts` to use the theme colors as utilities (`text-primary`, `bg-background2`, `border-accent`, โ€ฆ):
400
+
401
+ ```typescript
402
+ // uno.config.ts
403
+ import { defineConfig } from 'unocss'
404
+ import { venixUnoPreset } from '@venix-sistemas/jade/unocss'
405
+
406
+ export default defineConfig({
407
+ presets: [
408
+ venixUnoPreset(),
409
+ // ...your other presets
410
+ ],
411
+ })
412
+ ```
413
+
414
+ 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.
436
415
 
437
- ## Seasonal Themes
416
+ 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.
438
417
 
439
- 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.
418
+ ## Vuetify integration
440
419
 
441
- 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.
420
+ 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:
442
421
 
443
422
  ```typescript
444
- color: {
445
- themes: {
446
- blackFriday: {
447
- dark: true,
448
- seasonal: true,
449
- dateRange: { start: '11-24', end: '11-30' },
450
- primary: '#111111',
451
- background: '#000000',
452
- },
423
+ export default defineNuxtConfig({
424
+ modules: [
425
+ '@venix-sistemas/jade', // must come before the Vuetify module
426
+ 'vuetify-nuxt-module',
427
+ ],
428
+ venixTheme: {
429
+ vuetify: true,
453
430
  },
454
- }
431
+ })
455
432
  ```
456
433
 
457
- ## Development
434
+ - **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.
435
+ - **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, โ€ฆ).
436
+ - **Your values win:** anything you set in `vuetify.vuetifyOptions.theme.themes` is merged per color on top of the generated themes.
437
+ - **Always in sync:** a small runtime plugin picks Vuetify's initial theme from the same cookies (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.
438
+ - **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.
458
439
 
459
- Clone the repository, then:
440
+ 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.
460
441
 
461
- | Command | Description |
462
- | ------- | ----------- |
463
- | `pnpm install` | Install dependencies |
464
- | `pnpm dev` | Start the playground |
465
- | `pnpm test` | Run the tests |
466
- | `pnpm lint` | Run the linter |
467
- | `pnpm prepack` | Build the package |
442
+ ## Development
468
443
 
469
- See the [Configuration](#configuration) section above for the full options reference, and the [Playground](./playground) for a working example.
444
+ | Command | Description |
445
+ | -------------- | -------------------- |
446
+ | `pnpm install` | Install dependencies |
447
+ | `pnpm dev` | Start the [playground](./playground) |
448
+ | `pnpm test` | Run the tests |
449
+ | `pnpm lint` | Run the linter |
450
+ | `pnpm prepack` | Build the package |
470
451
 
471
452
  ## Brand
472
453