@happydesigns/ui 0.17.5 → 0.19.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/README.md CHANGED
@@ -1,70 +1,96 @@
1
- # @happydesigns/ui
2
-
3
- [![npm version](https://img.shields.io/npm/v/%40happydesigns%2Fui?logo=npm)](https://www.npmjs.com/package/@happydesigns/ui)
4
- [![npm downloads](https://img.shields.io/npm/dm/%40happydesigns%2Fui?logo=npm)](https://www.npmjs.com/package/@happydesigns/ui)
5
- [![CI](https://github.com/happydesigns/ui/actions/workflows/ci.yml/badge.svg)](https://github.com/happydesigns/ui/actions/workflows/ci.yml)
6
-
7
- Reusable Nuxt layer for happydesigns websites, docs sites, and product apps.
8
-
9
- 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.
10
-
11
- [npm](https://www.npmjs.com/package/@happydesigns/ui) · [npmx](https://npmx.dev/package/@happydesigns/ui) · [GitHub](https://github.com/happydesigns/ui)
12
-
13
- ## Installation
14
-
15
- ```bash
16
- pnpm add @happydesigns/ui @nuxt/ui tailwindcss
17
- ```
18
-
19
- ```ts
20
- export default defineNuxtConfig({
21
- extends: ['@happydesigns/ui'],
22
- css: ['~/assets/css/main.css'],
23
- })
24
- ```
25
-
26
- Create the application's single Tailwind entry point:
27
-
28
- ```css
29
- @import "tailwindcss";
30
- @import "@nuxt/ui";
31
- @import "@happydesigns/ui/styles.css";
32
- ```
33
-
34
- 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.
35
-
36
- Run Nuxt preparation after changing dependencies or layer configuration:
37
-
38
- ```bash
39
- pnpm exec nuxt prepare
40
- ```
41
-
42
- ## Development
43
-
44
- ```bash
45
- pnpm install
46
- pnpm prepare
47
- pnpm dev
48
- pnpm build
49
- ```
50
-
51
- `pnpm dev` starts the playground app. `pnpm build` builds the playground.
52
-
53
- ## Product Docs
54
-
55
- The product docs live in `docs/` and are built with Docus.
56
-
57
- ```bash
58
- pnpm docs
59
- pnpm docs:build
60
- ```
61
-
62
- `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.
63
-
64
- 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.
65
-
66
- ## Package Scope
67
-
68
- 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.
69
-
70
- Use the product docs for usage guidance. Use the source files for implementation facts.
1
+ # @happydesigns/ui
2
+
3
+ [![npm version](https://img.shields.io/npm/v/%40happydesigns%2Fui?logo=npm)](https://www.npmjs.com/package/@happydesigns/ui)
4
+ [![npm downloads](https://img.shields.io/npm/dm/%40happydesigns%2Fui?logo=npm)](https://www.npmjs.com/package/@happydesigns/ui)
5
+ [![CI](https://github.com/happydesigns/ui/actions/workflows/ci.yml/badge.svg)](https://github.com/happydesigns/ui/actions/workflows/ci.yml)
6
+
7
+ Reusable Nuxt layer for happydesigns websites, docs sites, and product apps.
8
+
9
+ 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.
10
+
11
+ [npm](https://www.npmjs.com/package/@happydesigns/ui) · [npmx](https://npmx.dev/package/@happydesigns/ui) · [GitHub](https://github.com/happydesigns/ui)
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pnpm add @happydesigns/ui @nuxt/ui tailwindcss
17
+ ```
18
+
19
+ ```ts
20
+ export default defineNuxtConfig({
21
+ extends: ['@happydesigns/ui'],
22
+ css: ['~/assets/css/main.css'],
23
+ })
24
+ ```
25
+
26
+ Create the application's single Tailwind entry point:
27
+
28
+ ```css
29
+ @import "tailwindcss";
30
+ @import "@nuxt/ui";
31
+ @import "@happydesigns/ui/styles.css";
32
+ ```
33
+
34
+ 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.
35
+
36
+ Run Nuxt preparation after changing dependencies or layer configuration:
37
+
38
+ ```bash
39
+ pnpm exec nuxt prepare
40
+ ```
41
+
42
+ ## Content collections
43
+
44
+ The layer exports reusable schema profiles, but it does not register collection names, sources, or route prefixes for an application. Define those locally in the consumer's `content.config.ts`:
45
+
46
+ ```ts
47
+ import { collectionSchemas } from '@happydesigns/ui/schemas'
48
+ import { defineCollection, defineContentConfig } from '@nuxt/content'
49
+
50
+ export default defineContentConfig({
51
+ collections: {
52
+ news: defineCollection({
53
+ type: 'page',
54
+ source: 'news/**/*.md',
55
+ schema: collectionSchemas.article,
56
+ }),
57
+ legal: defineCollection({
58
+ type: 'page',
59
+ source: 'legal/**/*.md',
60
+ schema: collectionSchemas.content,
61
+ }),
62
+ },
63
+ })
64
+ ```
65
+
66
+ This keeps the shared field model convenient while leaving collection names, file structure, routing, indexes, and additional project schemas under application control.
67
+
68
+ ## Development
69
+
70
+ ```bash
71
+ pnpm install
72
+ pnpm prepare
73
+ pnpm dev
74
+ pnpm build
75
+ ```
76
+
77
+ `pnpm dev` starts the playground app. `pnpm build` builds the playground.
78
+
79
+ ## Product Docs
80
+
81
+ The product docs live in `docs/` and are built with Docus.
82
+
83
+ ```bash
84
+ pnpm docs
85
+ pnpm docs:build
86
+ ```
87
+
88
+ `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.
89
+
90
+ 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.
91
+
92
+ ## Package Scope
93
+
94
+ 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.
95
+
96
+ Use the product docs for usage guidance. Use the source files for implementation facts.
package/app/app.config.ts CHANGED
@@ -1,139 +1,143 @@
1
- import type { AppConfigInput as NuxtUiConfigInput } from '@nuxt/schema'
1
+ import type { AppConfigInput as NuxtUiConfigInput } from '@nuxt/schema'
2
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
- },
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
+ content: {
98
+ userCollection: 'user',
99
+ },
100
+
101
+ search: {
102
+ title: 'Search',
103
+ description: 'Search the site content.',
104
+ placeholder: 'Search content…',
105
+ resultLimit: 20,
106
+ links: [],
107
+ groups: [],
108
+ cache: {
109
+ sharedMaxAge: 300,
110
+ staleWhileRevalidate: 3600,
111
+ },
112
+ error: {
113
+ title: 'Search unavailable',
114
+ description: 'The search index could not be loaded.',
115
+ retryLabel: 'Try again',
116
+ },
117
+ collections: [],
118
+ } satisfies SearchConfig,
119
+
120
+ icons: {} as Record<string, string>,
121
+
122
+ toc: {
123
+ title: '',
124
+ },
125
+
126
+ date: {
127
+ locale: 'en',
128
+ options: {
129
+ year: 'numeric',
130
+ month: 'short',
131
+ day: 'numeric',
132
+ } as Intl.DateTimeFormatOptions,
133
+ datetimeOptions: {
134
+ year: 'numeric',
135
+ month: 'short',
136
+ day: 'numeric',
137
+ hour: 'numeric',
138
+ minute: 'numeric',
139
+ } as Intl.DateTimeFormatOptions,
140
+ },
137
141
  },
138
142
 
139
143
  // The object is validated above; this bridges Nuxt's generated runtime-complete layer type.
@@ -1,21 +1,26 @@
1
1
  <script setup lang="ts">
2
+ import type { PageCollections } from '@nuxt/content'
2
3
  import type { Component } from 'vue'
4
+ import type { PageCollectionName } from '../types/content'
3
5
 
4
6
  const props = withDefaults(defineProps<{
5
7
  path: string
8
+ /** Consumer-owned page collection containing the fragment. */
9
+ collection?: PageCollectionName
6
10
  prose?: boolean
7
11
  components?: Record<string, Component>
8
12
  }>(), {
13
+ collection: 'snippet',
9
14
  prose: true,
10
15
  components: undefined,
11
16
  })
12
17
 
13
18
  const path = computed(() => props.path)
14
- const key = computed(() => `snippet-${path.value}`)
19
+ const key = computed(() => `${props.collection}:${path.value}`)
15
20
 
16
21
  const { data: snippet } = await useAsyncData(
17
22
  key,
18
- () => queryCollection('snippet')
23
+ () => queryCollection(props.collection as keyof PageCollections)
19
24
  .path(path.value)
20
25
  .first(),
21
26
  )
@@ -1,6 +1,6 @@
1
- <script setup lang="ts" generic="C extends keyof PageCollections = 'article'">
2
- import type { PageCollections } from '@nuxt/content'
1
+ <script setup lang="ts" generic="C extends PageCollectionName = 'article'">
3
2
  import type { ArticleFilter } from '../../composables/useArticleList'
3
+ import type { PageCollectionName } from '../../types/content'
4
4
 
5
5
  const props = withDefaults(defineProps<{
6
6
  /** Optional fixed category to filter by */
@@ -1,26 +1,26 @@
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>
1
+ <script setup lang="ts">
2
+ import type { ContentLink, PageCollectionName } from '../../types/content'
3
+
4
+ interface HeaderBodyPage {
5
+ path?: string
6
+ authors?: string[]
7
+ links?: ContentLink[]
8
+ }
9
+
10
+ const props = defineProps<{
11
+ page?: HeaderBodyPage
12
+ collection?: PageCollectionName
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>
@@ -1,37 +1,37 @@
1
- <script setup lang="ts">
2
- import type { PageCollections } from '@nuxt/content'
3
-
4
- interface HeadlineMetaPage {
5
- path?: string
6
- category?: string
7
- date?: string
8
- dateEnd?: string
9
- location?: {
10
- name?: string
11
- url?: string
12
- }
13
- }
14
-
15
- const props = defineProps<{
16
- page?: HeadlineMetaPage
17
- collection?: keyof PageCollections
18
- }>()
19
-
20
- const { has } = useVariant(() => props.collection || 'article')
21
-
22
- const showCategory = computed(() => has('category').value && Boolean(props.page?.category))
23
- const showDates = computed(() => has('dates').value && Boolean(props.page?.date))
24
- const showLocation = computed(() => has('location').value && Boolean(props.page?.location?.name))
25
- </script>
26
-
27
- <template>
28
- <div class="all:flex flex-wrap items-center gap-x-3 gap-y-2 text-muted">
29
- <HCategory v-if="showCategory" :category="page?.category" />
30
-
31
- <span v-if="showCategory && showDates" class="all:hidden sm:inline opacity-50">&middot;</span>
32
- <HDates v-if="showDates" :date="page?.date" :date-end="page?.dateEnd" />
33
-
34
- <span v-if="(showCategory || showDates) && showLocation" class="all:hidden sm:inline opacity-50">&middot;</span>
35
- <HLocation v-if="showLocation" :location="page?.location" />
36
- </div>
37
- </template>
1
+ <script setup lang="ts">
2
+ import type { PageCollectionName } from '../../types/content'
3
+
4
+ interface HeadlineMetaPage {
5
+ path?: string
6
+ category?: string
7
+ date?: string
8
+ dateEnd?: string
9
+ location?: {
10
+ name?: string
11
+ url?: string
12
+ }
13
+ }
14
+
15
+ const props = defineProps<{
16
+ page?: HeadlineMetaPage
17
+ collection?: PageCollectionName
18
+ }>()
19
+
20
+ const { has } = useVariant(() => props.collection || 'article')
21
+
22
+ const showCategory = computed(() => has('category').value && Boolean(props.page?.category))
23
+ const showDates = computed(() => has('dates').value && Boolean(props.page?.date))
24
+ const showLocation = computed(() => has('location').value && Boolean(props.page?.location?.name))
25
+ </script>
26
+
27
+ <template>
28
+ <div class="all:flex flex-wrap items-center gap-x-3 gap-y-2 text-muted">
29
+ <HCategory v-if="showCategory" :category="page?.category" />
30
+
31
+ <span v-if="showCategory && showDates" class="all:hidden sm:inline opacity-50">&middot;</span>
32
+ <HDates v-if="showDates" :date="page?.date" :date-end="page?.dateEnd" />
33
+
34
+ <span v-if="(showCategory || showDates) && showLocation" class="all:hidden sm:inline opacity-50">&middot;</span>
35
+ <HLocation v-if="showLocation" :location="page?.location" />
36
+ </div>
37
+ </template>
@@ -1,6 +1,6 @@
1
- <script setup lang="ts" generic="C extends keyof PageCollections = 'article'">
2
- import type { PageCollections } from '@nuxt/content'
1
+ <script setup lang="ts" generic="C extends PageCollectionName = 'article'">
3
2
  import type { ArticleFilter } from '../../composables/useArticleList'
3
+ import type { PageCollectionName } from '../../types/content'
4
4
  import { useArticleListQuery } from '../../composables/useArticleListQuery'
5
5
 
6
6
  const props = withDefaults(defineProps<{
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
- import type { PageCollections } from '@nuxt/content'
2
+ import type { PageCollectionName } from '../../types/content'
3
3
 
4
4
  const { collection = 'article', path } = defineProps<{
5
- collection?: keyof PageCollections
5
+ collection?: PageCollectionName
6
6
  path?: string
7
7
  }>()
8
8
 
@@ -7,9 +7,10 @@ const props = defineProps<{
7
7
  config?: { user?: Partial<UserProps> }
8
8
  }>()
9
9
 
10
+ const appConfig = useAppConfig()
10
11
  const userProps = computed(() => ({ ...(props.config?.user ?? {}), ...(props.target ? { target: props.target } : {}) }))
11
12
 
12
- const resolvedAuthors = await resolveUsers(props.authors || [], userProps.value)
13
+ const resolvedAuthors = await resolveUsers(props.authors || [], userProps.value, appConfig.app.content.userCollection)
13
14
  </script>
14
15
 
15
16
  <template>