numori-ui 0.1.1 → 0.3.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 (48) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +20 -9
  3. package/dist/components/Banner.js +179 -0
  4. package/dist/components/Banner.js.map +1 -0
  5. package/dist/components/Breadcrumb.js +107 -0
  6. package/dist/components/Breadcrumb.js.map +1 -0
  7. package/dist/components/Card.js +174 -0
  8. package/dist/components/Card.js.map +1 -0
  9. package/dist/components/CodeBlock.js +101 -0
  10. package/dist/components/CodeBlock.js.map +1 -0
  11. package/dist/components/ComparisonTable.js +152 -0
  12. package/dist/components/ComparisonTable.js.map +1 -0
  13. package/dist/components/IconTile.js +96 -0
  14. package/dist/components/IconTile.js.map +1 -0
  15. package/dist/components/SectionHeading.js +142 -0
  16. package/dist/components/SectionHeading.js.map +1 -0
  17. package/dist/components/Segmented.js +148 -0
  18. package/dist/components/Segmented.js.map +1 -0
  19. package/dist/components/Spinner.js +87 -0
  20. package/dist/components/Spinner.js.map +1 -0
  21. package/dist/components/ThemeToggle.js +85 -0
  22. package/dist/components/ThemeToggle.js.map +1 -0
  23. package/dist/components/Toast.js +107 -0
  24. package/dist/components/Toast.js.map +1 -0
  25. package/dist/components/index.js +73 -51
  26. package/dist/components/index.js.map +1 -1
  27. package/dist/icons/mdi.js +9 -0
  28. package/dist/icons/mdi.js.map +1 -1
  29. package/dist/index.d.ts +11 -0
  30. package/dist/index.js +38 -27
  31. package/dist/index.js.map +1 -1
  32. package/dist/manifest.js +11 -0
  33. package/dist/manifest.js.map +1 -1
  34. package/package.json +2 -1
  35. package/src/components/Banner.vue +149 -0
  36. package/src/components/Breadcrumb.vue +89 -0
  37. package/src/components/Card.vue +169 -0
  38. package/src/components/CodeBlock.vue +99 -0
  39. package/src/components/ComparisonTable.vue +141 -0
  40. package/src/components/IconTile.vue +100 -0
  41. package/src/components/SectionHeading.vue +121 -0
  42. package/src/components/Segmented.vue +152 -0
  43. package/src/components/Spinner.vue +70 -0
  44. package/src/components/ThemeToggle.vue +81 -0
  45. package/src/components/Toast.vue +106 -0
  46. package/src/components/index.js +33 -0
  47. package/src/icons/mdi.js +9 -0
  48. package/src/manifest.js +11 -0
