@sit-onyx/nuxt-docs 1.0.0-beta.105 → 1.0.0-beta.107
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/app/components/ColorSchemeSwitch.vue +27 -0
- package/app/components/LocaleSwitch.vue +41 -0
- package/app/components/NavBar.vue +29 -64
- package/app/error.vue +27 -8
- package/nuxt.config.ts +6 -0
- package/package.json +6 -6
- package/app/app.config.ts +0 -32
- package/app/components/NavItem.vue +0 -33
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { iconCircleContrast } from "@sit-onyx/icons";
|
|
3
|
+
import type { ColorSchemeValue } from "sit-onyx";
|
|
4
|
+
|
|
5
|
+
const colorMode = useColorMode();
|
|
6
|
+
const isColorSchemeDialogOpen = ref(false);
|
|
7
|
+
|
|
8
|
+
const colorScheme = computed({
|
|
9
|
+
get: () => {
|
|
10
|
+
return colorMode.preference === "system" ? "auto" : (colorMode.preference as ColorSchemeValue);
|
|
11
|
+
},
|
|
12
|
+
set: (newValue) => {
|
|
13
|
+
colorMode.preference = newValue === "auto" ? "system" : newValue;
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<OnyxIconButton
|
|
20
|
+
label="Toggle color scheme"
|
|
21
|
+
:icon="iconCircleContrast"
|
|
22
|
+
color="neutral"
|
|
23
|
+
@click="isColorSchemeDialogOpen = true"
|
|
24
|
+
/>
|
|
25
|
+
|
|
26
|
+
<OnyxColorSchemeDialog v-model="colorScheme" v-model:open="isColorSchemeDialogOpen" />
|
|
27
|
+
</template>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { iconTranslate } from "@sit-onyx/icons";
|
|
3
|
+
import type { SelectDialogOption } from "sit-onyx";
|
|
4
|
+
|
|
5
|
+
const { locale, setLocale, locales } = useI18n();
|
|
6
|
+
const isLanguageDialogOpen = ref(false);
|
|
7
|
+
|
|
8
|
+
const languageOptions = computed(() => {
|
|
9
|
+
return locales.value.map((locale) => {
|
|
10
|
+
return {
|
|
11
|
+
label: locale.name ?? locale.code,
|
|
12
|
+
value: locale.code,
|
|
13
|
+
} satisfies SelectDialogOption;
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const currentLocaleLabel = computed(() => {
|
|
18
|
+
// using "!" here is safe since splitting a string will always return at least one string in the returned array
|
|
19
|
+
return locale.value.split("-")[0]!.split("_")[0]!.toUpperCase();
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<OnyxButton
|
|
25
|
+
:label="currentLocaleLabel"
|
|
26
|
+
:icon="iconTranslate"
|
|
27
|
+
color="neutral"
|
|
28
|
+
mode="plain"
|
|
29
|
+
@click="isLanguageDialogOpen = true"
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
<OnyxSelectDialog
|
|
33
|
+
v-model:open="isLanguageDialogOpen"
|
|
34
|
+
:label="$t('onyx.languageSelect.headline')"
|
|
35
|
+
:model-value="locale"
|
|
36
|
+
:options="languageOptions"
|
|
37
|
+
@update:model-value="setLocale($event)"
|
|
38
|
+
>
|
|
39
|
+
<template #description> {{ $t("onyx.languageSelect.subtitle") }} </template>
|
|
40
|
+
</OnyxSelectDialog>
|
|
41
|
+
</template>
|
|
@@ -1,82 +1,47 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import type { OnyxNavBarProps, OnyxNavBarSlots } from "sit-onyx";
|
|
3
|
+
import ColorSchemeSwitch from "./ColorSchemeSwitch.vue";
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const isColorSchemeDialogOpen = ref(false);
|
|
10
|
-
|
|
11
|
-
const colorScheme = computed({
|
|
12
|
-
get: () => {
|
|
13
|
-
return colorMode.preference === "system" ? "auto" : (colorMode.preference as ColorSchemeValue);
|
|
14
|
-
},
|
|
15
|
-
set: (newValue) => {
|
|
16
|
-
colorMode.preference = newValue === "auto" ? "system" : newValue;
|
|
17
|
-
},
|
|
5
|
+
const props = withDefaults(defineProps<OnyxNavBarProps>(), {
|
|
6
|
+
appName: "Documentation",
|
|
7
|
+
withBackButton: true,
|
|
18
8
|
});
|
|
19
9
|
|
|
20
|
-
const
|
|
21
|
-
const localePath = useLocalePath();
|
|
22
|
-
const isLanguageDialogOpen = ref(false);
|
|
10
|
+
const slots = defineSlots<OnyxNavBarSlots>();
|
|
23
11
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
label: locale.name ?? locale.code,
|
|
28
|
-
value: locale.code,
|
|
29
|
-
} satisfies SelectDialogOption;
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const currentLocaleLabel = computed(() => {
|
|
34
|
-
// using "!" here is safe since splitting a string will always return at least one string in the returned array
|
|
35
|
-
return locale.value.split("-")[0]!.split("_")[0]!.toUpperCase();
|
|
36
|
-
});
|
|
12
|
+
const router = useRouter();
|
|
13
|
+
const { locales } = useI18n();
|
|
14
|
+
const localePath = useLocalePath();
|
|
37
15
|
</script>
|
|
38
16
|
|
|
39
17
|
<template>
|
|
40
18
|
<OnyxNavBar
|
|
41
|
-
|
|
42
|
-
|
|
19
|
+
v-bind="props"
|
|
20
|
+
:app-area="props.appArea ?? { link: localePath('/') }"
|
|
43
21
|
@navigate-back="router.back"
|
|
44
22
|
>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/>
|
|
23
|
+
<!-- eslint-disable vue/require-explicit-slots -- slots type is imported from onyx but eslint does not seem to be able to handle this -->
|
|
24
|
+
<template v-if="slots.appArea" #appArea>
|
|
25
|
+
<slot name="appArea"></slot>
|
|
26
|
+
</template>
|
|
50
27
|
|
|
51
|
-
<
|
|
52
|
-
<template v-if="locales.length > 1">
|
|
53
|
-
<OnyxButton
|
|
54
|
-
:label="currentLocaleLabel"
|
|
55
|
-
:icon="iconTranslate"
|
|
56
|
-
color="neutral"
|
|
57
|
-
mode="plain"
|
|
58
|
-
@click="isLanguageDialogOpen = true"
|
|
59
|
-
/>
|
|
28
|
+
<slot></slot>
|
|
60
29
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
:model-value="locale"
|
|
65
|
-
:options="languageOptions"
|
|
66
|
-
@update:model-value="setLocale($event)"
|
|
67
|
-
>
|
|
68
|
-
<template #description> {{ $t("onyx.languageSelect.subtitle") }} </template>
|
|
69
|
-
</OnyxSelectDialog>
|
|
70
|
-
</template>
|
|
30
|
+
<template v-if="slots.globalContextArea" #globalContextArea>
|
|
31
|
+
<slot name="globalContextArea"></slot>
|
|
32
|
+
</template>
|
|
71
33
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
:icon="iconCircleContrast"
|
|
75
|
-
color="neutral"
|
|
76
|
-
@click="isColorSchemeDialogOpen = true"
|
|
77
|
-
/>
|
|
34
|
+
<template v-if="slots.mobileActivePage" #mobileActivePage>
|
|
35
|
+
<slot name="mobileActivePage"></slot>
|
|
78
36
|
</template>
|
|
79
37
|
|
|
80
|
-
<
|
|
38
|
+
<template #contextArea>
|
|
39
|
+
<slot name="contextArea">
|
|
40
|
+
<!-- using lazy here so the locale switch code is not loaded when only one locale exists -->
|
|
41
|
+
<LazyLocaleSwitch v-if="locales.length > 1" />
|
|
42
|
+
<ColorSchemeSwitch />
|
|
43
|
+
</slot>
|
|
44
|
+
</template>
|
|
45
|
+
<!-- eslint-enable vue/require-explicit-slots -->
|
|
81
46
|
</OnyxNavBar>
|
|
82
47
|
</template>
|
package/app/error.vue
CHANGED
|
@@ -6,9 +6,23 @@ const props = defineProps<{
|
|
|
6
6
|
error: NuxtError;
|
|
7
7
|
}>();
|
|
8
8
|
|
|
9
|
+
defineSlots<{
|
|
10
|
+
/**
|
|
11
|
+
* Slot to override the default "Back to home" action(s).
|
|
12
|
+
*
|
|
13
|
+
* @params clearError - Function to clear the error and redirect to the home page
|
|
14
|
+
*/
|
|
15
|
+
actions?(props: { clearError: typeof _clearError }): unknown;
|
|
16
|
+
/**
|
|
17
|
+
* Slot to override the error details section.
|
|
18
|
+
* By default, an accordion will be displayed that shows the technical error details.
|
|
19
|
+
*/
|
|
20
|
+
details?(): unknown;
|
|
21
|
+
}>();
|
|
22
|
+
|
|
9
23
|
const localePath = useLocalePath();
|
|
10
24
|
|
|
11
|
-
const
|
|
25
|
+
const _clearError = () => clearError({ redirect: localePath("/") });
|
|
12
26
|
</script>
|
|
13
27
|
|
|
14
28
|
<template>
|
|
@@ -18,15 +32,20 @@ const handleError = () => clearError({ redirect: localePath("/") });
|
|
|
18
32
|
|
|
19
33
|
<div class="error__headline">
|
|
20
34
|
<OnyxHeadline is="h1">{{ props.error.message }}</OnyxHeadline>
|
|
21
|
-
|
|
35
|
+
|
|
36
|
+
<slot name="actions" :clear-error="_clearError">
|
|
37
|
+
<OnyxButton label="Back to home" @click="_clearError" />
|
|
38
|
+
</slot>
|
|
22
39
|
</div>
|
|
23
40
|
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
<slot name="details">
|
|
42
|
+
<OnyxAccordion>
|
|
43
|
+
<OnyxAccordionItem value="details">
|
|
44
|
+
<template #header>Technical error details</template>
|
|
45
|
+
<pre class="error__details">{{ JSON.stringify(props.error, null, 2) }}</pre>
|
|
46
|
+
</OnyxAccordionItem>
|
|
47
|
+
</OnyxAccordion>
|
|
48
|
+
</slot>
|
|
30
49
|
</div>
|
|
31
50
|
</App>
|
|
32
51
|
</template>
|
package/nuxt.config.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
2
2
|
export default defineNuxtConfig({
|
|
3
|
+
$meta: {
|
|
4
|
+
// the name is used to generate import aliases so the user can easily import
|
|
5
|
+
// any component or file from this layer from "#layers/onyx"
|
|
6
|
+
// see: https://nuxt.com/docs/4.x/guide/going-further/layers#named-layer-aliases
|
|
7
|
+
name: "onyx",
|
|
8
|
+
},
|
|
3
9
|
devtools: { enabled: true },
|
|
4
10
|
compatibilityDate: "2025-01-20",
|
|
5
11
|
typescript: { typeCheck: "build" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sit-onyx/nuxt-docs",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.107",
|
|
4
4
|
"description": "Nuxt layer/template for creating documentations with the onyx design system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Schwarz IT KG",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@nuxtjs/i18n": ">= 10",
|
|
32
32
|
"sass-embedded": ">= 1",
|
|
33
33
|
"@sit-onyx/icons": "^1.0.0-beta.24",
|
|
34
|
-
"@sit-onyx/nuxt": "^1.0.0-beta.
|
|
35
|
-
"sit-onyx": "^1.0.0-beta.
|
|
34
|
+
"@sit-onyx/nuxt": "^1.0.0-beta.291",
|
|
35
|
+
"sit-onyx": "^1.0.0-beta.291"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@fontsource-variable/source-code-pro": ">= 5",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"sass-embedded": "1.90.0",
|
|
48
48
|
"typescript": "5.9.2",
|
|
49
49
|
"vue": "3.5.18",
|
|
50
|
+
"@sit-onyx/nuxt": "^1.0.0-beta.291",
|
|
51
|
+
"@sit-onyx/icons": "^1.0.0-beta.24",
|
|
50
52
|
"@sit-onyx/shared": "^1.0.0-beta.4",
|
|
51
|
-
"
|
|
52
|
-
"sit-onyx": "^1.0.0-beta.290",
|
|
53
|
-
"@sit-onyx/icons": "^1.0.0-beta.24"
|
|
53
|
+
"sit-onyx": "^1.0.0-beta.291"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"dev": "pnpm dev:prepare && nuxi dev playground",
|
package/app/app.config.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { OnyxNavBarProps, OnyxNavItemProps } from "sit-onyx";
|
|
2
|
-
|
|
3
|
-
// TYPES
|
|
4
|
-
declare module "@nuxt/schema" {
|
|
5
|
-
interface AppConfigInput {
|
|
6
|
-
onyxDocs?: OnyxAppConfig;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface AppConfig {
|
|
10
|
-
onyxDocs: OnyxAppConfig & typeof defaultAppConfig;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type OnyxAppConfig = {
|
|
15
|
-
nav?: Partial<OnyxNavBarProps> & {
|
|
16
|
-
items?: NavItem[];
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type NavItem = OnyxNavItemProps & { children?: NavItem[] };
|
|
21
|
-
|
|
22
|
-
// CONFIG
|
|
23
|
-
const defaultAppConfig = {
|
|
24
|
-
nav: {
|
|
25
|
-
appName: "Documentation",
|
|
26
|
-
withBackButton: true,
|
|
27
|
-
},
|
|
28
|
-
} satisfies OnyxAppConfig;
|
|
29
|
-
|
|
30
|
-
export default defineAppConfig({
|
|
31
|
-
onyxDocs: defaultAppConfig,
|
|
32
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { extractLinkProps } from "sit-onyx";
|
|
3
|
-
import type { NavItem } from "../app.config";
|
|
4
|
-
|
|
5
|
-
const props = defineProps<NavItem>();
|
|
6
|
-
|
|
7
|
-
const localePath = useLocalePath();
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Same as `props` but without the `children` property to prevent console warnings when using `v-bind`.
|
|
11
|
-
*/
|
|
12
|
-
const navItemProps = computed(() => {
|
|
13
|
-
const { children: _, ...rest } = props;
|
|
14
|
-
return rest;
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Nav item link depending on the current locale / i18n.
|
|
19
|
-
*/
|
|
20
|
-
const localeLink = computed(() => {
|
|
21
|
-
if (!props.link) return;
|
|
22
|
-
const _link = extractLinkProps(props.link);
|
|
23
|
-
return { ..._link, href: localePath(_link.href) };
|
|
24
|
-
});
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<template>
|
|
28
|
-
<OnyxNavItem v-bind="navItemProps" :link="localeLink">
|
|
29
|
-
<template v-if="props.children?.length" #children>
|
|
30
|
-
<NavItem v-for="child in props.children" :key="child.label" v-bind="child" />
|
|
31
|
-
</template>
|
|
32
|
-
</OnyxNavItem>
|
|
33
|
-
</template>
|