@happydesigns/ui 0.16.0 → 0.17.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 (44) hide show
  1. package/README.md +64 -53
  2. package/app/app.config.ts +138 -165
  3. package/app/app.vue +0 -2
  4. package/app/assets/css/styles.css +38 -0
  5. package/app/components/Carousel.vue +33 -0
  6. package/app/components/{content/Snippet.vue → Snippet.vue} +6 -2
  7. package/app/components/article/ArticleGridDate.vue +19 -16
  8. package/app/components/article/ArticleHeaderBody.vue +26 -20
  9. package/app/components/article/ArticleHeadlineMeta.vue +37 -26
  10. package/app/components/article/ArticleList.vue +1 -1
  11. package/app/components/article/ArticlePage.vue +1 -1
  12. package/app/components/footer/FooterColumns.vue +60 -101
  13. package/app/components/search/ContentSearch.client.vue +59 -0
  14. package/app/components/studio/StudioLoginButton.client.vue +11 -3
  15. package/app/components/traits/Category.vue +1 -1
  16. package/app/components/traits/CopyButton.vue +40 -32
  17. package/app/components/traits/Links.vue +21 -17
  18. package/app/components/traits/Surround.vue +5 -6
  19. package/app/components/traits/Toc.vue +18 -16
  20. package/app/composables/useArticleList.ts +29 -27
  21. package/app/composables/useClipboard.ts +48 -26
  22. package/app/composables/useContentSearchData.ts +42 -0
  23. package/app/composables/useNavigationLinks.ts +40 -0
  24. package/app/composables/usePageContent.ts +1 -3
  25. package/app/composables/usePageSeo.ts +7 -15
  26. package/app/internal/pageLayout.ts +7 -0
  27. package/app/layouts/article.vue +137 -120
  28. package/app/layouts/content.vue +63 -59
  29. package/app/types/config.ts +91 -13
  30. package/app/utils/createContentSearchLoader.ts +45 -0
  31. package/app/utils/formatDate.ts +1 -1
  32. package/app/utils/formatDateTime.ts +1 -1
  33. package/app/utils/isNavigationTargetActive.ts +12 -0
  34. package/app/utils/resolveUsers.ts +56 -42
  35. package/nuxt.config.ts +1 -13
  36. package/package.json +17 -9
  37. package/schemas/collections.ts +4 -0
  38. package/schemas/indexes.ts +10 -0
  39. package/server/api/navigation.json.get.ts +11 -0
  40. package/server/api/search.json.get.ts +11 -0
  41. package/server/utils/contentSearch.ts +67 -0
  42. package/shared/types/app-config.d.ts +23 -0
  43. package/app/assets/css/main.css +0 -14
  44. package/app/components/content/Carousel.vue +0 -11