@@ -0,0 +1,169 @@
1
+ <template>
2
+ <!-- Dynamic root element — renders as div, article, section, or a link via :is -->
3
+ <component :is="tag" :class="mergedClasses" v-bind="restAttrs">
4
+ <!-- Optional header region, separated from the body by a hairline rule -->
5
+ <div v-if="$slots.header" class="mb-4 border-b border-gray-100 pb-4 dark:border-gray-800">
6
+ <slot name="header" />
7
+ </div>
8
+
9
+ <slot />
10
+
11
+ <!-- Optional footer region, pushed to the bottom in a flex-column card -->
12
+ <div v-if="$slots.footer" class="mt-auto border-t border-gray-100 pt-4 dark:border-gray-800">
13
+ <slot name="footer" />
14
+ </div>
15
+ </component>
16
+ </template>
17
+
18
+ <script setup>
19
+ /**
20
+ * UiCard — the surface primitive: a bordered, rounded container with the
21
+ * design system's card elevation, dark-mode surface, and optional interactive
22
+ * and highlighted states.
23
+ *
24
+ * It is the shell only. Card lays out header / default / footer slots but takes
25
+ * no view over their contents, so product cards, blog cards, pricing tiers and
26
+ * link tiles can all share one surface while keeping their own internals.
27
+ *
28
+ * Renders as any element via `tag`, so a whole card can be a single link
29
+ * (`tag="a"`) or an article. External Tailwind classes are merged with
30
+ * `tailwind-merge`, so a caller's `hover:border-primary-300` wins over the
31
+ * neutral hover border added by `interactive` rather than doubling up.
32
+ *
33
+ * @example Basic card
34
+ * <UiCard>
35
+ * <h3 class="font-semibold">Title</h3>
36
+ * <p class="text-sm text-gray-600 dark:text-gray-400">Body copy.</p>
37
+ * </UiCard>
38
+ *
39
+ * @example Interactive card that is one big link (stretched-link pattern)
40
+ * <UiCard tag="article" interactive focus-ring>
41
+ * <h3><a href="/x" class="after:absolute after:inset-0">Title</a></h3>
42
+ * </UiCard>
43
+ *
44
+ * @example Highlighted pricing tier with a footer action
45
+ * <UiCard highlighted padding="lg" class="flex h-full flex-col">
46
+ * …
47
+ * <template #footer><UiButton block>Choose</UiButton></template>
48
+ * </UiCard>
49
+ *
50
+ * @slot default — Card body.
51
+ * @slot header — Optional header, drawn above the body with a divider.
52
+ * @slot footer — Optional footer, drawn below the body with a divider.
53
+ */
54
+ import { computed, useAttrs } from 'vue'
55
+ import { twMerge } from 'tailwind-merge'
56
+
57
+ const props = defineProps({
58
+ /**
59
+ * HTML element (or globally registered component name) to render as.
60
+ * @type {string}
61
+ * @default 'div'
62
+ * @values 'div' | 'article' | 'section' | 'a' | 'li' | any valid tag
63
+ */
64
+ tag: { type: String, default: 'div' },
65
+
66
+ /**
67
+ * Inner padding.
68
+ * @type {string}
69
+ * @default 'md'
70
+ * @values 'none' | 'xs' | 'sm' | 'md' | 'lg'
71
+ */
72
+ padding: { type: String, default: 'md' },
73
+
74
+ /**
75
+ * Corner radius.
76
+ * @type {string}
77
+ * @default '2xl'
78
+ * @values 'lg' | 'xl' | '2xl'
79
+ */
80
+ radius: { type: String, default: '2xl' },
81
+
82
+ /**
83
+ * Base drop shadow. `interactive` raises this to `card-hover` on hover.
84
+ * @type {string}
85
+ * @default 'card'
86
+ * @values 'none' | 'card' | 'card-hover'
87
+ */
88
+ shadow: { type: String, default: 'card' },
89
+
90
+ /**
91
+ * Draw the surface border. On by default; turn off for cards that sit on a
92
+ * tinted panel and provide their own separation.
93
+ * @type {boolean}
94
+ * @default true
95
+ */
96
+ bordered: { type: Boolean, default: true },
97
+
98
+ /**
99
+ * Hover affordance: a small lift and a stronger shadow, with the transition
100
+ * disabled under `prefers-reduced-motion`. Border-color is included in the
101
+ * transition but left untinted, so add a `hover:border-*` (or `group-hover:
102
+ * border-*`) class to colour the border on hover.
103
+ * @type {boolean}
104
+ * @default false
105
+ */
106
+ interactive: { type: Boolean, default: false },
107
+
108
+ /**
109
+ * Recommended / featured state: accent border and a raised shadow, for the
110
+ * one card in a group that should draw the eye.
111
+ * @type {boolean}
112
+ * @default false
113
+ */
114
+ highlighted: { type: Boolean, default: false },
115
+
116
+ /**
117
+ * Lift the focus ring to the card when a single descendant link is stretched
118
+ * over the whole surface (the `after:absolute after:inset-0` pattern). The
119
+ * card becomes the positioning context and shows the ring on focus-within.
120
+ * @type {boolean}
121
+ * @default false
122
+ */
123
+ focusRing: { type: Boolean, default: false },
124
+ })
125
+
126
+ defineOptions({ inheritAttrs: false })
127
+
128
+ const attrs = useAttrs()
129
+ const restAttrs = computed(() => {
130
+ const { class: _class, ...rest } = attrs
131
+ return rest
132
+ })
133
+
134
+ const paddingClass = computed(
135
+ () => ({ none: '', xs: 'p-3', sm: 'p-4', md: 'p-5', lg: 'p-6' })[props.padding] ?? 'p-5',
136
+ )
137
+
138
+ const radiusClass = computed(
139
+ () =>
140
+ ({ lg: 'rounded-lg', xl: 'rounded-xl', '2xl': 'rounded-2xl' })[props.radius] ?? 'rounded-2xl',
141
+ )
142
+
143
+ const shadowClass = computed(
144
+ () =>
145
+ ({ none: '', card: 'shadow-card', 'card-hover': 'shadow-card-hover' })[props.shadow] ??
146
+ 'shadow-card',
147
+ )
148
+
149
+ const mergedClasses = computed(() =>
150
+ twMerge(
151
+ 'bg-white dark:bg-gray-900',
152
+ props.focusRing ? 'relative' : '',
153
+ radiusClass.value,
154
+ props.bordered ? 'border border-gray-200 dark:border-gray-700' : '',
155
+ shadowClass.value,
156
+ props.interactive
157
+ ? 'transition-[transform,box-shadow,border-color] duration-300 ease-out hover:-translate-y-1 hover:shadow-card-hover motion-reduce:transition-none motion-reduce:hover:translate-y-0'
158
+ : '',
159
+ props.highlighted
160
+ ? 'border-primary-400 shadow-card-hover ring-1 ring-primary-400/20 dark:border-primary-400/60 dark:ring-primary-400/25'
161
+ : '',
162
+ props.focusRing
163
+ ? 'focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-primary-500 dark:focus-within:outline-primary-400'
164
+ : '',
165
+ paddingClass.value,
166
+ attrs.class,
167
+ ),
168
+ )
169
+ </script>
@@ -0,0 +1,99 @@
1
+ <template>
2
+ <div class="group relative">
3
+ <div
4
+ v-if="label"
5
+ class="flex items-center justify-between rounded-t-xl border border-b-0 border-gray-200 bg-gray-50 px-4 py-2 text-xs font-medium text-gray-500 dark:border-gray-700 dark:bg-gray-800/60 dark:text-gray-400"
6
+ >
7
+ <span>{{ label }}</span>
8
+ </div>
9
+
10
+ <button
11
+ type="button"
12
+ class="absolute right-2 z-10 inline-flex items-center gap-1.5 rounded-lg border border-gray-200 bg-white/80 px-2.5 py-1.5 text-xs font-medium text-gray-600 opacity-0 backdrop-blur transition-all hover:bg-white hover:text-gray-900 focus-visible:opacity-100 group-hover:opacity-100 dark:border-gray-700 dark:bg-gray-800/80 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100"
13
+ :class="label ? 'top-11' : 'top-2'"
14
+ :aria-label="copied ? copiedLabel : copyLabel"
15
+ @click="copy"
16
+ >
17
+ <UiIcon
18
+ :name="copied ? 'mdi:check' : 'mdi:content-copy'"
19
+ class="size-3.5"
20
+ :class="copied ? 'text-success-600 dark:text-success-400' : ''"
21
+ />
22
+ {{ copied ? copiedLabel : copyLabel }}
23
+ </button>
24
+
25
+ <pre
26
+ class="overflow-x-auto border border-gray-200 bg-gray-950 p-4 text-[13px] leading-relaxed text-gray-100 dark:border-gray-700"
27
+ :class="label ? 'rounded-b-xl' : 'rounded-xl'"
28
+ ><code>{{ code }}</code></pre>
29
+ </div>
30
+ </template>
31
+
32
+ <script setup>
33
+ /**
34
+ * UiCodeBlock — a static, copyable code snippet.
35
+ *
36
+ * For code that documents itself rather than runs: install commands, config,
37
+ * import statements. A copy button fades in on hover or keyboard focus, so it
38
+ * stays out of the way while reading and confirms with a tick for a moment after
39
+ * a successful copy. An optional `label` renders a filename/language caption
40
+ * across the top.
41
+ *
42
+ * The copy uses the async Clipboard API and fails silently if it is
43
+ * unavailable (an insecure context, or permission denied) — a docs snippet
44
+ * should never throw because the clipboard was blocked. The button's labels are
45
+ * props rather than fixed strings so the component carries no baked-in language.
46
+ *
47
+ * @example
48
+ * <UiCodeBlock label="Terminal" code="npm install numori-ui" />
49
+ *
50
+ * @example Localised button labels
51
+ * <UiCodeBlock :code="snippet" :copy-label="$t('ui.copy')" :copied-label="$t('ui.copied')" />
52
+ */
53
+ import { ref } from 'vue'
54
+ import UiIcon from '../icons/Icon.vue'
55
+
56
+ const props = defineProps({
57
+ /**
58
+ * The snippet text.
59
+ * @type {string}
60
+ */
61
+ code: { type: String, required: true },
62
+
63
+ /**
64
+ * Optional filename/language caption shown above the block.
65
+ * @type {string}
66
+ * @default ''
67
+ */
68
+ label: { type: String, default: '' },
69
+
70
+ /**
71
+ * Label for the copy button in its resting state.
72
+ * @type {string}
73
+ * @default 'Copy'
74
+ */
75
+ copyLabel: { type: String, default: 'Copy' },
76
+
77
+ /**
78
+ * Label shown briefly after a successful copy.
79
+ * @type {string}
80
+ * @default 'Copied'
81
+ */
82
+ copiedLabel: { type: String, default: 'Copied' },
83
+ })
84
+
85
+ const copied = ref(false)
86
+
87
+ async function copy() {
88
+ try {
89
+ await navigator.clipboard.writeText(props.code)
90
+ copied.value = true
91
+ setTimeout(() => {
92
+ copied.value = false
93
+ }, 1600)
94
+ } catch {
95
+ // Clipboard unavailable (insecure context or denied permission); ignore
96
+ // rather than throw for a snippet whose whole job is to sit there and read.
97
+ }
98
+ }
99
+ </script>
@@ -0,0 +1,141 @@
1
+ <template>
2
+ <div class="overflow-x-auto rounded-2xl border border-gray-200 dark:border-gray-700">
3
+ <table class="w-full min-w-2xl border-collapse text-left text-sm">
4
+ <caption class="sr-only">
5
+ {{
6
+ caption
7
+ }}
8
+ </caption>
9
+
10
+ <thead>
11
+ <tr class="border-b border-gray-200 dark:border-gray-700">
12
+ <th scope="col" class="px-5 py-4 font-semibold text-gray-500 dark:text-gray-400">
13
+ <span class="sr-only">{{ featureLabel }}</span>
14
+ </th>
15
+ <th
16
+ scope="col"
17
+ class="w-2/5 bg-primary-50 px-5 py-4 font-semibold text-primary-800 dark:bg-primary-400/10 dark:text-primary-200"
18
+ >
19
+ {{ primaryLabel }}
20
+ </th>
21
+ <th scope="col" class="w-2/5 px-5 py-4 font-semibold text-gray-600 dark:text-gray-300">
22
+ {{ secondaryLabel }}
23
+ </th>
24
+ </tr>
25
+ </thead>
26
+
27
+ <tbody>
28
+ <tr
29
+ v-for="(row, index) in rows"
30
+ :key="row.key ?? index"
31
+ class="border-b border-gray-100 transition-colors duration-200 last:border-0 hover:bg-gray-50 dark:border-gray-800 dark:hover:bg-gray-900/60"
32
+ >
33
+ <th scope="row" class="px-5 py-4 font-medium text-gray-900 dark:text-gray-100">
34
+ {{ row.feature }}
35
+ </th>
36
+
37
+ <td
38
+ class="bg-primary-50/50 px-5 py-4 text-gray-700 dark:bg-primary-400/5 dark:text-gray-200"
39
+ >
40
+ <span class="flex items-start gap-2">
41
+ <UiIcon
42
+ :name="primaryIcon"
43
+ class="mt-0.5 size-4 shrink-0 text-success-600 dark:text-success-400"
44
+ />
45
+ {{ row.primary }}
46
+ </span>
47
+ </td>
48
+
49
+ <td class="px-5 py-4 text-gray-600 dark:text-gray-400">
50
+ <span class="flex items-start gap-2">
51
+ <UiIcon
52
+ :name="secondaryIcon"
53
+ class="mt-0.5 size-4 shrink-0 text-gray-400 dark:text-gray-500"
54
+ />
55
+ {{ row.secondary }}
56
+ </span>
57
+ </td>
58
+ </tr>
59
+ </tbody>
60
+ </table>
61
+ </div>
62
+ </template>
63
+
64
+ <script setup>
65
+ /**
66
+ * UiComparisonTable — a two-way, feature-by-feature comparison.
67
+ *
68
+ * A real `<table>`, not a grid of divs, because it is tabular data: the
69
+ * `<caption>`, `scope="col"` headers and `scope="row"` feature cells are what let
70
+ * a screen reader announce a whole row together ("Open source · yes · no")
71
+ * instead of reading three disconnected columns. The first (feature) column
72
+ * header is visually blank but named for assistive technology.
73
+ *
74
+ * The layout favours one column — the "primary" one is tinted with the accent —
75
+ * for the common "us versus the usual way" table. The leading icons are
76
+ * decorative; the cell text carries the meaning, so nothing depends on colour or
77
+ * glyph alone. It scrolls horizontally on narrow screens rather than crushing
78
+ * the columns.
79
+ *
80
+ * @example
81
+ * <UiComparisonTable
82
+ * caption="How Numori compares"
83
+ * primary-label="Numori"
84
+ * secondary-label="The usual suite"
85
+ * feature-label="Feature"
86
+ * :rows="[
87
+ * { key: 'oss', feature: 'Open source', primary: 'Entire ecosystem', secondary: 'The client, sometimes' },
88
+ * { key: 'sync', feature: 'Sync', primary: 'End-to-end encrypted', secondary: 'Readable on the server' },
89
+ * ]"
90
+ * />
91
+ */
92
+ import UiIcon from '../icons/Icon.vue'
93
+
94
+ defineProps({
95
+ /**
96
+ * Table summary for assistive technology. Rendered visually hidden.
97
+ * @type {string}
98
+ */
99
+ caption: { type: String, required: true },
100
+
101
+ /**
102
+ * Rows to render. Each is `{ key?, feature, primary, secondary }`; `key`
103
+ * should be stable if present, and falls back to the row index.
104
+ * @type {Array<{ key?: string|number, feature: string, primary: string, secondary: string }>}
105
+ */
106
+ rows: { type: Array, required: true },
107
+
108
+ /**
109
+ * Heading for the accented (primary) column.
110
+ * @type {string}
111
+ */
112
+ primaryLabel: { type: String, required: true },
113
+
114
+ /**
115
+ * Heading for the comparison (secondary) column.
116
+ * @type {string}
117
+ */
118
+ secondaryLabel: { type: String, required: true },
119
+
120
+ /**
121
+ * Accessible name for the otherwise-blank first column.
122
+ * @type {string}
123
+ * @default 'Feature'
124
+ */
125
+ featureLabel: { type: String, default: 'Feature' },
126
+
127
+ /**
128
+ * MDI icon marking each primary-column cell.
129
+ * @type {string}
130
+ * @default 'mdi:check-circle'
131
+ */
132
+ primaryIcon: { type: String, default: 'mdi:check-circle' },
133
+
134
+ /**
135
+ * MDI icon marking each secondary-column cell.
136
+ * @type {string}
137
+ * @default 'mdi:minus-circle-outline'
138
+ */
139
+ secondaryIcon: { type: String, default: 'mdi:minus-circle-outline' },
140
+ })
141
+ </script>
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <span class="inline-flex items-center justify-center" :class="mergedClasses" v-bind="restAttrs">
3
+ <UiIcon :name="icon" :class="iconSizeClass" aria-hidden="true" />
4
+ </span>
5
+ </template>
6
+
7
+ <script setup>
8
+ /**
9
+ * UiIconTile — a small rounded, tinted tile holding a single icon: the motif
10
+ * that stands in for a product logo or marks a feature next to a heading.
11
+ *
12
+ * Decorative by default — the icon is `aria-hidden`, on the assumption that a
13
+ * label sits next to it in text. The tint uses the design system's semantic
14
+ * colours; for a colour outside that set (a Tailwind palette, say) pass the
15
+ * `bg-*`/`text-*` classes directly and they override the built-in tint via
16
+ * `tailwind-merge`.
17
+ *
18
+ * @example Primary feature tile
19
+ * <UiIconTile icon="mdi:shield-lock-outline" />
20
+ *
21
+ * @example Large product mark in a custom colour
22
+ * <UiIconTile icon="mdi:note-text-outline" size="lg" class="bg-sky-100 text-sky-700" />
23
+ *
24
+ * @example Success tile
25
+ * <UiIconTile icon="mdi:check" color="success" size="sm" />
26
+ */
27
+ import { computed, useAttrs } from 'vue'
28
+ import { twMerge } from 'tailwind-merge'
29
+ import UiIcon from '../icons/Icon.vue'
30
+
31
+ const props = defineProps({
32
+ /**
33
+ * MDI icon name.
34
+ * @type {string}
35
+ */
36
+ icon: { type: String, required: true },
37
+
38
+ /**
39
+ * Tint colour from the semantic palette.
40
+ * @type {string}
41
+ * @default 'primary'
42
+ * @values 'primary' | 'gray' | 'success' | 'warning' | 'error' | 'blue'
43
+ */
44
+ color: { type: String, default: 'primary' },
45
+
46
+ /**
47
+ * Tile size (the radius scales with it).
48
+ * @type {string}
49
+ * @default 'md'
50
+ * @values 'sm' | 'md' | 'lg' | 'xl'
51
+ */
52
+ size: { type: String, default: 'md' },
53
+ })
54
+
55
+ const sizeClass = computed(
56
+ () =>
57
+ ({
58
+ sm: 'size-9 rounded-lg',
59
+ md: 'size-11 rounded-xl',
60
+ lg: 'size-14 rounded-2xl',
61
+ xl: 'size-16 rounded-2xl',
62
+ })[props.size] ?? 'size-11 rounded-xl',
63
+ )
64
+
65
+ const iconSizeClass = computed(
66
+ () =>
67
+ ({
68
+ sm: 'size-5',
69
+ md: 'size-6',
70
+ lg: 'size-8',
71
+ xl: 'size-9',
72
+ })[props.size] ?? 'size-6',
73
+ )
74
+
75
+ const colorClass = computed(
76
+ () =>
77
+ ({
78
+ primary: 'bg-primary-100 text-primary-700 dark:bg-primary-400/15 dark:text-primary-300',
79
+ gray: 'bg-gray-100 text-gray-700 dark:bg-gray-700/60 dark:text-gray-200',
80
+ success: 'bg-success-100 text-success-700 dark:bg-success-400/15 dark:text-success-300',
81
+ warning: 'bg-warning-100 text-warning-700 dark:bg-warning-400/15 dark:text-warning-300',
82
+ error: 'bg-error-100 text-error-700 dark:bg-error-400/15 dark:text-error-300',
83
+ blue: 'bg-blue-100 text-blue-700 dark:bg-blue-400/15 dark:text-blue-300',
84
+ })[props.color] ??
85
+ 'bg-primary-100 text-primary-700 dark:bg-primary-400/15 dark:text-primary-300',
86
+ )
87
+
88
+ defineOptions({ inheritAttrs: false })
89
+
90
+ const attrs = useAttrs()
91
+ const restAttrs = computed(() => {
92
+ const { class: _class, ...rest } = attrs
93
+ return rest
94
+ })
95
+
96
+ // External classes merge last so a caller's `bg-*`/`text-*` (e.g. a Tailwind
97
+ // palette outside the semantic set) overrides the built-in tint rather than
98
+ // colliding with it.
99
+ const mergedClasses = computed(() => twMerge(sizeClass.value, colorClass.value, attrs.class))
100
+ </script>
@@ -0,0 +1,121 @@
1
+ <template>
2
+ <div :class="align === 'center' ? 'text-center' : ''">
3
+ <p
4
+ v-if="eyebrow"
5
+ class="mb-3 text-sm font-semibold uppercase tracking-wide text-primary-600 dark:text-primary-400"
6
+ >
7
+ {{ eyebrow }}
8
+ </p>
9
+
10
+ <component :is="level" :id="id" :class="titleClasses">
11
+ <slot name="title">{{ title }}</slot>
12
+ </component>
13
+
14
+ <p v-if="subtitle || $slots.subtitle" :class="subtitleClasses">
15
+ <slot name="subtitle">{{ subtitle }}</slot>
16
+ </p>
17
+
18
+ <slot />
19
+ </div>
20
+ </template>
21
+
22
+ <script setup>
23
+ /**
24
+ * UiSectionHeading — the eyebrow / heading / standfirst trio used at the top of
25
+ * a page or the start of a section.
26
+ *
27
+ * `level` and the visual `size` are independent on purpose: the heading tag
28
+ * follows the document outline (an `h3` nested inside an `h2` section) while the
29
+ * size follows the layout, so neither is sacrificed for the other. The block is
30
+ * layout-neutral — no outer margins or width cap — so the caller controls
31
+ * spacing and measure.
32
+ *
33
+ * @example Section heading
34
+ * <UiSectionHeading
35
+ * eyebrow="Pricing"
36
+ * title="One price, everything included"
37
+ * subtitle="No tiers, no add-ons."
38
+ * />
39
+ *
40
+ * @example Centred page hero with a nested level
41
+ * <UiSectionHeading centred size="lg" level="h1" title="Own your notes" />
42
+ *
43
+ * @slot title — Overrides the `title` prop for rich heading content.
44
+ * @slot subtitle — Overrides the `subtitle` prop.
45
+ * @slot default — Extra content below the standfirst, e.g. a call to action.
46
+ */
47
+ import { computed } from 'vue'
48
+
49
+ const props = defineProps({
50
+ /**
51
+ * Small uppercase label above the heading.
52
+ * @type {string}
53
+ * @default ''
54
+ */
55
+ eyebrow: { type: String, default: '' },
56
+
57
+ /**
58
+ * Heading text. Omit if using the `title` slot.
59
+ * @type {string}
60
+ * @default ''
61
+ */
62
+ title: { type: String, default: '' },
63
+
64
+ /**
65
+ * Supporting paragraph below the heading.
66
+ * @type {string}
67
+ * @default ''
68
+ */
69
+ subtitle: { type: String, default: '' },
70
+
71
+ /**
72
+ * Heading tag, chosen to match the document outline — not the visual size.
73
+ * @type {string}
74
+ * @default 'h2'
75
+ * @values 'h1' | 'h2' | 'h3' | 'h4'
76
+ */
77
+ level: { type: String, default: 'h2' },
78
+
79
+ /**
80
+ * Visual size of the heading, independent of `level`.
81
+ * @type {string}
82
+ * @default 'md'
83
+ * @values 'sm' | 'md' | 'lg'
84
+ */
85
+ size: { type: String, default: 'md' },
86
+
87
+ /**
88
+ * Horizontal alignment.
89
+ * @type {string}
90
+ * @default 'left'
91
+ * @values 'left' | 'center'
92
+ */
93
+ align: { type: String, default: 'left' },
94
+
95
+ /**
96
+ * Optional id on the heading, so it can be targeted by `aria-labelledby`.
97
+ * @type {string}
98
+ * @default undefined
99
+ */
100
+ id: { type: String, default: undefined },
101
+ })
102
+
103
+ const titleClasses = computed(() => {
104
+ const sizeMap = {
105
+ sm: 'text-xl font-bold sm:text-2xl',
106
+ md: 'text-2xl font-bold sm:text-3xl',
107
+ lg: 'text-3xl font-bold sm:text-4xl',
108
+ }
109
+ return sizeMap[props.size] || sizeMap.md
110
+ })
111
+
112
+ const subtitleClasses = computed(() => {
113
+ const sizeMap = {
114
+ sm: 'mt-3 text-base text-gray-600 dark:text-gray-400',
115
+ md: 'mt-4 text-base text-gray-600 sm:text-lg dark:text-gray-400',
116
+ lg: 'mt-4 text-lg text-gray-600 dark:text-gray-400',
117
+ }
118
+ const base = sizeMap[props.size] || sizeMap.md
119
+ return props.align === 'center' ? `${base} mx-auto` : base
120
+ })
121
+ </script>