@altafusion/shell 0.0.0-stage → 0.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/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +110 -2
- package/app/app.config.ts +15 -0
- package/app/components/ShellAsidePlaceholder.vue +16 -0
- package/app/components/ShellBrandLogo.vue +26 -0
- package/app/components/ShellLangToggle.vue +129 -0
- package/app/components/ShellPageHeader.vue +25 -0
- package/app/components/ShellSiteHeader.vue +63 -0
- package/app/composables/useAppNav.ts +67 -0
- package/app/composables/useBrandTheme.ts +37 -0
- package/app/composables/usePageChrome.ts +40 -0
- package/app/composables/useShellChrome.ts +122 -0
- package/app/composables/useShellFooterRight.ts +13 -0
- package/app/composables/useShellHeaderActions.ts +18 -0
- package/app/composables/useShellHeaderRight.ts +13 -0
- package/app/composables/useShellI18n.ts +31 -0
- package/app/layouts/default.vue +68 -0
- package/app/layouts/fullscreen.vue +20 -0
- package/app/layouts/minimal.vue +11 -0
- package/app/layouts/product.vue +23 -0
- package/app/plugins/brand-theme.ts +29 -0
- package/app/plugins/shell-brand-head.ts +30 -0
- package/assets/css/brand-variants.css +50 -0
- package/assets/css/sections/landing-header.css +249 -0
- package/assets/css/sections/shell-chrome.css +34 -0
- package/assets/css/shell-sections.css +2 -0
- package/components/BaseButton.vue +106 -0
- package/eslint.config.mjs +4 -0
- package/lib/fugue-content-public-config.ts +39 -0
- package/lib/injection-keys.ts +9 -0
- package/lib/locale-switch-path.ts +20 -0
- package/lib/nuxt-ui-icons.ts +14 -0
- package/nuxt.config.ts +61 -0
- package/package.json +49 -3
- package/themes/tailwind-shell.css +35 -0
- package/types/app-brand.ts +42 -0
- package/types/nuxt-shell.d.ts +38 -0
- package/utils/altafusionBrandTheme.ts +15 -0
- package/utils/formatDate.ts +13 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @altafusion/shell
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7767e60: Rebrand for the public release. In `@altafusion/shell`, `CODERMAR_BRANDS`, `CODERMAR_BRAND_THEME` and `utils/codermarBrandTheme` become `ALTAFUSION_*` and `utils/altafusionBrandTheme`, and the brand cookie key is now `altafusion:brand`. In `@altafusion/msw`, the `codermarMsw*` exports become `altafusionMsw*`. The site settings schema `$id` is now `https://altafusion.com/schemas/site-settings.json`. Package descriptions and docs no longer reference private sites.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [7767e60]
|
|
12
|
+
- @altafusion/fugue-ui@0.2.0
|
|
13
|
+
|
|
14
|
+
## 0.1.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- cd1a639: Release pipeline check: no code change. Confirms the nine packages still publish after per-package access was set.
|
|
19
|
+
- @altafusion/fugue-ui@0.1.1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Altafusion
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,111 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @altafusion/shell
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Nuxt layer: **site chrome** and **product page chrome** for consumer apps.
|
|
4
|
+
|
|
5
|
+
## Layouts
|
|
6
|
+
|
|
7
|
+
| Layout | Use |
|
|
8
|
+
|--------|-----|
|
|
9
|
+
| `default` | Nuxt UI site header, padded main, optional footer |
|
|
10
|
+
| `fullscreen` | Site header + full-bleed main (landing pages) |
|
|
11
|
+
| `minimal` | Full-viewport pass-through — auth flows, embeds |
|
|
12
|
+
| `product` | Nuxt UI `UPage` shell — optional aside + header slots, main body (dashboard-style apps) |
|
|
13
|
+
|
|
14
|
+
Pages: `definePageMeta({ layout: 'product' })`. Named slots (`#aside`, `#header`) via `<NuxtLayout>` when needed. `#header` renders in `UPage`'s default slot (before `UPageBody`), not as a `UPage` named slot.
|
|
15
|
+
|
|
16
|
+
## Composables
|
|
17
|
+
|
|
18
|
+
| Composable | Role |
|
|
19
|
+
|------------|------|
|
|
20
|
+
| **`usePageChrome()`** | `title`, `breadcrumbs`, `showAside` from route meta |
|
|
21
|
+
| **`useAppNav()`** | Primary header nav — `localePath` on `to`, optional `labelKey` for i18n labels |
|
|
22
|
+
| **`useShellI18n()`** | `localePath()` / `t()` when `@altafusion/fugue-content` enables i18n (`runtimeConfig.public.cms.i18nEnabled`) |
|
|
23
|
+
| **`setAppNavItems()`** | Register nav items for the app session |
|
|
24
|
+
| **`useShellChrome()`** | `showHeader`, `showFooter`, `mainPadding` from route meta + layout |
|
|
25
|
+
| **`useShellSiteHeader()`** | Shared wiring for **`ShellSiteHeader`** — title, **`brand`**, nav, **`visualStyle`**, color mode |
|
|
26
|
+
| **`useBrandTheme()`** | Cookie-backed runtime brand (`default` / `violet` / `green`) + `[data-brand]` |
|
|
27
|
+
| **`ShellBrandLogo`** | Renders **`app.config.brand.logo`** in headers and login forms |
|
|
28
|
+
| **`setShellHeaderActions()` / `useShellHeaderActions()`** | Register header actions from a page (`onMounted` / `onUnmounted`) |
|
|
29
|
+
|
|
30
|
+
## Components
|
|
31
|
+
|
|
32
|
+
| Component | Role |
|
|
33
|
+
|-----------|------|
|
|
34
|
+
| **`ShellSiteHeader`** | Site header — **`FugueAppHeader`** + nav, **`ShellLangToggle`**, `header.visualStyle` from `app.config` |
|
|
35
|
+
| **`ShellLangToggle`** | Locale switcher — alternate-language text link (2 locales); globe + dropdown (3+) |
|
|
36
|
+
| **`ShellPageHeader`** | Page title region under the site header |
|
|
37
|
+
| **`ShellAsidePlaceholder`** | Dashed placeholder for filter aside until a slice ships real filters |
|
|
38
|
+
|
|
39
|
+
## Theming
|
|
40
|
+
|
|
41
|
+
Runtime brand variants (demo/dev): **`useBrandTheme()`**, **`brand-theme`** plugin, and **`assets/css/brand-variants.css`** on this layer. Portable helpers: **`@altafusion/fugue-ui/utils/brandTheme`**. Site look stays build-time via **`createAppConfig({ theme })`** and **`app/assets/css/themes/{app}-theme.css`**.
|
|
42
|
+
|
|
43
|
+
## Route meta
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
definePageMeta({
|
|
47
|
+
layout: 'product',
|
|
48
|
+
title: 'Projects',
|
|
49
|
+
breadcrumb: 'Projects',
|
|
50
|
+
shell: { footer: false, mainPadding: true },
|
|
51
|
+
nav: {
|
|
52
|
+
primary: 'projects',
|
|
53
|
+
aside: ['filters'],
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**App overrides:** place `app/components/ShellSiteHeader.vue` in the app to customize header actions — reuse **`useShellSiteHeader()`** from the shell layer. Logo and title come from **`app.config`** (see below).
|
|
59
|
+
|
|
60
|
+
## App settings (`app.config.ts`)
|
|
61
|
+
|
|
62
|
+
Product apps declare branding in **`app/app.config.ts`** (typed via **`@altafusion/shell`**):
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
export default defineAppConfig({
|
|
66
|
+
brand: {
|
|
67
|
+
name: 'My App',
|
|
68
|
+
logo: '/my-logo.svg', // public/ asset path
|
|
69
|
+
logoClass: 'dark:brightness-0 dark:invert', // optional img classes
|
|
70
|
+
favicon: '/favicon.svg',
|
|
71
|
+
},
|
|
72
|
+
seo: {
|
|
73
|
+
title: 'My App',
|
|
74
|
+
titleTemplate: '%s — My App',
|
|
75
|
+
description: '…',
|
|
76
|
+
},
|
|
77
|
+
header: {
|
|
78
|
+
showColorMode: true,
|
|
79
|
+
},
|
|
80
|
+
ui: { /* Nuxt UI tokens */ },
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
| Block | Purpose |
|
|
85
|
+
|-------|---------|
|
|
86
|
+
| **`brand`** | Display name, logo/favicon paths, optional **`logoClass`** — **`ShellBrandLogo`**, footer, login forms |
|
|
87
|
+
| **`seo`** | Default **`useSeoMeta`** via shell plugin |
|
|
88
|
+
| **`header`** | Color mode toggle; title override (else **`brand.name`**) |
|
|
89
|
+
| **`ui`** | Nuxt UI semantic colors |
|
|
90
|
+
|
|
91
|
+
**Fallback:** `runtimeConfig.public.appName` and `appNav` in **`nuxt.config.ts`** when env-specific wiring is needed. **Docs apps** (Docus) use **`site`** + **`app.head`** instead — not this block.
|
|
92
|
+
|
|
93
|
+
## Setup
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
// nuxt.config.ts — apps must still extend fugue-theme for @nuxt/eslint + theme tokens
|
|
97
|
+
export default defineNuxtConfig(createAppConfig({
|
|
98
|
+
extends: ['@altafusion/fugue-theme', '@altafusion/shell'],
|
|
99
|
+
runtimeConfig: {
|
|
100
|
+
public: {
|
|
101
|
+
appNav: [
|
|
102
|
+
{ label: 'Home', to: '/', icon: 'i-lucide-home', id: 'home' },
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
}, { enableNuxtUI: true }))
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Shell extends `@altafusion/fugue-ui` (which extends `fugue-nuxt-ui`). The **`product`** layout requires Nuxt UI (`enableNuxtUI: true` on the app).
|
|
110
|
+
|
|
111
|
+
**Multilingual sites:** use **`labelKey`** on `appNav` items and translate in the app’s **`i18n/locales/*.yaml`**. Paths stay locale-neutral (`to: '/about'`); **`useAppNav`** applies **`localePath()`**. See **`/fugue-content/starter-template/i18n`** in developer-docs.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell layer defaults — merged into every app that extends `@altafusion/shell`.
|
|
3
|
+
*/
|
|
4
|
+
export default defineAppConfig({
|
|
5
|
+
ui: {
|
|
6
|
+
/**
|
|
7
|
+
* Nuxt UI default `main` is `min-h-[calc(100vh-header)]`. Stacked with a real
|
|
8
|
+
* header + footer that always forces document overflow (~footer height) on
|
|
9
|
+
* every page. Flex-1 fills the shell column instead.
|
|
10
|
+
*/
|
|
11
|
+
main: {
|
|
12
|
+
base: 'flex-1 w-full min-h-0'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineOptions({ name: 'ShellAsidePlaceholder' })
|
|
3
|
+
|
|
4
|
+
const { message = 'Filters — coming soon' } = defineProps<{
|
|
5
|
+
message?: string
|
|
6
|
+
}>()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div
|
|
11
|
+
class="rounded-md border border-dashed border-default px-4 py-6 text-center text-sm text-muted"
|
|
12
|
+
role="status"
|
|
13
|
+
>
|
|
14
|
+
{{ message }}
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const {
|
|
3
|
+
logo,
|
|
4
|
+
alt,
|
|
5
|
+
size = 28,
|
|
6
|
+
logoClass,
|
|
7
|
+
} = defineProps<{
|
|
8
|
+
logo?: string
|
|
9
|
+
alt?: string
|
|
10
|
+
size?: number
|
|
11
|
+
/** Extra classes on the logo `<img>` — from `app.config.brand.logoClass` or per-use override. */
|
|
12
|
+
logoClass?: string
|
|
13
|
+
}>()
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<img
|
|
18
|
+
v-if="logo"
|
|
19
|
+
:src="logo"
|
|
20
|
+
:alt="alt"
|
|
21
|
+
:width="size"
|
|
22
|
+
:height="size"
|
|
23
|
+
class="shrink-0 rounded-lg object-contain"
|
|
24
|
+
:class="logoClass"
|
|
25
|
+
>
|
|
26
|
+
</template>
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useShellFugueContentPublicConfig } from '../../lib/fugue-content-public-config'
|
|
3
|
+
import { localeSwitchPathBase, localeSwitchPathWithHash } from '../../lib/locale-switch-path'
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
variant = 'default',
|
|
7
|
+
linkClass,
|
|
8
|
+
showLabel = true,
|
|
9
|
+
} = defineProps<{
|
|
10
|
+
/** `brochure` — brochure-style LangToggle (language icon + btn-inverse); `default` — globe + hover fill. */
|
|
11
|
+
variant?: 'default' | 'brochure'
|
|
12
|
+
/** Optional class override — a site can pass `landing-header__lang-btn`. */
|
|
13
|
+
linkClass?: string
|
|
14
|
+
/** Show the language name next to the icon; when false it stays available to screen readers only. */
|
|
15
|
+
showLabel?: boolean
|
|
16
|
+
}>()
|
|
17
|
+
|
|
18
|
+
const cms = useShellFugueContentPublicConfig()
|
|
19
|
+
const nuxtApp = useNuxtApp()
|
|
20
|
+
const route = useRoute()
|
|
21
|
+
|
|
22
|
+
const locales = computed(() => cms?.filteredLocales ?? [])
|
|
23
|
+
|
|
24
|
+
const show = computed(() =>
|
|
25
|
+
!!cms?.i18nEnabled
|
|
26
|
+
&& locales.value.length > 1,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const useDropdown = computed(() => locales.value.length > 2)
|
|
30
|
+
|
|
31
|
+
const currentLocale = computed(() => {
|
|
32
|
+
const i18n = nuxtApp.$i18n as { locale?: { value: string } } | undefined
|
|
33
|
+
return i18n?.locale?.value ?? locales.value[0]?.code ?? 'en'
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
/** Brochure-style: link to the other language(s), not the active one. */
|
|
37
|
+
const alternateLocales = computed(() =>
|
|
38
|
+
locales.value.filter(locale => locale.code !== currentLocale.value),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
/** After hydration, locale links may include the current in-page hash again. */
|
|
42
|
+
const hydrated = ref(false)
|
|
43
|
+
onMounted(() => {
|
|
44
|
+
hydrated.value = true
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
function switchLocaleLink(code: string): string {
|
|
48
|
+
const fn = nuxtApp.$switchLocalePath as ((locale: string) => string) | undefined
|
|
49
|
+
const raw = fn?.(code) ?? `/${code}`
|
|
50
|
+
const base = localeSwitchPathBase(raw)
|
|
51
|
+
if (!hydrated.value)
|
|
52
|
+
return base
|
|
53
|
+
return localeSwitchPathWithHash(base, route.hash)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function localeLabel(code: string) {
|
|
57
|
+
return locales.value.find(l => l.code === code)?.name ?? code
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const resolvedLinkClass = computed(() => {
|
|
61
|
+
if (linkClass)
|
|
62
|
+
return linkClass
|
|
63
|
+
if (variant === 'brochure')
|
|
64
|
+
return 'inline-flex min-w-[95px] cursor-pointer items-center justify-center rounded border border-solid border-gray-600 bg-transparent p-1 text-center text-gray-500 transition-colors hover:bg-gray-100 dark:border-gray-600 dark:text-gray-100 dark:hover:bg-gray-700'
|
|
65
|
+
return 'inline-flex items-center gap-1 rounded-md px-1.5 py-1.5 text-sm font-medium text-default hover:bg-elevated active:bg-elevated'
|
|
66
|
+
})
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<template>
|
|
70
|
+
<!-- Two locales: alternate language link. -->
|
|
71
|
+
<template v-if="show && !useDropdown">
|
|
72
|
+
<NuxtLink
|
|
73
|
+
v-for="locale in alternateLocales"
|
|
74
|
+
:key="locale.code"
|
|
75
|
+
:to="switchLocaleLink(locale.code)"
|
|
76
|
+
:class="resolvedLinkClass"
|
|
77
|
+
:aria-label="`Switch to ${locale.name ?? locale.code}`"
|
|
78
|
+
>
|
|
79
|
+
<UIcon
|
|
80
|
+
v-if="variant === 'brochure'"
|
|
81
|
+
name="i-lucide-languages"
|
|
82
|
+
class="size-[1em] shrink-0"
|
|
83
|
+
aria-hidden="true"
|
|
84
|
+
/>
|
|
85
|
+
<UIcon
|
|
86
|
+
v-else
|
|
87
|
+
name="i-lucide-globe"
|
|
88
|
+
class="size-4 shrink-0"
|
|
89
|
+
aria-hidden="true"
|
|
90
|
+
/>
|
|
91
|
+
<span :class="{ 'sr-only': !showLabel }">{{ locale.name ?? locale.code }}</span>
|
|
92
|
+
</NuxtLink>
|
|
93
|
+
</template>
|
|
94
|
+
|
|
95
|
+
<!-- Three or more: globe + current language + dropdown. -->
|
|
96
|
+
<UPopover
|
|
97
|
+
v-else-if="show && useDropdown"
|
|
98
|
+
:content="{ align: 'end' }"
|
|
99
|
+
>
|
|
100
|
+
<UButton
|
|
101
|
+
color="neutral"
|
|
102
|
+
variant="ghost"
|
|
103
|
+
size="sm"
|
|
104
|
+
class="px-1.5"
|
|
105
|
+
:label="localeLabel(currentLocale)"
|
|
106
|
+
icon="i-lucide-globe"
|
|
107
|
+
trailing-icon="i-lucide-chevron-down"
|
|
108
|
+
:ui="{ leadingIcon: 'size-4' }"
|
|
109
|
+
:aria-label="`Language: ${localeLabel(currentLocale)}`"
|
|
110
|
+
/>
|
|
111
|
+
|
|
112
|
+
<template #content>
|
|
113
|
+
<ul class="flex flex-col min-w-36 py-1">
|
|
114
|
+
<li
|
|
115
|
+
v-for="locale in locales"
|
|
116
|
+
:key="locale.code"
|
|
117
|
+
>
|
|
118
|
+
<NuxtLink
|
|
119
|
+
class="flex items-center justify-between py-1.5 px-3 gap-2 hover:bg-muted text-sm"
|
|
120
|
+
:to="switchLocaleLink(locale.code)"
|
|
121
|
+
:class="{ 'font-semibold text-highlighted': locale.code === currentLocale }"
|
|
122
|
+
>
|
|
123
|
+
{{ locale.name ?? locale.code }}
|
|
124
|
+
</NuxtLink>
|
|
125
|
+
</li>
|
|
126
|
+
</ul>
|
|
127
|
+
</template>
|
|
128
|
+
</UPopover>
|
|
129
|
+
</template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{
|
|
3
|
+
title: string
|
|
4
|
+
}>()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<div class="shell-page-header">
|
|
9
|
+
<h1 class="shell-page-header__title">
|
|
10
|
+
{{ title }}
|
|
11
|
+
</h1>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<style scoped>
|
|
16
|
+
.shell-page-header {
|
|
17
|
+
padding: 0 var(--space-6, 1.5rem) var(--space-4, 1rem);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.shell-page-header__title {
|
|
21
|
+
margin: 0;
|
|
22
|
+
font-size: var(--font-size-2xl, 1.5rem);
|
|
23
|
+
font-weight: var(--font-weight-semibold, 600);
|
|
24
|
+
}
|
|
25
|
+
</style>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const {
|
|
3
|
+
title,
|
|
4
|
+
brand,
|
|
5
|
+
homeTo,
|
|
6
|
+
navItems,
|
|
7
|
+
activeNavId,
|
|
8
|
+
showColorMode,
|
|
9
|
+
visualStyle,
|
|
10
|
+
headerActions,
|
|
11
|
+
headerRight,
|
|
12
|
+
} = useShellSiteHeader()
|
|
13
|
+
|
|
14
|
+
const isLandingStyle = computed(() =>
|
|
15
|
+
visualStyle.value === 'landing-fixed' || visualStyle.value === 'landing-static',
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const defaultLogoClass = computed(() =>
|
|
19
|
+
isLandingStyle.value ? 'landing-header__logo' : undefined,
|
|
20
|
+
)
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<FugueAppHeader
|
|
25
|
+
:title="title"
|
|
26
|
+
:home-to="homeTo"
|
|
27
|
+
:nav-items="navItems"
|
|
28
|
+
:active-nav-id="activeNavId"
|
|
29
|
+
:show-color-mode="showColorMode"
|
|
30
|
+
:visual-style="visualStyle"
|
|
31
|
+
>
|
|
32
|
+
<template #logo>
|
|
33
|
+
<slot name="logo">
|
|
34
|
+
<ShellBrandLogo
|
|
35
|
+
v-if="brand.logo"
|
|
36
|
+
:logo="brand.logo"
|
|
37
|
+
:alt="brand.logoAlt"
|
|
38
|
+
:logo-class="brand.logoClass ?? defaultLogoClass"
|
|
39
|
+
/>
|
|
40
|
+
</slot>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<template #actions>
|
|
44
|
+
<ShellLangToggle
|
|
45
|
+
v-if="isLandingStyle"
|
|
46
|
+
variant="brochure"
|
|
47
|
+
link-class="landing-header__lang-btn"
|
|
48
|
+
/>
|
|
49
|
+
<ShellLangToggle v-else />
|
|
50
|
+
<component
|
|
51
|
+
:is="headerActions"
|
|
52
|
+
v-if="headerActions"
|
|
53
|
+
/>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<template #right>
|
|
57
|
+
<component
|
|
58
|
+
:is="headerRight"
|
|
59
|
+
v-if="headerRight"
|
|
60
|
+
/>
|
|
61
|
+
</template>
|
|
62
|
+
</FugueAppHeader>
|
|
63
|
+
</template>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { shallowRef } from 'vue'
|
|
2
|
+
import { useShellI18n } from './useShellI18n'
|
|
3
|
+
|
|
4
|
+
export interface AppNavItem {
|
|
5
|
+
/** Display label (fallback when `labelKey` is unset or i18n is off). */
|
|
6
|
+
label: string
|
|
7
|
+
/** i18n message key — e.g. `nav.about` from `i18n/locales/*.yaml`. */
|
|
8
|
+
labelKey?: string
|
|
9
|
+
/** Locale-neutral route — resolved with `localePath` when i18n is enabled. */
|
|
10
|
+
to: string
|
|
11
|
+
icon: string
|
|
12
|
+
/** Matches `route.meta.nav.primary` when set on a page */
|
|
13
|
+
id?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const navItems = shallowRef<AppNavItem[]>([])
|
|
17
|
+
|
|
18
|
+
/** Register primary nav items for the current app session (clear on teardown if needed). */
|
|
19
|
+
export function setAppNavItems(items: AppNavItem[]) {
|
|
20
|
+
navItems.value = items
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Primary app header navigation for consumer product layouts.
|
|
25
|
+
* Items come from `setAppNavItems`, then `runtimeConfig.public.appNav`, then empty.
|
|
26
|
+
*
|
|
27
|
+
* When i18n is enabled, `to` is passed through `localePath` and `labelKey` is translated.
|
|
28
|
+
*/
|
|
29
|
+
export function useAppNav() {
|
|
30
|
+
const route = useRoute()
|
|
31
|
+
const configItems = useRuntimeConfig().public.appNav as AppNavItem[] | undefined
|
|
32
|
+
const { localePath, t } = useShellI18n()
|
|
33
|
+
|
|
34
|
+
const sourceItems = computed((): AppNavItem[] => {
|
|
35
|
+
if (navItems.value.length > 0)
|
|
36
|
+
return navItems.value
|
|
37
|
+
if (Array.isArray(configItems) && configItems.length > 0)
|
|
38
|
+
return configItems
|
|
39
|
+
return []
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const items = computed((): AppNavItem[] => {
|
|
43
|
+
return sourceItems.value.map(item => ({
|
|
44
|
+
...item,
|
|
45
|
+
label: item.labelKey
|
|
46
|
+
? t(item.labelKey, item.label)
|
|
47
|
+
: item.label,
|
|
48
|
+
to: localePath(item.to)
|
|
49
|
+
}))
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const activeId = computed(() => {
|
|
53
|
+
const nav = route.meta.nav as { primary?: string } | undefined
|
|
54
|
+
if (nav?.primary)
|
|
55
|
+
return nav.primary
|
|
56
|
+
|
|
57
|
+
const matched = items.value.find(
|
|
58
|
+
item => route.path === item.to || (item.to !== '/' && route.path.startsWith(`${item.to}/`))
|
|
59
|
+
)
|
|
60
|
+
return matched?.id
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
items,
|
|
65
|
+
activeId
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BrandId } from '../../utils/altafusionBrandTheme'
|
|
2
|
+
/**
|
|
3
|
+
* useBrandTheme – composable shared via the @altafusion/shell layer.
|
|
4
|
+
*
|
|
5
|
+
* Runtime demo/dev variants (`default` / `violet` / `green`); site themes stay
|
|
6
|
+
* build-time via `createAppConfig({ theme })` + `{app}-tokens.css`.
|
|
7
|
+
*/
|
|
8
|
+
import { isKnownBrandId } from '@altafusion/fugue-ui/utils/brandTheme'
|
|
9
|
+
import { ALTAFUSION_BRAND_THEME } from '../../utils/altafusionBrandTheme'
|
|
10
|
+
|
|
11
|
+
export type { BrandId }
|
|
12
|
+
|
|
13
|
+
export function useBrandTheme() {
|
|
14
|
+
const { brands, cookieKey, defaultBrandId } = ALTAFUSION_BRAND_THEME
|
|
15
|
+
const fallbackId = defaultBrandId ?? brands[0].id
|
|
16
|
+
|
|
17
|
+
const brand = useCookie<BrandId>(cookieKey, {
|
|
18
|
+
default: () => fallbackId,
|
|
19
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
20
|
+
sameSite: 'lax'
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
if (!isKnownBrandId(brands, brand.value))
|
|
24
|
+
brand.value = fallbackId
|
|
25
|
+
|
|
26
|
+
function setBrand(id: BrandId) {
|
|
27
|
+
if (!isKnownBrandId(brands, id))
|
|
28
|
+
return
|
|
29
|
+
brand.value = id
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
brand: readonly(brand),
|
|
34
|
+
setBrand,
|
|
35
|
+
brands: readonly(brands)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface PageChromeBreadcrumb {
|
|
2
|
+
label: string
|
|
3
|
+
to?: string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Page heading and breadcrumbs from route meta.
|
|
8
|
+
* Reads `definePageMeta` hints (`title`, `breadcrumb`).
|
|
9
|
+
*/
|
|
10
|
+
export function usePageChrome() {
|
|
11
|
+
const route = useRoute()
|
|
12
|
+
|
|
13
|
+
const title = computed(() => {
|
|
14
|
+
const metaTitle = route.meta.title
|
|
15
|
+
if (typeof metaTitle === 'string')
|
|
16
|
+
return metaTitle
|
|
17
|
+
return undefined
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const breadcrumbs = computed((): PageChromeBreadcrumb[] => {
|
|
21
|
+
const crumb = route.meta.breadcrumb
|
|
22
|
+
if (typeof crumb === 'string' && crumb.length > 0) {
|
|
23
|
+
return [
|
|
24
|
+
{ label: crumb }
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
return []
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const showAside = computed(() => {
|
|
31
|
+
const nav = route.meta.nav as { aside?: string[] } | undefined
|
|
32
|
+
return Boolean(nav?.aside?.length)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
title,
|
|
37
|
+
breadcrumbs,
|
|
38
|
+
showAside
|
|
39
|
+
}
|
|
40
|
+
}
|