@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.
- package/README.md +350 -254
- package/dist/module.json +1 -1
- package/dist/module.mjs +32 -35
- package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +1 -1
- package/dist/runtime/components/VenixThemeSwitcher.vue +242 -99
- package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +1 -1
- package/dist/runtime/composables/useThemeColors.d.ts +6 -0
- package/dist/runtime/composables/useThemeColors.js +24 -9
- package/dist/runtime/composables/useThemeCookies.d.ts +9 -2
- package/dist/runtime/composables/useThemeCookies.js +24 -6
- package/dist/runtime/composables/useThemeLocale.d.ts +5 -0
- package/dist/runtime/composables/useThemeLocale.js +12 -18
- package/dist/runtime/composables/useThemeSeasonal.d.ts +2 -2
- package/dist/runtime/composables/useThemeSeasonal.js +1 -1
- package/dist/runtime/composables/useVenixTheme.d.ts +20 -0
- package/dist/runtime/composables/useVenixTheme.js +174 -112
- package/dist/runtime/nitro/theme-init.js +8 -5
- package/dist/runtime/plugins/theme-init.server.js +7 -12
- package/dist/runtime/plugins/vuetify-theme.js +8 -11
- package/dist/runtime/scripts/theme-init.d.ts +23 -10
- package/dist/runtime/scripts/theme-init.js +42 -62
- package/dist/shared/constants.d.ts +18 -3
- package/dist/shared/constants.js +6 -1
- package/dist/shared/css/colors.js +2 -2
- package/dist/shared/css/cursor.js +9 -2
- package/dist/shared/css/index.d.ts +1 -7
- package/dist/shared/css/index.js +9 -9
- package/dist/shared/css/transition.d.ts +1 -1
- package/dist/shared/theme.json +302 -192
- package/dist/shared/types/color-options.d.ts +26 -2
- package/dist/shared/types/colors.d.ts +64 -7
- package/dist/shared/types/index.d.ts +1 -1
- package/dist/shared/types/runtime-config.d.ts +4 -2
- package/dist/shared/utils/icon-refs.d.ts +7 -3
- package/dist/shared/utils/icon-refs.js +1 -1
- package/dist/shared/utils/icon.d.ts +6 -2
- package/dist/shared/utils/icon.js +8 -3
- package/dist/shared/utils/index.d.ts +5 -3
- package/dist/shared/utils/index.js +12 -5
- package/dist/shared/utils/inline-script.d.ts +6 -0
- package/dist/shared/utils/inline-script.js +3 -0
- package/dist/shared/utils/load.d.ts +0 -1
- package/dist/shared/utils/load.js +7 -16
- package/dist/shared/utils/merge-themes.d.ts +41 -0
- package/dist/shared/utils/merge-themes.js +106 -0
- package/dist/shared/utils/normalize.d.ts +0 -10
- package/dist/shared/utils/normalize.js +0 -12
- package/dist/shared/utils/theme-config.d.ts +13 -4
- package/dist/shared/utils/theme-config.js +28 -13
- package/dist/shared/utils/theme-resolve.d.ts +19 -19
- package/dist/shared/utils/theme-resolve.js +25 -42
- package/dist/shared/utils/theme-resolver.d.ts +46 -0
- package/dist/shared/utils/theme-resolver.js +139 -0
- package/package.json +13 -10
- package/README-default.md +0 -84
- package/dist/runtime/plugin.d.ts +0 -2
- 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
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
90
|
+
It returns:
|
|
94
91
|
|
|
95
|
-
- `theme` β
|
|
96
|
-
- `
|
|
97
|
-
- `
|
|
98
|
-
- `
|
|
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
|
-
|
|
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
|
|
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="
|
|
121
|
+
<VenixThemeSwitcher label="Website color" />
|
|
109
122
|
</template>
|
|
110
123
|
```
|
|
111
124
|
|
|
112
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
202
|
+
### Seasonal themes
|
|
122
203
|
|
|
123
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
237
|
+
### Saving the theme (cookie consent)
|
|
135
238
|
|
|
136
|
-
|
|
239
|
+
Three cookies remember the user's choice between visits, for a year:
|
|
137
240
|
|
|
138
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
316
|
+
## Translation
|
|
208
317
|
|
|
209
|
-
|
|
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
|
-
|
|
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
|
-
|
|
327
|
+
The locale is detected in this order:
|
|
214
328
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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
|
-
|
|
347
|
+
### Integrating with a routing-based i18n module (e.g. `@nuxtjs/i18n`)
|
|
228
348
|
|
|
229
|
-
`
|
|
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
|
-
|
|
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
|
-
|
|
353
|
+
```ts
|
|
354
|
+
venixTheme: {
|
|
355
|
+
translation: {
|
|
356
|
+
manageHtmlLang: true,
|
|
357
|
+
},
|
|
358
|
+
}
|
|
359
|
+
```
|
|
234
360
|
|
|
235
|
-
|
|
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
|
-
|
|
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
|
|
385
|
+
<VenixIcon icon="<svg viewBox="0 0 24 24">...</svg>" />
|
|
386
|
+
<VenixIcon icon="π¨" />
|
|
246
387
|
</template>
|
|
247
388
|
```
|
|
248
389
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
"
|
|
444
|
+
"natal": {
|
|
303
445
|
"icon": {
|
|
304
|
-
"emote": "
|
|
305
|
-
"css": "mdi:
|
|
306
|
-
"svg": "line-md:
|
|
446
|
+
"emote": "π",
|
|
447
|
+
"css": "mdi:pine-tree-variant",
|
|
448
|
+
"svg": "line-md:star-filled"
|
|
307
449
|
}
|
|
308
450
|
}
|
|
309
451
|
```
|
|
310
452
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
467
|
+
## Typography
|
|
336
468
|
|
|
337
|
-
|
|
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
|
-
|
|
340
|
-
|
|
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
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
-
|
|
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
|
-
|
|
489
|
+
## Scrollbar
|
|
375
490
|
|
|
376
|
-
|
|
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
|
-
<
|
|
382
|
-
<
|
|
383
|
-
|
|
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
|
-
|
|
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
|
-
|
|
509
|
+
## Cursor
|
|
424
510
|
|
|
425
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
517
|
+
```typescript
|
|
430
518
|
venixTheme: {
|
|
431
|
-
|
|
432
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
535
|
+
## Vuetify
|
|
440
536
|
|
|
441
|
-
|
|
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
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|