@innertia-solutions/innertia-nuxt 0.1.3 → 0.1.4

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
@@ -25,8 +25,11 @@ export default defineNuxtConfig({
25
25
  mode: 'saas', // 'saas' (default) | 'app'
26
26
 
27
27
  branding: { name: 'MyApp', version: '1.0.0' },
28
+ // Tema Preline — define el "feel" completo (paleta neutral, dark mode tone).
29
+ // Ver https://preline.co/docs/themes.html
30
+ theme: 'moon', // 'default' | 'harvest' | 'retro' | 'ocean' | 'autumn' | 'moon' | 'bubblegum' | 'cashmere' | 'olive'
31
+ // Override del brand color del tema
28
32
  colors: { primary: 'violet', secondary: 'slate' },
29
- darkTone: 'slate', // 'neutral' (default) | 'slate' | 'gray' | 'zinc' | 'stone'
30
33
 
31
34
  apps: {
32
35
  backoffice: {
package/app.config.ts CHANGED
@@ -30,30 +30,41 @@ export default defineAppConfig({
30
30
  },
31
31
 
32
32
  /**
33
- * Colores primario y secundario. Acepta:
33
+ * Tema Preline. Cada tema define el "feel" completo (paleta neutral, fondos,
34
+ * bordes, sombras) tanto en light como en dark mode. Es el equivalente a
35
+ * "darkTone" pero más expresivo — distintos temas tienen distintos tonos.
36
+ *
37
+ * Cada tema viene con un brand color default (puedes overridearlo con `colors.primary`):
38
+ * - 'default' → blue (neutral, profesional)
39
+ * - 'harvest' → amber (cálido, tierra)
40
+ * - 'retro' → fuchsia (vibrante, ochenta)
41
+ * - 'ocean' → cyan (frío, acuático)
42
+ * - 'autumn' → yellow (otoñal)
43
+ * - 'moon' → gray (gris, dark-friendly elegante)
44
+ * - 'bubblegum' → pink (suave, juvenil)
45
+ * - 'cashmere' → mauve (cálido morado)
46
+ * - 'olive' → avocado (verde tierra)
47
+ *
48
+ * Ver https://preline.co/docs/themes.html para preview de cada uno.
49
+ */
50
+ theme: 'default' as PrelineTheme,
51
+
52
+ /**
53
+ * Colores primario y secundario. Overridean el brand color default del tema.
54
+ * Acepta:
34
55
  * - Nombre de color de Tailwind (string): 'violet', 'indigo', 'emerald', etc.
35
56
  * - Scale custom (object): { 50: '#f5f3ff', ..., 950: '#2e1065' }
36
57
  *
58
+ * Si no se declara, se usa el brand color default del `theme` elegido.
59
+ *
37
60
  * El plugin `colors` aplica estos valores a las CSS vars `--primary-{50..950}`
38
61
  * y `--secondary-{50..950}` en SSR y cliente.
39
62
  */
40
63
  colors: {
41
- primary: 'blue' as ColorOption,
42
- secondary: 'slate' as ColorOption,
64
+ primary: undefined as ColorOption | undefined,
65
+ secondary: undefined as ColorOption | undefined,
43
66
  },
44
67
 
45
- /**
46
- * Tono neutral usado en modo dark (backgrounds, borders, surfaces).
47
- * Cambia el "feel" del modo oscuro sin tocar el color de marca.
48
- *
49
- * - 'neutral' (default) → gris puro, neutral
50
- * - 'slate' → gris con leve tinte azul (más frío)
51
- * - 'gray' → gris levemente más cálido que slate
52
- * - 'zinc' → gris cálido
53
- * - 'stone' → gris muy cálido (con tinte tierra)
54
- */
55
- darkTone: 'neutral' as DarkTone,
56
-
57
68
  /**
58
69
  * Contenido del panel marketing del layout `auth`. Si no se declara, el panel queda vacío.
59
70
  */
@@ -120,8 +131,17 @@ export type AppMobileMode = 'allow' | 'block' | 'redirect'
120
131
  export type ColorScale = Partial<Record<50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950, string>>
121
132
  export type ColorOption = string | ColorScale
122
133
 
123
- /** Tono neutral usado en modo dark debe ser una paleta gris de Tailwind. */
124
- export type DarkTone = 'neutral' | 'slate' | 'gray' | 'zinc' | 'stone'
134
+ /** Temas Preline disponibles cada uno define un "feel" completo (light + dark). */
135
+ export type PrelineTheme =
136
+ | 'default' // blue
137
+ | 'harvest' // amber
138
+ | 'retro' // fuchsia
139
+ | 'ocean' // cyan
140
+ | 'autumn' // yellow
141
+ | 'moon' // gray
142
+ | 'bubblegum' // pink
143
+ | 'cashmere' // mauve
144
+ | 'olive' // avocado
125
145
 
126
146
  /** Proveedor OAuth — slug del provider (matchea con backend SocialAuthController). */
127
147
  export type OAuthProvider = 'google' | 'microsoft' | 'apple' | 'github'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innertia-solutions/innertia-nuxt",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Innertia Solutions — Nuxt layer unificada: core, auth, multitenancy, theme y app contexts",
5
5
  "keywords": [
6
6
  "nuxt",
package/plugins/colors.ts CHANGED
@@ -1,39 +1,42 @@
1
- import type { ColorOption, ColorScale, DarkTone } from '../app.config'
1
+ import type { ColorOption, ColorScale, PrelineTheme } from '../app.config'
2
2
 
3
3
  const SCALE_LEVELS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950] as const
4
4
 
5
5
  /**
6
- * Aplica las CSS vars de theming desde `appConfig.innertia`:
7
- * - `colors.primary` y `colors.secondary` → --primary-{50..950}, --secondary-{50..950}
8
- * - `darkTone` reemplaza el neutral default en modo dark (backgrounds, borders, surfaces)
6
+ * Aplica el theming completo desde `appConfig.innertia`:
7
+ * - `theme` setea `data-theme="theme-{name}"` en <html> (Preline themes)
8
+ * - `colors.primary` override del brand color del tema --primary-{50..950}
9
+ * - `colors.secondary` → --secondary-{50..950}
9
10
  *
10
- * Funciona en SSR (inyecta <style> en head) y cliente.
11
+ * Funciona en SSR (inyecta <style> + htmlAttrs en head) y cliente.
11
12
  *
12
- * colors acepta:
13
+ * `colors.primary/secondary` acepta:
13
14
  * - Nombre Tailwind: 'violet' → mapea a var(--color-violet-50..950)
14
15
  * - Scale custom: { 50: '#f5f3ff', ..., 950: '#2e1065' }
15
16
  *
16
- * darkTone acepta:
17
- * 'neutral' | 'slate' | 'gray' | 'zinc' | 'stone'
17
+ * El "tono dark" se controla via `theme` — cada tema Preline incluye su propia
18
+ * paleta neutral para light y dark. Ej. `theme: 'moon'` da un dark grisáceo elegante.
18
19
  */
19
20
  export default defineNuxtPlugin(() => {
20
21
  const appConfig = useAppConfig()
22
+ const theme = appConfig.innertia?.theme as PrelineTheme | undefined
21
23
  const colors = appConfig.innertia?.colors as { primary?: ColorOption; secondary?: ColorOption } | undefined
22
- const darkTone = appConfig.innertia?.darkTone as DarkTone | undefined
23
24
 
24
- const css: string[] = []
25
-
26
- if (colors) css.push(buildColorCSS(colors))
27
- // Solo aplicar override si el producto eligió algo distinto del default
28
- if (darkTone && darkTone !== 'neutral') css.push(buildDarkToneCSS(darkTone))
25
+ // ── Aplicar tema Preline via data-theme ─────────────────────────────────
26
+ if (theme && theme !== 'default') {
27
+ useHead({ htmlAttrs: { 'data-theme': `theme-${theme}` } })
28
+ }
29
29
 
30
- if (css.length === 0) return
30
+ // ── Aplicar overrides de primary/secondary via <style> ───────────────────
31
+ if (!colors || (!colors.primary && !colors.secondary)) return
32
+ const css = buildColorCSS(colors)
33
+ if (!css) return
31
34
 
32
35
  useHead({
33
36
  style: [
34
37
  {
35
38
  id: 'innertia-colors',
36
- children: css.join('\n'),
39
+ children: css,
37
40
  },
38
41
  ],
39
42
  })
@@ -53,63 +56,6 @@ function buildColorCSS(colors: { primary?: ColorOption; secondary?: ColorOption
53
56
  return lines.join('\n')
54
57
  }
55
58
 
56
- /**
57
- * Genera overrides para modo dark reemplazando el `neutral` default por el tono elegido.
58
- * Cubre backgrounds, foregrounds, borders, layers, surfaces y cards — todos los lugares
59
- * donde el theme.css base usa `--color-neutral-*` en `.dark`.
60
- *
61
- * Por especificidad, `.dark` aquí gana sobre `.dark` en theme.css porque se inyecta
62
- * después en el head (last-declared wins).
63
- */
64
- function buildDarkToneCSS(tone: DarkTone): string {
65
- return `.dark {
66
- --background: var(--color-${tone}-800);
67
- --background-1: var(--color-${tone}-900);
68
- --background-2: var(--color-${tone}-900);
69
- --background-plain: var(--color-${tone}-950);
70
- --foreground: var(--color-${tone}-200);
71
- --foreground-inverse: var(--color-white);
72
- --inverse: var(--color-${tone}-950);
73
- --border: var(--color-${tone}-700);
74
- --border-line-1: var(--color-${tone}-800);
75
- --border-line-2: var(--color-${tone}-700);
76
- --border-line-3: var(--color-${tone}-600);
77
- --layer: var(--color-${tone}-800);
78
- --layer-line: var(--color-${tone}-700);
79
- --layer-hover: var(--color-${tone}-700);
80
- --layer-focus: var(--color-${tone}-700);
81
- --layer-active: var(--color-${tone}-700);
82
- --surface: var(--color-${tone}-700);
83
- --surface-1: var(--color-${tone}-600);
84
- --surface-2: var(--color-${tone}-500);
85
- --surface-3: var(--color-${tone}-600);
86
- --muted: var(--color-${tone}-700);
87
- --muted-foreground: var(--color-${tone}-400);
88
- --muted-foreground-1: var(--color-${tone}-300);
89
- --muted-hover: var(--color-${tone}-600);
90
- --card: var(--color-${tone}-800);
91
- --card-line: var(--color-${tone}-700);
92
- --card-divider: var(--color-${tone}-700);
93
- --card-header: var(--color-${tone}-700);
94
- --card-footer: var(--color-${tone}-700);
95
- --dropdown: var(--color-${tone}-800);
96
- --dropdown-line: var(--color-${tone}-700);
97
- --dropdown-divider: var(--color-${tone}-700);
98
- --dropdown-item-hover: var(--color-${tone}-700);
99
- --dropdown-item-foreground: var(--color-${tone}-200);
100
- --tooltip: var(--color-${tone}-100);
101
- --tooltip-foreground: var(--color-${tone}-900);
102
- --navbar: var(--color-${tone}-900);
103
- --navbar-line: var(--color-${tone}-800);
104
- --navbar-divider: var(--color-${tone}-800);
105
- --navbar-nav-foreground: var(--color-${tone}-300);
106
- --navbar-nav-hover: var(--color-${tone}-800);
107
- --navbar-nav-active: var(--color-${tone}-700);
108
- --sidebar: var(--color-${tone}-900);
109
- --sidebar-line: var(--color-${tone}-800);
110
- }`
111
- }
112
-
113
59
  function buildRoleVars(role: 'primary' | 'secondary', value: ColorOption): string[] {
114
60
  const out: string[] = []
115
61
 
@@ -1,7 +0,0 @@
1
- export default defineNuxtPlugin(() => {
2
- const appConfig = useAppConfig() as { spark?: { theme?: string } }
3
- const theme = appConfig.spark?.theme
4
- if (theme && theme !== 'default') {
5
- document.documentElement.setAttribute('data-theme', `theme-${theme}`)
6
- }
7
- })