package/README.md CHANGED
@@ -1,53 +1,64 @@
1
- # @happydesigns/ui
2
-
3
- Reusable Nuxt layer for happydesigns websites, docs sites, and product apps.
4
-
5
- The package provides shared Nuxt setup, Nuxt UI conventions, content collection schemas, public `H*` components, composables, variants, and app config conventions. Projects extend the layer and keep project-specific routes, content, branding, and deployment settings in the project that owns them.
6
-
7
- ## Installation
8
-
9
- ```bash
10
- pnpm add @happydesigns/ui
11
- ```
12
-
13
- ```ts
14
- export default defineNuxtConfig({
15
- extends: ['@happydesigns/ui'],
16
- })
17
- ```
18
-
19
- Run Nuxt preparation after changing dependencies or layer configuration:
20
-
21
- ```bash
22
- pnpm exec nuxt prepare
23
- ```
24
-
25
- ## Development
26
-
27
- ```bash
28
- pnpm install
29
- pnpm prepare
30
- pnpm dev
31
- pnpm build
32
- ```
33
-
34
- `pnpm dev` starts the playground app. `pnpm build` builds the playground.
35
-
36
- ## Product Docs
37
-
38
- The product docs live in `docs/` and are built with Docus.
39
-
40
- ```bash
41
- pnpm docs
42
- pnpm docs:build
43
- ```
44
-
45
- `pnpm docs:build` generates a static Docus build in `docs/.output/public`. Use `pnpm docs:build:server` only when the deployment target needs a server-capable Docus build for live MCP support.
46
-
47
- The docs explain how to use the layer, content model, components, composables, variants, and configuration. Component props, slots, examples, variants, and collection tables are generated from the package source where possible.
48
-
49
- ## Package Scope
50
-
51
- This package owns reusable interface and content foundations. It does not own project copy, customer-specific routes, final brand assets, deployment settings, or product-specific domain behavior.
52
-
53
- Use the product docs for usage guidance. Use the source files for implementation facts.
1
+ # @happydesigns/ui
2
+
3
+ Reusable Nuxt layer for happydesigns websites, docs sites, and product apps.
4
+
5
+ The package provides shared Nuxt setup, Nuxt UI conventions, content collection schemas, public `H*` components, composables, variants, and app config conventions. Projects extend the layer and keep project-specific routes, content, branding, and deployment settings in the project that owns them.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add @happydesigns/ui @nuxt/ui tailwindcss
11
+ ```
12
+
13
+ ```ts
14
+ export default defineNuxtConfig({
15
+ extends: ['@happydesigns/ui'],
16
+ css: ['~/assets/css/main.css'],
17
+ })
18
+ ```
19
+
20
+ Create the application's single Tailwind entry point:
21
+
22
+ ```css
23
+ @import "tailwindcss";
24
+ @import "@nuxt/ui";
25
+ @import "@happydesigns/ui/styles.css";
26
+ ```
27
+
28
+ Do not register another stylesheet that imports Tailwind or Nuxt UI. Keeping one compilation context ensures that Nuxt UI's generated responsive and color-mode variants share the application's theme and source graph.
29
+
30
+ Run Nuxt preparation after changing dependencies or layer configuration:
31
+
32
+ ```bash
33
+ pnpm exec nuxt prepare
34
+ ```
35
+
36
+ ## Development
37
+
38
+ ```bash
39
+ pnpm install
40
+ pnpm prepare
41
+ pnpm dev
42
+ pnpm build
43
+ ```
44
+
45
+ `pnpm dev` starts the playground app. `pnpm build` builds the playground.
46
+
47
+ ## Product Docs
48
+
49
+ The product docs live in `docs/` and are built with Docus.
50
+
51
+ ```bash
52
+ pnpm docs
53
+ pnpm docs:build
54
+ ```
55
+
56
+ `pnpm docs:build` generates a static Docus build in `docs/.output/public`. Use `pnpm docs:build:server` only when the deployment target needs a server-capable Docus build for live MCP support.
57
+
58
+ The docs explain how to use the layer, content model, components, composables, variants, and configuration. Component props, slots, examples, variants, and collection tables are generated from the package source where possible.
59
+
60
+ ## Package Scope
61
+
62
+ This package owns reusable interface and content foundations. It does not own project copy, customer-specific routes, final brand assets, deployment settings, or product-specific domain behavior.
63
+
64
+ Use the product docs for usage guidance. Use the source files for implementation facts.
package/app/app.config.ts CHANGED
@@ -1,168 +1,141 @@
1
- import type { BadgeProps, ButtonProps, FooterColumn } from '@nuxt/ui'
2
- import type { QueryConfig } from './types/config'
3
-
4
- export * from './types/config'
5
-
6
- export default defineAppConfig({
7
- variants: {
8
- // UI feature variants — config overrides (extends defined in nuxt.config.ts)
9
- user: { config: { user: { target: '_blank' } } },
10
- backButton: { config: { backButton: { icon: 'i-ph-arrow-left', label: 'Back' } as Pick<ButtonProps, 'icon' | 'label' | 'to'> } },
11
- copyButton: {
12
- config: {
13
- copyButton: {
14
- icon: 'i-ph-link-simple-duotone',
15
- label: 'Copy URL',
16
- successIcon: 'i-lucide-copy-check',
17
- successLabel: 'Link copied to clipboard',
18
- },
19
- },
20
- },
21
- separator: { config: { separator: { buttons: [], separator: 'or' } } },
22
- surround: {
23
- config: {
24
- surround: {
25
- show: true,
26
- prevIcon: 'i-lucide-arrow-left',
27
- nextIcon: 'i-lucide-arrow-right',
28
- prevLabel: 'Previous',
29
- nextLabel: 'Next',
30
- },
31
- },
32
- },
33
-
34
- // Collection variants — runtime config overrides only
35
- article: {
36
- config: {
37
- query: {
38
- fields: ['title', 'description', 'published', 'date'],
39
- order: { field: 'date', direction: 'DESC' },
40
- where: [{ field: 'published', operator: '=', value: true }],
41
- } as QueryConfig,
42
- categories: {} as Record<string, BadgeProps>,
43
- breadcrumbs: [],
44
- list: {
45
- itemsPerPage: 12,
46
- labelAll: 'All',
47
- noResultsMessage: 'No articles found.',
48
- noResultsIcon: 'i-ph-article-ny-times-light',
49
- },
50
- },
51
- },
52
- event: {
53
- config: {
54
- query: {
55
- fields: ['title', 'description', 'published', 'date', 'dateEnd', 'location'],
56
- order: { field: 'date', direction: 'DESC' },
57
- where: [{ field: 'published', operator: '=', value: true }],
58
- } as QueryConfig,
59
- categories: {} as Record<string, BadgeProps>,
60
- breadcrumbs: [],
61
- list: {
62
- itemsPerPage: 12,
63
- labelAll: 'All',
64
- noResultsMessage: 'No events found.',
65
- noResultsIcon: 'i-ph-calendar-blank',
66
- },
67
- },
68
- },
1
+ import type { AppConfigInput as NuxtUiConfigInput } from '@nuxt/schema'
2
+ import type { BadgeProps, ButtonProps } from '@nuxt/ui'
3
+ import type { AppConfigInput as LayerAppConfigInput } from 'nuxt/schema'
4
+ import type { QueryConfig, SearchConfig } from './types/config'
5
+
6
+ export * from './types/config'
7
+
8
+ const ui = {
9
+ main: {
10
+ base: 'wrap-break-word',
11
+ },
12
+ } satisfies NonNullable<NuxtUiConfigInput['ui']>
13
+
14
+ export default defineAppConfig({
15
+ variants: {
16
+ // UI feature variants — config overrides (extends defined in nuxt.config.ts)
17
+ user: { config: { user: { target: '_blank' } } },
18
+ backButton: { config: { backButton: { icon: 'i-ph-arrow-left', label: 'Back' } as Pick<ButtonProps, 'icon' | 'label' | 'to'> } },
19
+ copyButton: {
20
+ config: {
21
+ copyButton: {
22
+ icon: 'i-ph-link-simple-duotone',
23
+ label: 'Copy URL',
24
+ successIcon: 'i-lucide-copy-check',
25
+ successLabel: 'Link copied to clipboard',
26
+ errorIcon: 'i-lucide-copy-x',
27
+ errorLabel: 'Link could not be copied',
28
+ },
29
+ },
30
+ },
31
+ separator: { config: { separator: { buttons: [], separator: 'or' } } },
32
+ surround: {
33
+ config: {
34
+ surround: {
35
+ show: true,
36
+ prevIcon: 'i-lucide-arrow-left',
37
+ nextIcon: 'i-lucide-arrow-right',
38
+ prevLabel: 'Previous',
39
+ nextLabel: 'Next',
40
+ },
41
+ },
42
+ },
43
+
44
+ // Collection variants — runtime config overrides only
45
+ article: {
46
+ config: {
47
+ query: {
48
+ fields: ['title', 'description', 'published', 'date'],
49
+ order: { field: 'date', direction: 'DESC' },
50
+ where: [{ field: 'published', operator: '=', value: true }],
51
+ } as QueryConfig,
52
+ categories: {} as Record<string, BadgeProps>,
53
+ breadcrumbs: [],
54
+ list: {
55
+ itemsPerPage: 12,
56
+ labelAll: 'All',
57
+ noResultsMessage: 'No articles found.',
58
+ noResultsIcon: 'i-ph-article-ny-times-light',
59
+ },
60
+ },
61
+ },
62
+ event: {
63
+ config: {
64
+ query: {
65
+ fields: ['title', 'description', 'published', 'date', 'dateEnd', 'location'],
66
+ order: { field: 'date', direction: 'DESC' },
67
+ where: [{ field: 'published', operator: '=', value: true }],
68
+ } as QueryConfig,
69
+ categories: {} as Record<string, BadgeProps>,
70
+ breadcrumbs: [],
71
+ list: {
72
+ itemsPerPage: 12,
73
+ labelAll: 'All',
74
+ noResultsMessage: 'No events found.',
75
+ noResultsIcon: 'i-ph-calendar-blank',
76
+ },
77
+ },
78
+ },
79
+ },
80
+
81
+ app: {
82
+ meta: {
83
+ copyright: {},
84
+ socials: [],
85
+ github: {
86
+ repo: '',
87
+ branch: 'main',
88
+ dir: 'content',
89
+ },
90
+ },
91
+
92
+ links: {
93
+ header: [],
94
+ footer: [],
95
+ },
96
+
97
+ search: {
98
+ title: 'Search',
99
+ description: 'Search the site content.',
100
+ placeholder: 'Search content…',
101
+ resultLimit: 20,
102
+ links: [],
103
+ groups: [],
104
+ cache: {
105
+ sharedMaxAge: 300,
106
+ staleWhileRevalidate: 3600,
107
+ },
108
+ error: {
109
+ title: 'Search unavailable',
110
+ description: 'The search index could not be loaded.',
111
+ retryLabel: 'Try again',
112
+ },
113
+ collections: [],
114
+ } satisfies SearchConfig,
115
+
116
+ icons: {} as Record<string, string>,
117
+
118
+ toc: {
119
+ title: '',
120
+ },
121
+
122
+ date: {
123
+ locale: 'en',
124
+ options: {
125
+ year: 'numeric',
126
+ month: 'short',
127
+ day: 'numeric',
128
+ } as Intl.DateTimeFormatOptions,
129
+ datetimeOptions: {
130
+ year: 'numeric',
131
+ month: 'short',
132
+ day: 'numeric',
133
+ hour: 'numeric',
134
+ minute: 'numeric',
135
+ } as Intl.DateTimeFormatOptions,
136
+ },
69
137
  },
70
138
 
71
- app: {
72
- meta: {
73
- copyright: {},
74
- socials: [],
75
- github: {
76
- repo: '',
77
- branch: 'main',
78
- dir: 'content',
79
- },
80
- },
81
-
82
- links: {
83
- header: [],
84
- footer: [],
85
- },
86
-
87
- icons: {} as Record<string, string>,
88
-
89
- toc: {
90
- title: '',
91
- },
92
-
93
- date: {
94
- locale: 'en',
95
- options: {
96
- year: 'numeric',
97
- month: 'short',
98
- day: 'numeric',
99
- } as Intl.DateTimeFormatOptions,
100
- datetimeOptions: {
101
- year: 'numeric',
102
- month: 'short',
103
- day: 'numeric',
104
- hour: 'numeric',
105
- minute: 'numeric',
106
- } as Intl.DateTimeFormatOptions,
107
- },
108
- },
109
-
110
- ui: {
111
- main: {
112
- base: 'wrap-break-word',
113
- },
114
- footerColumns: {
115
- slots: {},
116
- columns: {},
117
- },
118
- },
139
+ // The object is validated above; this bridges Nuxt's generated runtime-complete layer type.
140
+ ui: ui as unknown as LayerAppConfigInput['ui'],
119
141
  })
120
-
121
- declare module '@nuxt/schema' {
122
- interface AppConfigInput {
123
- app?: {
124
- [key: string]: any
125
- meta?: {
126
- copyright?: {
127
- /** The year in which the copyright was issued */
128
- copyrightYear?: number
129
- /** The name of the copyright holder */
130
- copyrightHolder?: string
131
- /** Optional homepage URL of the copyright holder; omit it to render plain text */
132
- copyrightHomepage?: string
133
- }
134
- /** Social button definitions (e.g. Instagram, Facebook, GitHub) */
135
- socials?: Array<ButtonProps>
136
- /** Configuration for GitHub repository info */
137
- github?: {
138
- /** The repository identifier (e.g. 'sfbiberach/schachfreunde-biberach.de') */
139
- repo?: string
140
- /** The branch name (e.g. 'main') */
141
- branch?: string
142
- /** The directory where the content is stored (e.g. 'content') */
143
- dir?: string
144
- }
145
- }
146
- /** Link collections for various UI regions (e.g. header, footer) */
147
- links?: {
148
- header?: Array<FooterColumn>
149
- footer?: Array<FooterColumn>
150
- }
151
- /** Configuration for the table of contents */
152
- toc?: {
153
- /** The default title to be shown in the table of contents */
154
- title?: string
155
- }
156
- /** A mapping of internal identifier strings to icon strings */
157
- icons?: Record<string, string>
158
- date?: {
159
- /** The locale used for date formatting (e.g. 'en', 'de') */
160
- locale?: string
161
- /** Options for Intl.DateTimeFormat for dates */
162
- options?: Intl.DateTimeFormatOptions
163
- /** Options for Intl.DateTimeFormat for datetimes */
164
- datetimeOptions?: Intl.DateTimeFormatOptions
165
- }
166
- }
167
- }
168
- }
package/app/app.vue CHANGED
@@ -1,11 +1,9 @@
1
1
  <template>
2
2
  <UApp>
3
- <AppHeader />
4
3
  <UMain>
5
4
  <NuxtLayout>
6
5
  <NuxtPage />
7
6
  </NuxtLayout>
8
7
  </UMain>
9
- <AppFooter />
10
8
  </UApp>
11
9
  </template>
@@ -0,0 +1,38 @@
1
+ @custom-variant all (&);
2
+
3
+ @layer components {
4
+ :where(.h-content) p .iconify {
5
+ display: inline-block;
6
+ /* OG metadata tools may parse this rule without Tailwind theme context. */
7
+ margin-inline-end: 0.25em;
8
+ inline-size: 1em;
9
+ block-size: 1em;
10
+ transform: translateY(-1px);
11
+ }
12
+ }
13
+
14
+ .footer-cols-left,
15
+ .footer-cols-center,
16
+ .footer-cols-right {
17
+ display: contents;
18
+ }
19
+
20
+ .footer-cols-root {
21
+ grid-template-columns: minmax(0, 1fr);
22
+ }
23
+
24
+ @media (min-width: theme(--breakpoint-lg)) {
25
+ .footer-cols-root {
26
+ grid-template-columns: repeat(var(--cols-lg, auto-fit), minmax(min(100%, 12rem), 1fr));
27
+ }
28
+ }
29
+
30
+ @media (min-width: theme(--breakpoint-xl)) {
31
+ .footer-cols-root {
32
+ grid-template-columns: repeat(var(--cols-xl, auto-fit), minmax(min(100%, 12rem), 1fr));
33
+ }
34
+ }
35
+
36
+ .footer-cols-root p:last-child {
37
+ margin-bottom: 0;
38
+ }
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ type CarouselItem = string | {
3
+ src: string
4
+ alt: string
5
+ }
6
+
7
+ const props = withDefaults(defineProps<{
8
+ items: CarouselItem[]
9
+ label?: string
10
+ }>(), {
11
+ label: 'Media carousel',
12
+ })
13
+
14
+ function resolveItem(item: CarouselItem) {
15
+ return typeof item === 'string' ? { src: item, alt: '' } : item
16
+ }
17
+ </script>
18
+
19
+ <template>
20
+ <UCarousel
21
+ v-slot="{ item }"
22
+ :items="props.items"
23
+ :aria-label="props.label"
24
+ :ui="{ item: 'basis-full sm:basis-1/2' }"
25
+ dots
26
+ >
27
+ <ProseImg
28
+ :src="resolveItem(item).src"
29
+ :alt="resolveItem(item).alt"
30
+ class="w-full rounded-lg"
31
+ />
32
+ </UCarousel>
33
+ </template>
@@ -10,10 +10,13 @@ const props = withDefaults(defineProps<{
10
10
  components: undefined,
11
11
  })
12
12
 
13
+ const path = computed(() => props.path)
14
+ const key = computed(() => `snippet-${path.value}`)
15
+
13
16
  const { data: snippet } = await useAsyncData(
14
- `snippet-${props.path}`,
17
+ key,
15
18
  () => queryCollection('snippet')
16
- .path(props.path)
19
+ .path(path.value)
17
20
  .first(),
18
21
  )
19
22
 
@@ -26,6 +29,7 @@ const components = computed(() => props.components)
26
29
  :value="snippet"
27
30
  :prose="props.prose"
28
31
  :components="components"
32
+ class="h-content"
29
33
  v-bind="$attrs"
30
34
  />
31
35
  </template>
@@ -1,16 +1,19 @@
1
- <script setup lang="ts">
2
- import formatDate from '../../utils/formatDate'
3
-
4
- defineProps<{
5
- article: any
6
- }>()
7
- </script>
8
-
9
- <template>
10
- <time v-if="article.date" class="text-xs text-muted">
11
- {{ formatDate(article.date) }}
12
- <template v-if="article.dateEnd && article.date !== article.dateEnd">
13
- - {{ formatDate(article.dateEnd) }}
14
- </template>
15
- </time>
16
- </template>
1
+ <script setup lang="ts">
2
+ import formatDate from '../../utils/formatDate'
3
+
4
+ defineProps<{
5
+ article: {
6
+ date?: string
7
+ dateEnd?: string
8
+ }
9
+ }>()
10
+ </script>
11
+
12
+ <template>
13
+ <time v-if="article.date" class="text-xs text-muted">
14
+ {{ formatDate(article.date) }}
15
+ <template v-if="article.dateEnd && article.date !== article.dateEnd">
16
+ - {{ formatDate(article.dateEnd) }}
17
+ </template>
18
+ </time>
19
+ </template>
@@ -1,20 +1,26 @@
1
- <script setup lang="ts">
2
- import type { PageCollections } from '@nuxt/content'
3
-
4
- const props = defineProps<{
5
- page?: any
6
- collection?: keyof PageCollections
7
- }>()
8
-
9
- const { has } = useVariant(() => props.collection || 'article')
10
- const hasAuthors = has('authors')
11
- const hasLinks = has('links')
12
- </script>
13
-
14
- <template>
15
- <div class="mt-4 all:flex flex-wrap items-center gap-3">
16
- <HAuthors v-if="hasAuthors" :authors="page?.authors" />
17
- <HLinks v-if="hasLinks && page?.links?.length" :links="page?.links" />
18
- <slot />
19
- </div>
20
- </template>
1
+ <script setup lang="ts">
2
+ import type { PageCollections } from '@nuxt/content'
3
+
4
+ interface HeaderBodyPage {
5
+ path?: string
6
+ authors?: string[]
7
+ links?: PageCollections['event']['links']
8
+ }
9
+
10
+ const props = defineProps<{
11
+ page?: HeaderBodyPage
12
+ collection?: keyof PageCollections
13
+ }>()
14
+
15
+ const { has } = useVariant(() => props.collection || 'article')
16
+ const hasAuthors = has('authors')
17
+ const hasLinks = has('links')
18
+ </script>
19
+
20
+ <template>
21
+ <div class="mt-4 all:flex flex-wrap items-center gap-3">
22
+ <HAuthors v-if="hasAuthors" :authors="page?.authors" />
23
+ <HLinks v-if="hasLinks && page?.links?.length" :links="page.links" />
24
+ <slot />
25
+ </div>
26
+ </template>