@seta-labs/nuxt-foundation 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/app/apps.ts +33 -0
  2. package/app/assets/shell.css +190 -0
  3. package/app/components/FoundationBarra.vue +42 -0
  4. package/app/components/FoundationLauncher.vue +54 -0
  5. package/app/components/FoundationMenu.vue +30 -0
  6. package/app/components/FoundationStato.vue +16 -0
  7. package/app/components/FoundationUtente.vue +48 -0
  8. package/app/composables/useFoundation.ts +66 -0
  9. package/app/composables/usePopover.ts +50 -0
  10. package/app/layouts/default.vue +43 -0
  11. package/app/utils/app-link.ts +6 -0
  12. package/app.config.ts +22 -0
  13. package/design-system/README.md +77 -0
  14. package/design-system/assets/App/README.md +4 -0
  15. package/design-system/assets/Icone/README.md +6 -0
  16. package/design-system/assets/Icone/i-aggiungi.svg +1 -0
  17. package/design-system/assets/Icone/i-altro.svg +1 -0
  18. package/design-system/assets/Icone/i-app-agency.svg +1 -0
  19. package/design-system/assets/Icone/i-app-geo.svg +1 -0
  20. package/design-system/assets/Icone/i-app-immo.svg +1 -0
  21. package/design-system/assets/Icone/i-app-infra.svg +1 -0
  22. package/design-system/assets/Icone/i-app-proxy.svg +1 -0
  23. package/design-system/assets/Icone/i-app-spid.svg +1 -0
  24. package/design-system/assets/Icone/i-app.svg +1 -0
  25. package/design-system/assets/Icone/i-attenzione.svg +1 -0
  26. package/design-system/assets/Icone/i-automazione.svg +1 -0
  27. package/design-system/assets/Icone/i-cerca.svg +1 -0
  28. package/design-system/assets/Icone/i-check.svg +1 -0
  29. package/design-system/assets/Icone/i-chiudi.svg +1 -0
  30. package/design-system/assets/Icone/i-crescita.svg +1 -0
  31. package/design-system/assets/Icone/i-direzione.svg +1 -0
  32. package/design-system/assets/Icone/i-documento.svg +1 -0
  33. package/design-system/assets/Icone/i-filtro.svg +1 -0
  34. package/design-system/assets/Icone/i-freccia.svg +1 -0
  35. package/design-system/assets/Icone/i-guida.svg +1 -0
  36. package/design-system/assets/Icone/i-ia.svg +1 -0
  37. package/design-system/assets/Icone/i-impostazioni.svg +1 -0
  38. package/design-system/assets/Icone/i-info.svg +1 -0
  39. package/design-system/assets/Icone/i-mail.svg +1 -0
  40. package/design-system/assets/Icone/i-notifiche.svg +1 -0
  41. package/design-system/assets/Icone/i-sito.svg +1 -0
  42. package/design-system/assets/Icone/i-sviluppo.svg +1 -0
  43. package/design-system/assets/Marchio/README.md +8 -0
  44. package/design-system/assets/Marchio/favicon.svg +5 -0
  45. package/design-system/assets/Marchio/logo-dark-stretto.png +0 -0
  46. package/design-system/assets/Marchio/logo-light-stretto.png +0 -0
  47. package/design-system/components/Avviso/README.md +8 -0
  48. package/design-system/components/Avviso/preview.html +17 -0
  49. package/design-system/components/Barra/README.md +8 -0
  50. package/design-system/components/Barra/preview.html +24 -0
  51. package/design-system/components/BarraStato/README.md +7 -0
  52. package/design-system/components/BarraStato/preview.html +12 -0
  53. package/design-system/components/Bottone/README.md +12 -0
  54. package/design-system/components/Bottone/preview.html +15 -0
  55. package/design-system/components/Campo/README.md +9 -0
  56. package/design-system/components/Campo/preview.html +20 -0
  57. package/design-system/components/Card/README.md +9 -0
  58. package/design-system/components/Card/preview.html +13 -0
  59. package/design-system/components/Cover/preview.html +50 -0
  60. package/design-system/components/Dialog/README.md +8 -0
  61. package/design-system/components/Dialog/preview.html +12 -0
  62. package/design-system/components/Etichetta/README.md +8 -0
  63. package/design-system/components/Etichetta/preview.html +12 -0
  64. package/design-system/components/Launcher/README.md +9 -0
  65. package/design-system/components/Launcher/preview.html +12 -0
  66. package/design-system/components/Lettura/README.md +8 -0
  67. package/design-system/components/Lettura/preview.html +12 -0
  68. package/design-system/components/Menu/README.md +9 -0
  69. package/design-system/components/Menu/preview.html +17 -0
  70. package/design-system/components/Tabella/README.md +9 -0
  71. package/design-system/components/Tabella/preview.html +16 -0
  72. package/design-system/components/Targa/README.md +7 -0
  73. package/design-system/components/Targa/preview.html +12 -0
  74. package/design-system/components/Tessera/README.md +9 -0
  75. package/design-system/components/Tessera/preview.html +12 -0
  76. package/design-system/components/Toast/README.md +7 -0
  77. package/design-system/components/Toast/preview.html +12 -0
  78. package/design-system/components/Vuoto/README.md +7 -0
  79. package/design-system/components/Vuoto/preview.html +12 -0
  80. package/design-system/components/bundle.css +238 -0
  81. package/design-system/design-system.json +361 -0
  82. package/design-system/tokens.css +102 -0
  83. package/design-system/tokens.json +111 -0
  84. package/design-system/vue/SfIcona.vue +17 -0
  85. package/design-system/vue/SfTessera.vue +20 -0
  86. package/design-system/vue/icons.ts +32 -0
  87. package/nuxt.config.ts +36 -0
  88. package/package.json +45 -0
