@happydesigns/ui 0.13.5 → 0.15.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 (40) hide show
  1. package/README.md +53 -94
  2. package/app/app.config.ts +168 -169
  3. package/app/app.vue +11 -0
  4. package/app/components/article/ArticleGrid.vue +134 -158
  5. package/app/components/article/ArticleGridDate.vue +1 -1
  6. package/app/components/article/ArticleHeaderBody.vue +20 -20
  7. package/app/components/article/ArticleHeadlineMeta.vue +26 -26
  8. package/app/components/article/ArticleList.vue +80 -95
  9. package/app/components/article/ArticlePage.vue +17 -16
  10. package/app/components/footer/FooterColumnHeading.vue +5 -5
  11. package/app/components/footer/FooterColumns.vue +16 -20
  12. package/app/components/footer/FooterCopyright.vue +35 -29
  13. package/app/components/traits/Authors.vue +21 -20
  14. package/app/components/traits/BackButton.vue +15 -26
  15. package/app/components/traits/Category.vue +9 -9
  16. package/app/components/traits/CopyButton.vue +32 -39
  17. package/app/components/traits/Dates.vue +20 -20
  18. package/app/components/traits/Links.vue +17 -17
  19. package/app/components/traits/Location.vue +20 -20
  20. package/app/components/traits/Separator.vue +21 -26
  21. package/app/components/traits/SeparatorButtons.vue +54 -56
  22. package/app/components/traits/Surround.vue +51 -60
  23. package/app/components/traits/Toc.vue +16 -16
  24. package/app/composables/useArticleList.ts +13 -15
  25. package/app/composables/useArticleListQuery.ts +54 -0
  26. package/app/composables/useCategoryBadge.ts +27 -27
  27. package/app/composables/useClipboard.ts +26 -26
  28. package/app/composables/usePageContent.ts +18 -18
  29. package/app/composables/usePageSeo.ts +30 -30
  30. package/app/layouts/article.vue +120 -128
  31. package/app/layouts/content.vue +59 -67
  32. package/app/layouts/default.vue +1 -10
  33. package/app/types/config.ts +13 -6
  34. package/app/utils/resolveUsers.ts +32 -3
  35. package/content.config.ts +6 -6
  36. package/nuxt.config.ts +72 -80
  37. package/package.json +29 -18
  38. package/schemas/collections.ts +46 -46
  39. package/schemas/index.ts +2 -2
  40. package/schemas/traits.ts +90 -90
@@ -1,7 +1,6 @@
1
1
  <script setup lang="ts" generic="T extends FooterColumnLink">
2
- import type { FooterColumn, FooterColumnLink, FooterColumnsProps, FooterColumnsSlots } from '@nuxt/ui'
2
+ import type { FooterColumn, FooterColumnLink, FooterColumnsProps, FooterColumnsSlots, SlotClass } from '@nuxt/ui'
3
3
  import { useAppConfig } from '#imports'
4
- import { tv } from 'tailwind-variants'
5
4
 
6
5
  interface HFooterColumnProps<T extends FooterColumnLink> extends /* @vue-ignore */ FooterColumnsProps<T> {
7
6
  lgCols?: number
@@ -23,28 +22,25 @@ const rightCount = slots.right ? slots.right({}).length : 0
23
22
  const lgCount = Math.max(leftCount, centerCount, rightCount)
24
23
  const totalCount = leftCount + centerCount + rightCount
25
24
 
26
- const ui = tv({
27
- extend: tv({
28
- extend: tv({ slots: {
29
- root: 'footer-cols-root all:grid grid-flow-row gap-y-12 gap-x-8',
30
- left: 'footer-cols-left',
31
- center: 'footer-cols-center',
32
- right: 'footer-cols-right',
33
- } }),
34
- slots: appConfig.ui?.footerColumns?.slots || {},
35
- }),
36
- slots: props.ui || {},
37
- })()
25
+ function withLayoutClass(base: string, override?: SlotClass): SlotClass {
26
+ if (typeof override === 'function')
27
+ return defaults => [base, override(defaults)]
28
+
29
+ return [base, override]
30
+ }
31
+
32
+ const ui = computed(() => ({
33
+ ...props.ui,
34
+ root: withLayoutClass('footer-cols-root all:grid grid-flow-row gap-y-12 gap-x-8', props.ui?.root),
35
+ left: withLayoutClass('footer-cols-left', props.ui?.left),
36
+ center: withLayoutClass('footer-cols-center', props.ui?.center),
37
+ right: withLayoutClass('footer-cols-right', props.ui?.right),
38
+ }))
38
39
  </script>
39
40
 
40
41
  <template>
41
42
  <UFooterColumns
42
- v-bind="props" :columns="footerColumns" :ui="{
43
- root: ui.root?.() ?? '',
44
- left: ui.left?.() ?? '',
45
- center: ui.center?.() ?? '',
46
- right: ui.right?.() ?? '',
47
- }"
43
+ v-bind="props" :columns="footerColumns" :ui="ui"
48
44
  :style="{
