numori-ui 0.1.0 → 0.2.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.
@@ -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>
@@ -0,0 +1,152 @@
1
+ <template>
2
+ <div
3
+ role="group"
4
+ :aria-label="ariaLabel"
5
+ class="relative inline-grid p-1"
6
+ :class="[trackClass, 'border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900']"
7
+ :style="{ gridTemplateColumns: `repeat(${count}, minmax(0, 1fr))` }"
8
+ >
9
+ <!--
10
+ A single pill slides between segments rather than each segment owning its
11
+ own background, so the movement animates. Segments are equal-width, so the
12
+ pill's width is one column and it translates by whole columns. `top/bottom/
13
+ left` inset it inside the track's padding; `%` in translateX resolves
14
+ against the pill's own (one-column) width.
15
+ -->
16
+ <span
17
+ aria-hidden="true"
18
+ class="pointer-events-none absolute bottom-1 left-1 top-1 bg-primary-500 shadow-sm transition-transform duration-300 ease-out motion-reduce:transition-none"
19
+ :class="pillClass"
20
+ :style="pillStyle"
21
+ />
22
+
23
+ <button
24
+ v-for="(option, index) in options"
25
+ :key="option.value"
26
+ type="button"
27
+ :aria-pressed="isActive(option) ? 'true' : 'false'"
28
+ :disabled="option.disabled"
29
+ class="relative z-10 inline-flex items-center justify-center gap-1.5 font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50"
30
+ :class="[
31
+ buttonSizeClass,
32
+ buttonShapeClass,
33
+ isActive(option) ? activeTextClass : idleTextClass,
34
+ ]"
35
+ @click="select(option, index)"
36
+ >
37
+ <UiIcon v-if="option.icon" :name="option.icon" :class="iconSizeClass" />
38
+ {{ option.label }}
39
+ </button>
40
+ </div>
41
+ </template>
42
+
43
+ <script setup>
44
+ /**
45
+ * UiSegmented — a segmented control: pick one of a few named options from a row
46
+ * of buttons, with a pill that slides to the active choice.
47
+ *
48
+ * This is a set of toggle buttons (`role="group"` + `aria-pressed`), not a
49
+ * switch, because the choice is between named options rather than on/off — "the
50
+ * second option is off" is not something a screen reader should say. Segments
51
+ * are equal width so the pill can slide by whole columns.
52
+ *
53
+ * For an on/off control use `UiToggle`; for many options or a searchable list
54
+ * use `UiSelect`.
55
+ *
56
+ * @example Billing period
57
+ * <UiSegmented
58
+ * v-model="billing"
59
+ * :options="[
60
+ * { value: 'monthly', label: 'Monthly' },
61
+ * { value: 'yearly', label: 'Yearly' },
62
+ * ]"
63
+ * aria-label="Billing period"
64
+ * />
65
+ *
66
+ * @example With icons and a labelled-by heading
67
+ * <h2 id="view-h" class="sr-only">View</h2>
68
+ * <UiSegmented v-model="view" :options="views" aria-labelledby="view-h" />
69
+ *
70
+ * @emits {string|number} update:modelValue — the chosen option's `value`
71
+ */
72
+ import { computed } from 'vue'
73
+ import UiIcon from '../icons/Icon.vue'
74
+
75
+ const props = defineProps({
76
+ /**
77
+ * Selected value (v-model), matched against each option's `value`.
78
+ * @type {string | number}
79
+ * @default undefined
80
+ */
81
+ modelValue: { type: [String, Number], default: undefined },
82
+
83
+ /**
84
+ * The options. Each is `{ value, label, icon?, disabled? }`.
85
+ * @type {Array<{ value: string|number, label: string, icon?: string, disabled?: boolean }>}
86
+ */
87
+ options: { type: Array, required: true },
88
+
89
+ /**
90
+ * Size preset controlling padding and font size.
91
+ * @type {string}
92
+ * @default 'md'
93
+ * @values 'sm' | 'md'
94
+ */
95
+ size: { type: String, default: 'md' },
96
+
97
+ /**
98
+ * Corner shape of the track and pill.
99
+ * @type {string}
100
+ * @default 'pill'
101
+ * @values 'pill' | 'rounded'
102
+ */
103
+ shape: { type: String, default: 'pill' },
104
+
105
+ /**
106
+ * Accessible name for the group. Omit if you label it with an external
107
+ * heading via `aria-labelledby` (which falls through to the root).
108
+ * @type {string}
109
+ * @default undefined
110
+ */
111
+ ariaLabel: { type: String, default: undefined },
112
+ })
113
+
114
+ const emit = defineEmits(['update:modelValue'])
115
+
116
+ const count = computed(() => props.options?.length || 1)
117
+
118
+ const isActive = (option) => option.value === props.modelValue
119
+
120
+ const activeIndex = computed(() => {
121
+ const i = (props.options ?? []).findIndex((o) => o.value === props.modelValue)
122
+ return i === -1 ? 0 : i
123
+ })
124
+
125
+ function select(option, index) {
126
+ if (option.disabled) return
127
+ emit('update:modelValue', option.value)
128
+ // index is accepted for symmetry with the template call site; the value is
129
+ // what identifies the option.
130
+ void index
131
+ }
132
+
133
+ const trackClass = computed(() => (props.shape === 'rounded' ? 'rounded-xl' : 'rounded-full'))
134
+ const buttonShapeClass = computed(() => (props.shape === 'rounded' ? 'rounded-lg' : 'rounded-full'))
135
+ const pillClass = computed(() => (props.shape === 'rounded' ? 'rounded-lg' : 'rounded-full'))
136
+
137
+ const buttonSizeClass = computed(() =>
138
+ props.size === 'sm' ? 'px-3 py-1 text-xs' : 'px-4 py-1.5 text-sm',
139
+ )
140
+ const iconSizeClass = computed(() => (props.size === 'sm' ? 'size-3.5' : 'size-4'))
141
+
142
+ const activeTextClass = 'text-white'
143
+ const idleTextClass =
144
+ 'text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100'
145
+
146
+ const pillStyle = computed(() => ({
147
+ // Track padding is p-1 (0.25rem) each side, so the usable width is
148
+ // `100% - 0.5rem`; one segment is that divided by the option count.
149
+ width: `calc((100% - 0.5rem) / ${count.value})`,
150
+ transform: `translateX(calc(${activeIndex.value} * 100%))`,
151
+ }))
152
+ </script>
@@ -12,8 +12,10 @@
12
12
  import Alert from './Alert.vue'
13
13
  import Avatar from './Avatar.vue'
14
14
  import Badge from './Badge.vue'
15
+ import Breadcrumb from './Breadcrumb.vue'
15
16
  import Button from './Button.vue'
16
17
  import ButtonsGroup from './ButtonsGroup.vue'
18
+ import Card from './Card.vue'
17
19
  import Checkbox from './Checkbox.vue'
18
20
  import Divider from './Divider.vue'
19
21
  import Dropdown from './Dropdown.vue'
@@ -22,6 +24,7 @@ import DropdownRow from './DropdownRow.vue'
22
24
  import DropdownSubmenu from './DropdownSubmenu.vue'
23
25
  import FileInput from './FileInput.vue'
24
26
  import FormField from './FormField.vue'
27
+ import IconTile from './IconTile.vue'
25
28
  import Input from './Input.vue'
26
29
  import Kbd from './Kbd.vue'
27
30
  import ListMenu from './ListMenu.vue'
@@ -32,6 +35,8 @@ import Popup from './Popup.vue'
32
35
  import ProgressBar from './ProgressBar.vue'
33
36
  import Prompt from './Prompt.vue'
34
37
  import Radio from './Radio.vue'
38
+ import SectionHeading from './SectionHeading.vue'
39
+ import Segmented from './Segmented.vue'
35
40
  import Select from './Select.vue'
36
41
  import Slider from './Slider.vue'
37
42
  import Stepper from './Stepper.vue'
@@ -43,8 +48,10 @@ export {
43
48
  Alert as UiAlert,
44
49
  Avatar as UiAvatar,
45
50
  Badge as UiBadge,
51
+ Breadcrumb as UiBreadcrumb,
46
52
  Button as UiButton,
47
53
  ButtonsGroup as UiButtonsGroup,
54
+ Card as UiCard,
48
55
  Checkbox as UiCheckbox,
49
56
  Divider as UiDivider,
50
57
  Dropdown as UiDropdown,
@@ -53,6 +60,7 @@ export {
53
60
  DropdownSubmenu as UiDropdownSubmenu,
54
61
  FileInput as UiFileInput,
55
62
  FormField as UiFormField,
63
+ IconTile as UiIconTile,
56
64
  Input as UiInput,
57
65
  Kbd as UiKbd,
58
66
  ListMenu as UiListMenu,
@@ -63,6 +71,8 @@ export {
63
71
  ProgressBar as UiProgressBar,
64
72
  Prompt as UiPrompt,
65
73
  Radio as UiRadio,
74
+ SectionHeading as UiSectionHeading,
75
+ Segmented as UiSegmented,
66
76
  Select as UiSelect,
67
77
  Slider as UiSlider,
68
78
  Stepper as UiStepper,
@@ -80,8 +90,10 @@ export const components = {
80
90
  Alert,
81
91
  Avatar,
82
92
  Badge,
93
+ Breadcrumb,
83
94
  Button,
84
95
  ButtonsGroup,
96
+ Card,
85
97
  Checkbox,
86
98
  Divider,
87
99
  Dropdown,
@@ -90,6 +102,7 @@ export const components = {
90
102
  DropdownSubmenu,
91
103
  FileInput,
92
104
  FormField,
105
+ IconTile,
93
106
  Input,
94
107
  Kbd,
95
108
  ListMenu,
@@ -100,6 +113,8 @@ export const components = {
100
113
  ProgressBar,
101
114
  Prompt,
102
115
  Radio,
116
+ SectionHeading,
117
+ Segmented,
103
118
  Select,
104
119
  Slider,
105
120
  Stepper,
@@ -44,7 +44,7 @@
44
44
  * @example Inherits the parent's text colour
45
45
  * <span class="text-primary-600"><UiIcon name="mdi:alert-circle" class="w-5 h-5" /></span>
46
46
  */
47
- import { computed, defineComponent, h } from 'vue'
47
+ import { computed, defineComponent, h, resolveComponent } from 'vue'
48
48
  import { MDI_VIEW_BOX } from './mdi.js'
49
49
  import { resolveIconPath } from './registry.js'
50
50
  import { useIconComponent } from './resolver.js'
@@ -102,7 +102,12 @@ export default defineComponent({
102
102
  // A string is allowed and resolves as a globally registered component,
103
103
  // which is how the Nuxt module forwards e.g. @nuxt/icon's <Icon>.
104
104
  if (hostComponent) {
105
- return h(hostComponent, {
105
+ // A string names a globally registered component (e.g. @nuxt/icon's
106
+ // <Icon>). In a render function that must be resolved explicitly:
107
+ // h('Icon', …) would emit a literal <Icon> element, not the component.
108
+ const comp =
109
+ typeof hostComponent === 'string' ? resolveComponent(hostComponent) : hostComponent
110
+ return h(comp, {
106
111
  ...restAttrs.value,
107
112
  name: props.name,
108
113
  class: sizeClass.value,
package/src/manifest.js CHANGED
@@ -23,8 +23,10 @@ export const COMPONENT_NAMES = [
23
23
  'Alert',
24
24
  'Avatar',
25
25
  'Badge',
26
+ 'Breadcrumb',
26
27
  'Button',
27
28
  'ButtonsGroup',
29
+ 'Card',
28
30
  'Checkbox',
29
31
  'Divider',
30
32
  'Dropdown',
@@ -33,6 +35,7 @@ export const COMPONENT_NAMES = [
33
35
  'DropdownSubmenu',
34
36
  'FileInput',
35
37
  'FormField',
38
+ 'IconTile',
36
39
  'Input',
37
40
  'Kbd',
38
41
  'ListMenu',
@@ -43,6 +46,8 @@ export const COMPONENT_NAMES = [
43
46
  'ProgressBar',
44
47
  'Prompt',
45
48
  'Radio',
49
+ 'SectionHeading',
50
+ 'Segmented',
46
51
  'Select',
47
52
  'Slider',
48
53
  'Stepper',