@venix-sistemas/jade 1.0.1 โ 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 +237 -258
- package/dist/module.json +1 -1
- package/dist/module.mjs +9 -26
- package/dist/runtime/composables/useThemeLocale.js +10 -16
- package/dist/runtime/composables/useVenixTheme.js +19 -17
- package/dist/runtime/scripts/theme-init.js +34 -8
- package/dist/shared/css/colors.js +2 -2
- package/dist/shared/css/index.js +4 -4
- package/dist/shared/theme.json +3 -3
- package/dist/shared/types/colors.d.ts +5 -0
- package/dist/shared/utils/icon-refs.js +1 -1
- package/dist/shared/utils/icon.d.ts +2 -0
- package/dist/shared/utils/icon.js +2 -1
- package/dist/shared/utils/index.d.ts +2 -1
- package/dist/shared/utils/index.js +2 -1
- package/dist/shared/utils/load.js +4 -6
- package/dist/shared/utils/merge-themes.d.ts +11 -0
- package/dist/shared/utils/merge-themes.js +10 -0
- package/dist/shared/utils/normalize.d.ts +3 -2
- package/dist/shared/utils/theme-config.js +6 -4
- package/dist/shared/utils/theme-resolve.d.ts +8 -0
- package/dist/shared/utils/theme-resolve.js +39 -7
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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
|
-
<
|
|
78
|
-
|
|
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
|
-
|
|
79
|
+
It returns four groups:
|
|
94
80
|
|
|
95
|
-
- `theme` โ
|
|
96
|
-
- `
|
|
97
|
-
- `
|
|
98
|
-
- `
|
|
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
|
-
|
|
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
|
|
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,150 +101,163 @@ const { theme } = useVenixTheme()
|
|
|
109
101
|
</template>
|
|
110
102
|
```
|
|
111
103
|
|
|
112
|
-
|
|
113
|
-
|
|
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 |
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
123
|
+
Each option accepts `false` (disable), `true` (enable with defaults) or an object (enable and customize):
|
|
139
124
|
|
|
140
|
-
| Option |
|
|
141
|
-
| ------------- |
|
|
142
|
-
| `translation` | `
|
|
143
|
-
| `color` | `
|
|
144
|
-
| `scrollbar` | `
|
|
145
|
-
| `cursor` | `
|
|
146
|
-
| `typography` | `
|
|
147
|
-
| `
|
|
148
|
-
| `
|
|
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
|
|
153
|
-
|
|
|
154
|
-
| `locale`
|
|
155
|
-
| `defaultLocale
|
|
156
|
-
| `cookieSync`
|
|
157
|
-
| `manageHtmlLang` | `boolean` | `false` | Keep `<html lang>` in sync
|
|
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
|
-
|
|
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
|
|
164
|
-
|
|
|
165
|
-
| `apply`
|
|
166
|
-
| `defaultColor
|
|
167
|
-
| `themes`
|
|
168
|
-
| `iconFormat`
|
|
169
|
-
|
|
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`:
|
|
173
|
-
|
|
174
|
-
```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
|
-
})
|
|
185
|
-
```
|
|
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) |
|
|
186
154
|
|
|
187
|
-
`
|
|
155
|
+
#### `scrollbar`, `cursor` and `typography`
|
|
188
156
|
|
|
189
157
|
```typescript
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
+
],
|
|
203
180
|
},
|
|
204
181
|
}
|
|
205
182
|
```
|
|
206
183
|
|
|
207
|
-
|
|
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.
|
|
208
185
|
|
|
209
|
-
|
|
186
|
+
## Themes
|
|
210
187
|
|
|
211
|
-
|
|
188
|
+
The module ships with `dark`, `light` and the [seasonal themes](#seasonal-themes). `color.themes` extends that set:
|
|
212
189
|
|
|
213
|
-
|
|
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`.
|
|
214
192
|
|
|
215
193
|
```typescript
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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
|
+
},
|
|
223
207
|
},
|
|
224
|
-
}
|
|
208
|
+
}
|
|
225
209
|
```
|
|
226
210
|
|
|
227
|
-
|
|
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).
|
|
228
212
|
|
|
229
|
-
|
|
213
|
+
### Seasonal Themes
|
|
230
214
|
|
|
231
|
-
|
|
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.
|
|
232
216
|
|
|
233
|
-
|
|
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`):
|
|
234
218
|
|
|
235
|
-
|
|
219
|
+
```typescript
|
|
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
|
+
},
|
|
236
|
+
},
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The built-in Carnival theme uses `easter-65` to `easter-46`: 20 days, from the pre-Carnival weeks up to Ash Wednesday.
|
|
236
241
|
|
|
237
242
|
## Icons
|
|
238
243
|
|
|
239
|
-
`jade` installs and configures [`@nuxt/icon`](https://github.com/nuxt/icon)
|
|
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:
|
|
240
245
|
|
|
241
246
|
```vue
|
|
242
247
|
<template>
|
|
243
|
-
<VenixIcon icon="๐จ" />
|
|
244
248
|
<VenixIcon icon="line-md:home" />
|
|
245
|
-
<VenixIcon icon="<svg viewBox
|
|
249
|
+
<VenixIcon icon="<svg viewBox="0 0 24 24">...</svg>" />
|
|
250
|
+
<VenixIcon icon="๐จ" />
|
|
246
251
|
</template>
|
|
247
252
|
```
|
|
248
253
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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.
|
|
252
257
|
|
|
253
258
|
### Aliases
|
|
254
259
|
|
|
255
|
-
|
|
260
|
+
`icon.aliases` gives short names to any of the three formats:
|
|
256
261
|
|
|
257
262
|
```typescript
|
|
258
263
|
venixTheme: {
|
|
@@ -272,7 +277,11 @@ venixTheme: {
|
|
|
272
277
|
|
|
273
278
|
### Offline icon collections
|
|
274
279
|
|
|
275
|
-
|
|
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:
|
|
276
285
|
|
|
277
286
|
```typescript
|
|
278
287
|
venixTheme: {
|
|
@@ -282,21 +291,11 @@ venixTheme: {
|
|
|
282
291
|
}
|
|
283
292
|
```
|
|
284
293
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
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.
|
|
288
295
|
|
|
289
296
|
### Theme icons
|
|
290
297
|
|
|
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:
|
|
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:
|
|
300
299
|
|
|
301
300
|
```json
|
|
302
301
|
"light": {
|
|
@@ -308,21 +307,11 @@ Each color theme's `icon` (used by `useVenixTheme().themes` for things like a th
|
|
|
308
307
|
}
|
|
309
308
|
```
|
|
310
309
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
-
|
|
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>`:
|
|
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>`:
|
|
326
315
|
|
|
327
316
|
```vue
|
|
328
317
|
<VenixIcon
|
|
@@ -332,46 +321,18 @@ venixTheme: {
|
|
|
332
321
|
/>
|
|
333
322
|
```
|
|
334
323
|
|
|
335
|
-
## Themes
|
|
336
|
-
|
|
337
|
-
The module ships with a built-in set of color themes (`dark`, `light`, plus the [seasonal ones](#seasonal-themes)) and can be extended through `color.themes`, which does two different things depending on the key:
|
|
338
|
-
|
|
339
|
-
- An **existing** name (`dark`, `light`, or any seasonal one) overrides only the properties you give it, keeping the rest of that theme intact.
|
|
340
|
-
- A **new** name registers a theme that doesn't exist in the built-in set at all โ nothing further to opt into, it works the same as any built-in theme: real CSS variables, its own entry in `useVenixTheme().themes` (so it shows up in `<VenixThemeSwitcher>`), and Vuetify/UnoCSS integration if those are enabled. Useful for a theme specific to your project, e.g. a brand color scheme or a one-off campaign theme with no equivalent in the base set.
|
|
341
|
-
|
|
342
|
-
```typescript
|
|
343
|
-
color: {
|
|
344
|
-
themes: {
|
|
345
|
-
// Overrides an existing theme โ the rest of `dark` stays as shipped
|
|
346
|
-
dark: {
|
|
347
|
-
primary: '#FF6B6B',
|
|
348
|
-
},
|
|
349
|
-
|
|
350
|
-
// Registers a brand new one, project-specific โ 'summerSale' isn't a
|
|
351
|
-
// built-in theme name, so this doesn't override anything
|
|
352
|
-
summerSale: {
|
|
353
|
-
dark: false,
|
|
354
|
-
primary: '#FF8A00',
|
|
355
|
-
background: '#FFF8EE',
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
|
-
}
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
This is currently the only supported way to customize colors โ there's no option yet to load a completely custom theme file in place of the built-in one.
|
|
362
|
-
|
|
363
324
|
## Cookie Consent
|
|
364
325
|
|
|
365
|
-
|
|
326
|
+
Two cookies remember the user's choice between visits:
|
|
366
327
|
|
|
367
|
-
| Cookie
|
|
368
|
-
|
|
|
369
|
-
| `venix-theme-preference`
|
|
370
|
-
| `venix-theme-resolved`
|
|
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 |
|
|
371
332
|
|
|
372
|
-
Neither is written
|
|
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).)
|
|
373
334
|
|
|
374
|
-
Consent is read from `localStorage['venix-cookie-consent']
|
|
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:
|
|
375
336
|
|
|
376
337
|
```vue
|
|
377
338
|
<script setup lang="ts">
|
|
@@ -385,46 +346,43 @@ const { persistence } = useVenixTheme()
|
|
|
385
346
|
</template>
|
|
386
347
|
```
|
|
387
348
|
|
|
388
|
-
- `persistence.hasConsent` โ reactive `Ref<boolean>`,
|
|
389
|
-
- `persistence.grant()` โ records consent
|
|
390
|
-
- `persistence.revoke()` โ records the
|
|
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).
|
|
391
353
|
|
|
392
|
-
If you already have
|
|
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:
|
|
393
355
|
|
|
394
356
|
```ts
|
|
395
357
|
localStorage.setItem('venix-cookie-consent', JSON.stringify({ functionality: true }))
|
|
396
358
|
window.dispatchEvent(new Event('venix-cookie-preferences-updated'))
|
|
397
359
|
```
|
|
398
360
|
|
|
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
361
|
## Internationalization
|
|
402
362
|
|
|
403
|
-
The
|
|
363
|
+
The resolved locale translates the theme names (each theme's `translations`) and `<VenixThemeSwitcher>`'s own strings. It's detected in this order:
|
|
404
364
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
4. The `Accept-Language` header (SSR) / `navigator.language` (client)
|
|
411
|
-
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`
|
|
412
370
|
|
|
413
371
|
### Using your own translations
|
|
414
372
|
|
|
415
|
-
`
|
|
373
|
+
`locale.translate()` applies the same matching and fallbacks to your own strings:
|
|
416
374
|
|
|
417
375
|
```ts
|
|
418
376
|
const { locale } = useVenixTheme()
|
|
419
377
|
|
|
420
|
-
locale.translate({ 'en-US': 'Hello', 'pt-BR': 'Olรก' }, 'Hello') //
|
|
378
|
+
locale.translate({ 'en-US': 'Hello', 'pt-BR': 'Olรก' }, 'Hello') // second argument: fallback
|
|
421
379
|
```
|
|
422
380
|
|
|
423
381
|
### Integrating with a routing-based i18n module (e.g. `@nuxtjs/i18n`)
|
|
424
382
|
|
|
425
|
-
`translation.cookieSync` defaults to `'i18n_redirected'
|
|
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.
|
|
426
384
|
|
|
427
|
-
|
|
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):
|
|
428
386
|
|
|
429
387
|
```ts
|
|
430
388
|
venixTheme: {
|
|
@@ -434,41 +392,62 @@ venixTheme: {
|
|
|
434
392
|
}
|
|
435
393
|
```
|
|
436
394
|
|
|
437
|
-
|
|
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.
|
|
438
396
|
|
|
439
|
-
##
|
|
397
|
+
## UnoCSS integration
|
|
440
398
|
|
|
441
|
-
|
|
399
|
+
Add the preset to your `uno.config.ts` to use the theme colors as utilities (`text-primary`, `bg-background2`, `border-accent`, โฆ):
|
|
442
400
|
|
|
443
|
-
|
|
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.
|
|
415
|
+
|
|
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.
|
|
417
|
+
|
|
418
|
+
## Vuetify integration
|
|
419
|
+
|
|
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:
|
|
444
421
|
|
|
445
422
|
```typescript
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
background: '#000000',
|
|
454
|
-
},
|
|
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,
|
|
455
430
|
},
|
|
456
|
-
}
|
|
431
|
+
})
|
|
457
432
|
```
|
|
458
433
|
|
|
459
|
-
|
|
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.
|
|
460
439
|
|
|
461
|
-
|
|
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.
|
|
462
441
|
|
|
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 |
|
|
442
|
+
## Development
|
|
470
443
|
|
|
471
|
-
|
|
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 |
|
|
472
451
|
|
|
473
452
|
## Brand
|
|
474
453
|
|