49
45
  '--cols-sm': 1,
50
46
  '--cols-lg': props.lgCols ?? lgCount,
@@ -1,29 +1,35 @@
1
- <script setup lang="ts">
2
- const props = defineProps<{
3
- copyrightYear?: number
4
- copyrightHolder?: string
5
- copyrightHomepage?: string
6
- }>()
7
-
8
- const appConfig = useAppConfig()
9
-
10
- const copyrightYear = props.copyrightYear ?? new Date().getFullYear()
11
- const copyrightHolder = props.copyrightHolder ?? appConfig.app?.meta?.copyright?.copyrightHolder ?? ''
12
- const copyrightHomepage = props.copyrightHomepage ?? appConfig.app?.meta?.copyright?.copyrightHomepage ?? ''
13
- </script>
14
-
15
- <template>
16
- <div>
17
- <template v-if="$slots.copyright">
18
- <slot name="copyright" :copyright-year :copyright-homepage :copyright-holder />
19
- </template>
20
- <template v-else>
21
- <p class="text-muted text-sm">
22
- Copyright © {{ copyrightYear }}
23
- <ULink :to="copyrightHomepage" target="_blank">
24
- {{ copyrightHolder }}
25
- </ULink>
26
- </p>
27
- </template>
28
- </div>
29
- </template>
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ copyrightYear?: number
4
+ copyrightHolder?: string
5
+ copyrightHomepage?: string
6
+ }>()
7
+
8
+ interface CopyrightConfig {
9
+ copyrightHolder?: string
10
+ copyrightHomepage?: string
11
+ }
12
+
13
+ const appConfig = useAppConfig()
14
+ const copyright = appConfig.app?.meta?.copyright as CopyrightConfig | undefined
15
+
16
+ const copyrightYear = props.copyrightYear ?? new Date().getFullYear()
17
+ const copyrightHolder = props.copyrightHolder ?? copyright?.copyrightHolder ?? ''
18
+ const copyrightHomepage = props.copyrightHomepage ?? copyright?.copyrightHomepage ?? ''
19
+ </script>
20
+
21
+ <template>
22
+ <div>
23
+ <template v-if="$slots.copyright">
24
+ <slot name="copyright" :copyright-year :copyright-homepage :copyright-holder />
25
+ </template>
26
+ <template v-else>
27
+ <p class="text-muted text-sm">
28
+ Copyright © {{ copyrightYear }}
29
+ <ULink :to="copyrightHomepage" target="_blank">
30
+ {{ copyrightHolder }}
31
+ </ULink>
32
+ </p>
33
+ </template>
34
+ </div>
35
+ </template>
@@ -1,20 +1,21 @@
1
- <script setup lang="ts">
2
- const props = defineProps<{
3
- authors?: string[]
4
- target?: string
5
- }>()
6
-
7
- const { config } = useVariant('user')
8
-
9
- const userProps = computed(() => ({ ...(config.value.user ?? {}), ...(props.target ? { target: props.target } : {}) }))
10
-
11
- const resolvedAuthors = await resolveUsers(props.authors || [], userProps.value)
12
- </script>
13
-
14
- <template>
15
- <UUser
16
- v-for="(author, index) in resolvedAuthors"
17
- :key="index"
18
- v-bind="author"
19
- />
20
- </template>
1
+ <script setup lang="ts">
2
+ import type { UserProps } from '@nuxt/ui'
3
+
4
+ const props = defineProps<{
5
+ authors?: string[]
6
+ target?: string
7
+ config?: { user?: Partial<UserProps> }
8
+ }>()
9
+
10
+ const userProps = computed(() => ({ ...(props.config?.user ?? {}), ...(props.target ? { target: props.target } : {}) }))
11
+
12
+ const resolvedAuthors = await resolveUsers(props.authors || [], userProps.value)
13
+ </script>
14
+
15
+ <template>
16
+ <UUser
17
+ v-for="(author, index) in resolvedAuthors"
18
+ :key="index"
19
+ v-bind="author"
20
+ />
21
+ </template>
@@ -1,26 +1,15 @@
1
- <script setup lang="ts">
2
- import type { RouteLocationRaw } from 'vue-router'
3
-
4
- const props = defineProps<{
5
- to?: RouteLocationRaw
6
- icon?: string
7
- label?: string
8
- }>()
9
-
10
- const { config } = useVariant('backButton')
11
-
12
- const resolvedIcon = computed(() => props.icon ?? config.value.backButton?.icon)
13
- const resolvedLabel = computed(() => props.label ?? config.value.backButton?.label)
14
- const resolvedTo = computed(() => props.to ?? config.value.backButton?.to)
15
- </script>
16
-
17
- <template>
18
- <UButton
19
- color="primary"
20
- variant="ghost"
21
- :icon="resolvedIcon"
22
- :to="resolvedTo"
23
- >
24
- {{ resolvedLabel }}
25
- </UButton>
26
- </template>
1
+ <script setup lang="ts">
2
+ import type { RouteLocationRaw } from 'vue-router'
3
+
4
+ defineProps<{
5
+ to?: RouteLocationRaw
6
+ icon?: string
7
+ label?: string
8
+ }>()
9
+ </script>
10
+
11
+ <template>
12
+ <UButton color="primary" variant="ghost" :icon="icon" :to="to">
13
+ {{ label }}
14
+ </UButton>
15
+ </template>
@@ -1,9 +1,9 @@
1
- <script setup lang="ts">
2
- defineProps<{
3
- category?: string
4
- }>()
5
- </script>
6
-
7
- <template>
8
- <span class="text-primary-500 dark:text-primary-400 font-medium">{{ category }}</span>
9
- </template>
1
+ <script setup lang="ts">
2
+ defineProps<{
3
+ category?: string
4
+ }>()
5
+ </script>
6
+
7
+ <template>
8
+ <span class="text-primary-500 dark:text-primary-400 font-medium">{{ category }}</span>
9
+ </template>
@@ -1,39 +1,32 @@
1
- <script setup lang="ts">
2
- const props = defineProps<{
3
- path?: string
4
- icon?: string
5
- label?: string
6
- successIcon?: string
7
- successLabel?: string
8
- }>()
9
-
10
- const { config } = useVariant('copyButton')
11
-
12
- const resolvedIcon = computed(() => props.icon ?? config.value.copyButton?.icon)
13
- const resolvedLabel = computed(() => props.label ?? config.value.copyButton?.label)
14
- const resolvedSuccessIcon = computed(() => props.successIcon ?? config.value.copyButton?.successIcon)
15
- const resolvedSuccessLabel = computed(() => props.successLabel ?? config.value.copyButton?.successLabel)
16
-
17
- const { copy } = useClipboard()
18
- const url = useRequestURL()
19
- const route = useRoute()
20
-
21
- function copyLink() {
22
- copy(`${url.origin}${props.path ?? route.path}`, {
23
- id: 'article-copy-link',
24
- title: resolvedSuccessLabel.value,
25
- icon: resolvedSuccessIcon.value,
26
- })
27
- }
28
- </script>
29
-
30
- <template>
31
- <UButton
32
- :icon="resolvedIcon"
33
- variant="ghost"
34
- color="neutral"
35
- @click="copyLink"
36
- >
37
- {{ resolvedLabel }}
38
- </UButton>
39
- </template>
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ path?: string
4
+ icon?: string
5
+ label?: string
6
+ successIcon?: string
7
+ successLabel?: string
8
+ }>()
9
+
10
+ const { copy } = useClipboard()
11
+ const url = useRequestURL()
12
+ const route = useRoute()
13
+
14
+ function copyLink() {
15
+ copy(`${url.origin}${props.path ?? route.path}`, {
16
+ id: 'article-copy-link',
17
+ title: props.successLabel,
18
+ icon: props.successIcon,
19
+ })
20
+ }
21
+ </script>
22
+
23
+ <template>
24
+ <UButton
25
+ :icon="icon"
26
+ variant="ghost"
27
+ color="neutral"
28
+ @click="copyLink"
29
+ >
30
+ {{ label }}
31
+ </UButton>
32
+ </template>
@@ -1,20 +1,20 @@
1
- <script setup lang="ts">
2
- import formatDate from '~/utils/formatDate'
3
-
4
- defineProps<{
5
- date?: string
6
- dateEnd?: string
7
- }>()
8
- </script>
9
-
10
- <template>
11
- <div class="all:flex items-center space-x-2">
12
- <UIcon name="i-lucide-calendar" class="size-4" />
13
- <time>
14
- {{ formatDate(date) }}
15
- <template v-if="dateEnd && date !== dateEnd">
16
- - {{ formatDate(dateEnd) }}
17
- </template>
18
- </time>
19
- </div>
20
- </template>
1
+ <script setup lang="ts">
2
+ import formatDate from '../../utils/formatDate'
3
+
4
+ defineProps<{
5
+ date?: string
6
+ dateEnd?: string
7
+ }>()
8
+ </script>
9
+
10
+ <template>
11
+ <div class="all:flex items-center space-x-2">
12
+ <UIcon name="i-lucide-calendar" class="size-4" />
13
+ <time>
14
+ {{ formatDate(date) }}
15
+ <template v-if="dateEnd && date !== dateEnd">
16
+ - {{ formatDate(dateEnd) }}
17
+ </template>
18
+ </time>
19
+ </div>
20
+ </template>
@@ -1,17 +1,17 @@
1
- <script setup lang="ts">
2
- import type { ButtonProps } from '@nuxt/ui'
3
-
4
- defineProps<{
5
- links?: ButtonProps[]
6
- }>()
7
- </script>
8
-
9
- <template>
10
- <UButton
11
- v-for="(link, index) in links"
12
- :key="index"
13
- variant="subtle"
14
- size="sm"
15
- v-bind="link"
16
- />
17
- </template>
1
+ <script setup lang="ts">
2
+ import type { ButtonProps } from '@nuxt/ui'
3
+
4
+ defineProps<{
5
+ links?: ButtonProps[]
6
+ }>()
7
+ </script>
8
+
9
+ <template>
10
+ <UButton
11
+ v-for="(link, index) in links"
12
+ :key="index"
13
+ variant="subtle"
14
+ size="sm"
15
+ v-bind="link"
16
+ />
17
+ </template>
@@ -1,20 +1,20 @@
1
- <script setup lang="ts">
2
- defineProps<{
3
- location?: { url?: string, name?: string }
4
- }>()
5
- </script>
6
-
7
- <template>
8
- <div class="all:flex items-center space-x-2">
9
- <UIcon name="i-lucide-map-pin" class="size-4" />
10
- <NuxtLink
11
- v-if="location?.url"
12
- :to="location.url"
13
- target="_blank"
14
- class="hover:text-primary transition-colors underline decoration-dotted underline-offset-4"
15
- >
16
- {{ location.name }}
17
- </NuxtLink>
18
- <span v-else>{{ location?.name }}</span>
19
- </div>
20
- </template>
1
+ <script setup lang="ts">
2
+ defineProps<{
3
+ location?: { url?: string, name?: string }
4
+ }>()
5
+ </script>
6
+
7
+ <template>
8
+ <div class="all:flex items-center space-x-2">
9
+ <UIcon name="i-lucide-map-pin" class="size-4" />
10
+ <NuxtLink
11
+ v-if="location?.url"
12
+ :to="location.url"
13
+ target="_blank"
14
+ class="hover:text-primary transition-colors underline decoration-dotted underline-offset-4"
15
+ >
16
+ {{ location.name }}
17
+ </NuxtLink>
18
+ <span v-else>{{ location?.name }}</span>
19
+ </div>
20
+ </template>
@@ -1,26 +1,21 @@
1
- <script setup lang="ts">
2
- import type { ActionButton } from '~/types/config'
3
-
4
- const props = defineProps<{
5
- stem?: string
6
- extension?: string
7
- buttons?: ActionButton[]
8
- separator?: string
9
- }>()
10
-
11
- const { config } = useVariant('separator')
12
-
13
- const resolvedButtons = computed(() => props.buttons ?? config.value.separator?.buttons ?? [])
14
- const resolvedSeparator = computed(() => props.separator ?? config.value.separator?.separator)
15
-
16
- const hasButtons = computed(() => resolvedButtons.value.length > 0)
17
- </script>
18
-
19
- <template>
20
- <USeparator v-if="!hasButtons" class="mt-8" />
21
- <USeparator v-else class="mt-8">
22
- <div class="all:flex items-center gap-2 text-sm text-muted">
23
- <HSeparatorButtons :stem="stem" :extension="extension" :buttons="resolvedButtons" :separator="resolvedSeparator" />
24
- </div>
25
- </USeparator>
26
- </template>
1
+ <script setup lang="ts">
2
+ import type { ActionButton } from '../../types/config'
3
+
4
+ const props = defineProps<{
5
+ stem?: string
6
+ extension?: string
7
+ buttons?: ActionButton[]
8
+ separator?: string
9
+ }>()
10
+
11
+ const hasButtons = computed(() => (props.buttons?.length ?? 0) > 0)
12
+ </script>
13
+
14
+ <template>
15
+ <USeparator v-if="!hasButtons" class="mt-8" />
16
+ <USeparator v-else class="mt-8">
17
+ <div class="all:flex items-center gap-2 text-sm text-muted">
18
+ <HSeparatorButtons :stem="stem" :extension="extension" :buttons="buttons" :separator="separator" />
19
+ </div>
20
+ </USeparator>
21
+ </template>
@@ -1,56 +1,54 @@
1
- <script setup lang="ts">
2
- import type { ActionButton } from '~/types/config'
3
-
4
- const props = defineProps<{
5
- stem?: string
6
- extension?: string
7
- buttons?: ActionButton[]
8
- separator?: string
9
- }>()
10
-
11
- const { config } = useVariant('separator')
12
-
13
- const resolvedButtons = computed(() => props.buttons ?? config.value.separator?.buttons ?? [])
14
- const resolvedSeparator = computed(() => props.separator ?? config.value.separator?.separator)
15
-
16
- const appConfig = useAppConfig()
17
-
18
- const editLink = computed(() => {
19
- const { repo, branch, dir } = appConfig.app.meta.github || {}
20
- if (!repo || !props.stem)
21
- return null
22
-
23
- const extension = props.extension || 'md'
24
- return `https://github.com/${repo}/edit/${branch}/${dir}/${props.stem}.${extension}`
25
- })
26
-
27
- const reportLink = computed(() => {
28
- const repo = appConfig.app.meta.github?.repo
29
- return repo ? `https://github.com/${repo}/issues/new` : null
30
- })
31
-
32
- const buttons = computed(() =>
33
- resolvedButtons.value.flatMap((btn) => {
34
- let to = btn.to
35
- if (btn.type === 'github-edit')
36
- to = editLink.value ?? undefined
37
- else if (btn.type === 'report-github-issue')
38
- to = reportLink.value ?? undefined
39
- return to ? [{ ...btn, to }] : []
40
- }),
41
- )
42
- </script>
43
-
44
- <template>
45
- <template v-for="(btn, index) in buttons" :key="index">
46
- <template v-if="index > 0">
47
- {{ resolvedSeparator }}
48
- </template>
49
- <UButton
50
- variant="link"
51
- color="neutral"
52
- :ui="{ leadingIcon: 'size-4' }"
53
- v-bind="btn"
54
- />
55
- </template>
56
- </template>
1
+ <script setup lang="ts">
2
+ import type { ActionButton } from '../../types/config'
3
+
4
+ const props = withDefaults(defineProps<{
5
+ stem?: string
6
+ extension?: string
7
+ buttons?: ActionButton[]
8
+ separator?: string
9
+ }>(), {
10
+ buttons: () => [],
11
+ })
12
+
13
+ const appConfig = useAppConfig()
14
+
15
+ const editLink = computed(() => {
16
+ const { repo, branch, dir } = appConfig.app.meta.github || {}
17
+ if (!repo || !props.stem)
18
+ return null
19
+
20
+ const extension = props.extension || 'md'
21
+ return `https://github.com/${repo}/edit/${branch}/${dir}/${props.stem}.${extension}`
22
+ })
23
+
24
+ const reportLink = computed(() => {
25
+ const repo = appConfig.app.meta.github?.repo
26
+ return repo ? `https://github.com/${repo}/issues/new` : null
27
+ })
28
+
29
+ const buttons = computed(() =>
30
+ props.buttons.flatMap((btn) => {
31
+ const { action, ...buttonProps } = btn
32
+ let to = buttonProps.to
33
+ if (action === 'github-edit')
34
+ to = editLink.value ?? undefined
35
+ else if (action === 'report-github-issue')
36
+ to = reportLink.value ?? undefined
37
+ return to ? [{ ...buttonProps, to }] : []
38
+ }),
39
+ )
40
+ </script>
41
+
42
+ <template>
43
+ <template v-for="(btn, index) in buttons" :key="index">
44
+ <template v-if="index > 0">
45
+ {{ separator }}
46
+ </template>
47
+ <UButton
48
+ variant="link"
49
+ color="neutral"
50
+ :ui="{ leadingIcon: 'size-4' }"
51
+ v-bind="btn"
52
+ />
53
+ </template>
54
+ </template>