package/app/apps.ts ADDED
@@ -0,0 +1,33 @@
1
+ import type { IconName } from '../design-system/vue/icons';
2
+
3
+ // Registry of the Seta Foundation suite. Adding an app = one entry here, its
4
+ // `--app-<id>` token and `app-<id>` glyph in the design system, a release.
5
+ // `app`: a Nuxt UI that mounts the shell. `tool`: an external UI, opened in a
6
+ // new tab without the shell. URLs are production only: there is no staging and
7
+ // the other apps do not run locally.
8
+ export const foundationApps = [
9
+ { id: 'agency', name: 'Agency', kind: 'app', url: 'https://agency.setalabs.it' },
10
+ { id: 'proxy', name: 'Proxy', kind: 'app', url: 'https://proxy.setalabs.it' },
11
+ { id: 'infra', name: 'Infra', kind: 'tool', url: 'https://argocd.setalabs.it' },
12
+ ] as const satisfies readonly FoundationAppEntry[];
13
+
14
+ export type FoundationAppKind = 'app' | 'tool';
15
+
16
+ export interface FoundationAppEntry {
17
+ id: string;
18
+ name: string;
19
+ kind: FoundationAppKind;
20
+ url: string;
21
+ }
22
+
23
+ export type FoundationApp = (typeof foundationApps)[number];
24
+ export type FoundationAppId = FoundationApp['id'];
25
+ export type ShellAppId = Extract<FoundationApp, { kind: 'app' }>['id'];
26
+
27
+ export function appGlyph(id: FoundationAppId): IconName {
28
+ return `app-${id}`;
29
+ }
30
+
31
+ export function findApp(id: string): FoundationApp | undefined {
32
+ return foundationApps.find((app) => app.id === id);
33
+ }
@@ -0,0 +1,190 @@
1
+ /* Shell layout on top of the design system classes (bundle.css). Token values only. */
2
+
3
+ html,
4
+ body {
5
+ margin: 0;
6
+ background: var(--bg);
7
+ }
8
+
9
+ .sf-shell {
10
+ display: grid;
11
+ grid-template-rows: var(--shell-barra) minmax(0, 1fr) var(--shell-stato);
12
+ grid-template-columns: minmax(0, 1fr);
13
+ height: 100dvh;
14
+ }
15
+
16
+ .sf-shell__barra {
17
+ position: relative;
18
+ z-index: 20;
19
+ }
20
+
21
+ .sf-shell__marchio {
22
+ display: flex;
23
+ align-items: center;
24
+ }
25
+
26
+ .sf-shell__corpo {
27
+ display: flex;
28
+ min-height: 0;
29
+ }
30
+
31
+ .sf-shell__menu {
32
+ flex-shrink: 0;
33
+ overflow-y: auto;
34
+ }
35
+
36
+ .sf-shell__slot {
37
+ flex: 1;
38
+ min-width: 0;
39
+ overflow-y: auto;
40
+ padding: var(--s-6);
41
+ }
42
+
43
+ .sf-shell__briciole {
44
+ margin-bottom: var(--s-5);
45
+ }
46
+
47
+ .sf-shell__apri-menu,
48
+ .sf-shell__velo {
49
+ display: none;
50
+ }
51
+
52
+ /* --- overlays: launcher and user panel --------------------------- */
53
+ .sf-launcher-ancora,
54
+ .sf-utente-ancora {
55
+ position: relative;
56
+ }
57
+
58
+ .sf-launcher-ancora .sf-launcher {
59
+ position: absolute;
60
+ top: calc(100% + var(--s-2));
61
+ left: var(--s-2);
62
+ width: min(400px, calc(100vw - var(--s-4)));
63
+ animation: sf-entrata var(--d-ampio) var(--e-entrata);
64
+ }
65
+
66
+ .sf-avatar--bottone {
67
+ font: inherit;
68
+ font-size: 11px;
69
+ font-weight: 600;
70
+ letter-spacing: 0.08em;
71
+ cursor: pointer;
72
+ }
73
+
74
+ .sf-avatar--bottone:hover,
75
+ .sf-avatar--bottone[aria-expanded='true'] {
76
+ border-color: var(--accent);
77
+ }
78
+
79
+ .sf-utente {
80
+ position: absolute;
81
+ top: calc(100% + var(--s-3));
82
+ right: 0;
83
+ width: min(280px, calc(100vw - var(--s-4)));
84
+ display: flex;
85
+ flex-direction: column;
86
+ gap: var(--s-1);
87
+ padding: var(--s-2);
88
+ background: var(--surface);
89
+ border: 1px solid var(--border-forte);
90
+ border-radius: var(--r-lg);
91
+ box-shadow: var(--ombra-sovrapposto);
92
+ animation: sf-entrata var(--d-ampio) var(--e-entrata);
93
+ }
94
+
95
+ .sf-utente__chi {
96
+ display: flex;
97
+ flex-direction: column;
98
+ gap: 2px;
99
+ padding: var(--s-2) var(--s-3) var(--s-3);
100
+ border-bottom: 1px solid var(--border);
101
+ margin-bottom: var(--s-1);
102
+ }
103
+
104
+ .sf-utente__nome {
105
+ font-weight: 600;
106
+ overflow-wrap: anywhere;
107
+ }
108
+
109
+ .sf-utente__email {
110
+ font-size: 13px;
111
+ color: var(--muted);
112
+ overflow-wrap: anywhere;
113
+ }
114
+
115
+ .sf-utente__voce {
116
+ display: flex;
117
+ align-items: center;
118
+ min-height: 40px;
119
+ padding: 0 var(--s-3);
120
+ border: 0;
121
+ border-radius: var(--r-sm);
122
+ background: transparent;
123
+ color: var(--fg);
124
+ font: inherit;
125
+ font-weight: 500;
126
+ text-align: left;
127
+ text-decoration: none;
128
+ cursor: pointer;
129
+ }
130
+
131
+ .sf-utente__voce:hover {
132
+ background: var(--surface-2);
133
+ }
134
+
135
+ @keyframes sf-entrata {
136
+ from {
137
+ opacity: 0;
138
+ transform: translateY(-4px);
139
+ }
140
+ }
141
+
142
+ /* --- narrow screens: the side menu becomes a drawer -------------- */
143
+ @media (max-width: 900px) {
144
+ .sf-shell__apri-menu {
145
+ display: inline-flex;
146
+ }
147
+
148
+ .sf-shell__menu {
149
+ position: fixed;
150
+ top: var(--shell-barra);
151
+ bottom: 0;
152
+ left: 0;
153
+ z-index: 10;
154
+ width: min(var(--shell-menu), 85vw);
155
+ box-shadow: var(--ombra-sovrapposto);
156
+ transform: translateX(-100%);
157
+ visibility: hidden;
158
+ transition:
159
+ transform var(--d-rapido) var(--e-uscita),
160
+ visibility 0s linear var(--d-rapido);
161
+ }
162
+
163
+ .sf-shell__velo {
164
+ display: block;
165
+ position: fixed;
166
+ inset: var(--shell-barra) 0 0;
167
+ z-index: 9;
168
+ }
169
+
170
+ .sf-shell__menu--aperto {
171
+ transform: none;
172
+ visibility: visible;
173
+ transition: transform var(--d-ampio) var(--e-entrata);
174
+ }
175
+
176
+ .sf-shell__slot {
177
+ padding: var(--s-5) var(--s-4);
178
+ }
179
+ }
180
+
181
+ @media (max-width: 640px) {
182
+ .sf-shell__marchio,
183
+ .sf-shell__sep {
184
+ display: none;
185
+ }
186
+
187
+ .sf-barra {
188
+ gap: var(--s-2);
189
+ }
190
+ }
@@ -0,0 +1,42 @@
1
+ <script setup lang="ts">
2
+ import logoNotte from '../../design-system/assets/Marchio/logo-dark-stretto.png';
3
+ import logoGiorno from '../../design-system/assets/Marchio/logo-light-stretto.png';
4
+
5
+ defineProps<{ menuOpen: boolean }>();
6
+ defineEmits<{ toggleMenu: [] }>();
7
+
8
+ const app = useFoundationApp();
9
+ const hasNav = useFoundationNav().length > 0;
10
+ const dev = import.meta.dev;
11
+ </script>
12
+
13
+ <template>
14
+ <header class="sf-barra sf-shell__barra">
15
+ <FoundationLauncher />
16
+ <NuxtLink to="/" class="sf-shell__marchio" aria-label="Seta Labs, torna all'inizio">
17
+ <img class="sf-marchio sf-solo-notte" :src="logoNotte" alt="" />
18
+ <img class="sf-marchio sf-solo-giorno" :src="logoGiorno" alt="" />
19
+ </NuxtLink>
20
+ <template v-if="app">
21
+ <span class="sf-barra__sep sf-shell__sep" />
22
+ <NuxtLink to="/" class="sf-barra__app">
23
+ <SfTessera :app="app.id" :size="32" />
24
+ {{ app.name }}
25
+ </NuxtLink>
26
+ </template>
27
+ <span class="sf-barra__spazio" />
28
+ <span v-if="dev" class="sf-ambiente sf-ambiente--staging">DEV</span>
29
+ <FoundationUtente />
30
+ <button
31
+ v-if="hasNav"
32
+ class="sf-btn sf-btn--icona sf-shell__apri-menu"
33
+ type="button"
34
+ aria-controls="sf-menu"
35
+ :aria-expanded="menuOpen"
36
+ :aria-label="menuOpen ? 'Chiudi il menu' : 'Apri il menu'"
37
+ @click="$emit('toggleMenu')"
38
+ >
39
+ <SfIcona :name="menuOpen ? 'chiudi' : 'altro'" />
40
+ </button>
41
+ </header>
42
+ </template>
@@ -0,0 +1,54 @@
1
+ <script setup lang="ts">
2
+ import { foundationApps, type FoundationApp } from '../apps';
3
+
4
+ const current = useFoundationApp();
5
+ const trigger = ref<HTMLElement | null>(null);
6
+ const panel = ref<HTMLElement | null>(null);
7
+ const { open, toggle } = usePopover(trigger, panel);
8
+
9
+ // The current app links to its own root, so the launcher works locally too.
10
+ const href = (app: FoundationApp): string => (app.id === current.value?.id ? '/' : app.url);
11
+ const isTool = (app: FoundationApp): boolean => app.kind === 'tool';
12
+ </script>
13
+
14
+ <template>
15
+ <div class="sf-launcher-ancora">
16
+ <button
17
+ ref="trigger"
18
+ class="sf-barra__launcher"
19
+ type="button"
20
+ aria-label="Apri le app"
21
+ aria-haspopup="dialog"
22
+ :aria-expanded="open"
23
+ @click="toggle"
24
+ >
25
+ <SfIcona name="app" />
26
+ </button>
27
+ <div
28
+ v-if="open"
29
+ ref="panel"
30
+ class="sf-launcher"
31
+ role="dialog"
32
+ aria-label="App Seta Foundation"
33
+ >
34
+ <div class="sf-targa__riga">
35
+ <b>App</b><span>Seta Foundation</span><span class="sf-targa__filetto" />
36
+ <span>{{ String(foundationApps.length).padStart(2, '0') }}</span>
37
+ </div>
38
+ <div class="sf-launcher__griglia">
39
+ <a
40
+ v-for="app in foundationApps"
41
+ :key="app.id"
42
+ class="sf-launcher__app"
43
+ :href="href(app)"
44
+ :aria-current="app.id === current?.id ? 'page' : undefined"
45
+ :target="isTool(app) ? '_blank' : undefined"
46
+ :rel="isTool(app) ? 'noopener' : undefined"
47
+ >
48
+ <SfTessera :app="app.id" />
49
+ {{ app.name }}
50
+ </a>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ </template>
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ defineProps<{ open: boolean }>();
3
+
4
+ const nav = useFoundationNav();
5
+ const app = useFoundationApp();
6
+ const active = useActiveNav();
7
+ </script>
8
+
9
+ <template>
10
+ <nav
11
+ v-if="nav.length"
12
+ id="sf-menu"
13
+ class="sf-menu sf-shell__menu"
14
+ :class="{ 'sf-shell__menu--aperto': open }"
15
+ :aria-label="app?.name ?? 'Menu'"
16
+ >
17
+ <div class="sf-menu__gruppo">
18
+ <NuxtLink
19
+ v-for="item in nav"
20
+ :key="item.to"
21
+ :to="item.to"
22
+ class="sf-menu__voce"
23
+ :aria-current="item === active ? 'page' : undefined"
24
+ >
25
+ <SfIcona :name="item.icon" />
26
+ {{ item.label }}
27
+ </NuxtLink>
28
+ </div>
29
+ </nav>
30
+ </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ const { foundationVersion } = useRuntimeConfig().public;
3
+ const app = useFoundationApp();
4
+ </script>
5
+
6
+ <template>
7
+ <footer class="sf-stato sf-shell__stato">
8
+ <span>
9
+ Seta Foundation <b>shell {{ foundationVersion }}</b>
10
+ </span>
11
+ <span class="sf-barra__spazio" />
12
+ <span v-if="app">
13
+ App <b>{{ app.id }}</b>
14
+ </span>
15
+ </footer>
16
+ </template>
@@ -0,0 +1,48 @@
1
+ <script setup lang="ts">
2
+ const user = useCurrentUser();
3
+ const { theme, toggle: toggleTheme } = useFoundationTheme();
4
+ const trigger = ref<HTMLElement | null>(null);
5
+ const panel = ref<HTMLElement | null>(null);
6
+ const { open, toggle } = usePopover(trigger, panel);
7
+
8
+ const label = computed(() => user.value?.name ?? user.value?.email ?? 'Utente non identificato');
9
+ const initials = computed(() => {
10
+ const source = user.value?.name ?? user.value?.email.split('@')[0];
11
+ if (!source) return '?';
12
+ const words = source.split(/[\s._-]+/).filter(Boolean);
13
+ return words
14
+ .slice(0, 2)
15
+ .map((word) => word[0])
16
+ .join('')
17
+ .toUpperCase();
18
+ });
19
+ const nextTheme = computed(() => (theme.value === 'notte' ? 'giorno' : 'notte'));
20
+ </script>
21
+
22
+ <template>
23
+ <div class="sf-utente-ancora">
24
+ <button
25
+ ref="trigger"
26
+ class="sf-avatar sf-avatar--bottone"
27
+ type="button"
28
+ :aria-label="`Menu utente: ${label}`"
29
+ :aria-expanded="open"
30
+ @click="toggle"
31
+ >
32
+ {{ initials }}
33
+ </button>
34
+ <div v-if="open" ref="panel" class="sf-utente" role="group" :aria-label="label">
35
+ <div class="sf-utente__chi">
36
+ <span class="sf-utente__nome">{{ label }}</span>
37
+ <span v-if="user?.name" class="sf-utente__email">{{ user.email }}</span>
38
+ <span v-if="!user" class="sf-utente__email"
39
+ >Accesso gestito da Cloudflare Access</span
40
+ >
41
+ </div>
42
+ <button class="sf-utente__voce" type="button" @click="toggleTheme">
43
+ Passa al tema {{ nextTheme }}
44
+ </button>
45
+ <a v-if="user" class="sf-utente__voce" href="/cdn-cgi/access/logout">Esci</a>
46
+ </div>
47
+ </div>
48
+ </template>
@@ -0,0 +1,66 @@
1
+ import { findApp, type FoundationApp } from '../apps';
2
+ import type { FoundationNavItem } from '../../app.config';
3
+
4
+ export type FoundationTheme = 'notte' | 'giorno';
5
+
6
+ export interface FoundationUser {
7
+ email: string;
8
+ name?: string;
9
+ }
10
+
11
+ /** The registry entry of the app hosting the shell, from `public.foundationApp`. */
12
+ export function useFoundationApp(): ComputedRef<FoundationApp | undefined> {
13
+ const config = useRuntimeConfig();
14
+ return computed(() => findApp(config.public.foundationApp));
15
+ }
16
+
17
+ /** The side menu the host declares under `foundation.nav` in its app.config. */
18
+ export function useFoundationNav(): FoundationNavItem[] {
19
+ // The resolved app config type widens `icon` to string; the input type checks it.
20
+ return useAppConfig().foundation.nav as FoundationNavItem[];
21
+ }
22
+
23
+ /** The side-menu entry matching the current route, nested paths included. */
24
+ export function useActiveNav(): ComputedRef<FoundationNavItem | undefined> {
25
+ const route = useRoute();
26
+ const nav = useFoundationNav();
27
+ return computed(() =>
28
+ nav.find((item) => route.path === item.to || route.path.startsWith(`${item.to}/`)),
29
+ );
30
+ }
31
+
32
+ /** Theme persisted in a cookie so the server renders the right `data-theme`. */
33
+ export function useFoundationTheme(): { theme: Ref<FoundationTheme>; toggle: () => void } {
34
+ const theme = useCookie<FoundationTheme>('sf-theme', {
35
+ default: () => 'notte',
36
+ maxAge: 60 * 60 * 24 * 365,
37
+ sameSite: 'lax',
38
+ });
39
+ const toggle = (): void => {
40
+ theme.value = theme.value === 'notte' ? 'giorno' : 'notte';
41
+ };
42
+ return { theme, toggle };
43
+ }
44
+
45
+ // Cloudflare Access answers on every protected hostname; locally there is no
46
+ // Access in front of the app, so the user is simply unknown.
47
+ async function fetchIdentity(): Promise<FoundationUser | null> {
48
+ if (import.meta.dev) return null;
49
+ try {
50
+ const identity = await $fetch<{ email?: string; name?: string }>(
51
+ '/cdn-cgi/access/get-identity',
52
+ );
53
+ return identity.email ? { email: identity.email, name: identity.name } : null;
54
+ } catch {
55
+ return null;
56
+ }
57
+ }
58
+
59
+ /** The Cloudflare Access user, resolved in the browser; `null` when unknown. */
60
+ export function useCurrentUser(): Ref<FoundationUser | null> {
61
+ const { data } = useAsyncData('foundation:user', fetchIdentity, {
62
+ default: () => null,
63
+ server: false,
64
+ });
65
+ return data;
66
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Open state of a panel anchored to a trigger: Esc closes it and gives focus
3
+ * back to the trigger, a pointer outside or a navigation closes it, opening it
4
+ * moves focus to its first link or button.
5
+ */
6
+ export function usePopover(
7
+ trigger: Ref<HTMLElement | null>,
8
+ panel: Ref<HTMLElement | null>,
9
+ ): { open: Ref<boolean>; close: (restoreFocus?: boolean) => void; toggle: () => void } {
10
+ const open = ref(false);
11
+ const route = useRoute();
12
+
13
+ const close = (restoreFocus = true): void => {
14
+ if (!open.value) return;
15
+ open.value = false;
16
+ if (restoreFocus) trigger.value?.focus();
17
+ };
18
+ const toggle = (): void => {
19
+ open.value = !open.value;
20
+ };
21
+ const onKey = (event: KeyboardEvent): void => {
22
+ if (event.key === 'Escape') close();
23
+ };
24
+ const onPointer = (event: PointerEvent): void => {
25
+ const target = event.target as Node;
26
+ if (panel.value?.contains(target) || trigger.value?.contains(target)) return;
27
+ close(false);
28
+ };
29
+
30
+ watch(open, async (value) => {
31
+ if (!value) return;
32
+ await nextTick();
33
+ const current = panel.value?.querySelector<HTMLElement>('[aria-current="page"]');
34
+ (current ?? panel.value?.querySelector<HTMLElement>('a, button'))?.focus();
35
+ });
36
+ watch(
37
+ () => route.fullPath,
38
+ () => close(false),
39
+ );
40
+ onMounted(() => {
41
+ document.addEventListener('keydown', onKey);
42
+ document.addEventListener('pointerdown', onPointer);
43
+ });
44
+ onBeforeUnmount(() => {
45
+ document.removeEventListener('keydown', onKey);
46
+ document.removeEventListener('pointerdown', onPointer);
47
+ });
48
+
49
+ return { open, close, toggle };
50
+ }
@@ -0,0 +1,43 @@
1
+ <script setup lang="ts">
2
+ const { theme } = useFoundationTheme();
3
+ const app = useFoundationApp();
4
+ const active = useActiveNav();
5
+ const route = useRoute();
6
+ const menuOpen = ref(false);
7
+
8
+ useHead({ htmlAttrs: { 'data-theme': theme } });
9
+ const closeMenu = (): void => {
10
+ menuOpen.value = false;
11
+ };
12
+ const onKey = (event: KeyboardEvent): void => {
13
+ if (event.key === 'Escape') closeMenu();
14
+ };
15
+
16
+ watch(() => route.fullPath, closeMenu);
17
+ onMounted(() => document.addEventListener('keydown', onKey));
18
+ onBeforeUnmount(() => document.removeEventListener('keydown', onKey));
19
+ </script>
20
+
21
+ <template>
22
+ <div class="sf sf-shell">
23
+ <FoundationBarra :menu-open="menuOpen" @toggle-menu="menuOpen = !menuOpen" />
24
+ <div class="sf-shell__corpo">
25
+ <FoundationMenu :open="menuOpen" />
26
+ <div
27
+ v-if="menuOpen"
28
+ class="sf-velo sf-shell__velo"
29
+ aria-hidden="true"
30
+ @click="closeMenu"
31
+ />
32
+ <main class="sf-shell__slot">
33
+ <div v-if="app && active" class="sf-targa__riga sf-shell__briciole">
34
+ <b>{{ app.name }}</b
35
+ ><span>{{ active.label }}</span
36
+ ><span class="sf-targa__filetto" />
37
+ </div>
38
+ <slot />
39
+ </main>
40
+ </div>
41
+ <FoundationStato />
42
+ </div>
43
+ </template>
@@ -0,0 +1,6 @@
1
+ import { findApp, type ShellAppId } from '../apps';
2
+
3
+ /** Production URL of `path` inside another shell app of the suite. */
4
+ export function appLink(id: ShellAppId, path = '/'): string {
5
+ return new URL(path, findApp(id)?.url).href;
6
+ }
package/app.config.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type { IconName } from './design-system/vue/icons';
2
+
3
+ export interface FoundationNavItem {
4
+ label: string;
5
+ to: string;
6
+ icon: IconName;
7
+ }
8
+
9
+ // Types the host's `defineAppConfig` input: a wrong icon name fails its typecheck.
10
+ declare module '@nuxt/schema' {
11
+ interface AppConfigInput {
12
+ foundation?: { nav?: FoundationNavItem[] };
13
+ }
14
+ }
15
+
16
+ // Defaults of the shell. The host app declares its side menu under
17
+ // `foundation.nav` in its own app.config.ts.
18
+ export default defineAppConfig({
19
+ foundation: {
20
+ nav: [] as FoundationNavItem[],
21
+ },
22
+ });