gooee 0.51.1 → 1.0.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 +10 -3
- package/package.json +6 -2
- package/scripts/add.js +181 -42
- package/src/base.css +3 -1
- package/src/components/Accordion/Accordion.module.css +7 -5
- package/src/components/Accordion/Accordion.tsx +13 -11
- package/src/components/Accordion/Accordion.vue +16 -15
- package/src/components/Accordion/AccordionItem.vue +8 -7
- package/src/components/Alert/Alert.module.css +9 -7
- package/src/components/Alert/Alert.tsx +25 -16
- package/src/components/Alert/Alert.vue +31 -27
- package/src/components/AlertDialog/AlertDialog.module.css +2 -0
- package/src/components/AlertDialog/AlertDialog.tsx +8 -7
- package/src/components/AlertDialog/AlertDialog.vue +25 -23
- package/src/components/AnimatedNumber/AnimatedNumber.module.css +5 -3
- package/src/components/AnimatedNumber/AnimatedNumber.tsx +6 -6
- package/src/components/AnimatedNumber/AnimatedNumber.vue +5 -5
- package/src/components/AspectRatio/AspectRatio.module.css +2 -0
- package/src/components/AspectRatio/AspectRatio.tsx +3 -3
- package/src/components/AspectRatio/AspectRatio.vue +5 -8
- package/src/components/Avatar/Avatar.module.css +10 -8
- package/src/components/Avatar/Avatar.tsx +4 -3
- package/src/components/Avatar/Avatar.vue +17 -19
- package/src/components/Avatar/index.ts +0 -2
- package/src/components/AvatarGroup/AvatarGroup.module.css +11 -9
- package/src/components/AvatarGroup/AvatarGroup.tsx +4 -4
- package/src/components/AvatarGroup/AvatarGroup.vue +13 -16
- package/src/components/Badge/Badge.module.css +6 -4
- package/src/components/Badge/Badge.tsx +3 -3
- package/src/components/Badge/Badge.vue +15 -14
- package/src/components/Breadcrumb/Breadcrumb.module.css +5 -3
- package/src/components/Breadcrumb/Breadcrumb.tsx +20 -12
- package/src/components/Breadcrumb/Breadcrumb.vue +33 -25
- package/src/components/Button/Button.module.css +16 -14
- package/src/components/Button/Button.tsx +6 -4
- package/src/components/Button/Button.vue +42 -33
- package/src/components/ButtonGroup/ButtonGroup.module.css +2 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +1 -1
- package/src/components/ButtonGroup/ButtonGroup.vue +9 -12
- package/src/components/Card/Card.module.css +6 -4
- package/src/components/Card/Card.tsx +6 -6
- package/src/components/Card/Card.vue +18 -21
- package/src/components/Center/Center.module.css +2 -0
- package/src/components/Center/Center.tsx +1 -1
- package/src/components/Center/Center.vue +18 -15
- package/src/components/Checkbox/Checkbox.module.css +10 -8
- package/src/components/Checkbox/Checkbox.tsx +7 -5
- package/src/components/Checkbox/Checkbox.vue +29 -31
- package/src/components/CheckboxGroup/CheckboxGroup.module.css +3 -1
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +4 -4
- package/src/components/CheckboxGroup/CheckboxGroup.vue +33 -30
- package/src/components/Cluster/Cluster.module.css +2 -0
- package/src/components/Cluster/Cluster.tsx +1 -1
- package/src/components/Cluster/Cluster.vue +21 -17
- package/src/components/CodeBlock/CodeBlock.module.css +12 -10
- package/src/components/CodeBlock/CodeBlock.tsx +18 -10
- package/src/components/CodeBlock/CodeBlock.vue +30 -27
- package/src/components/CodeBlock/highlight.ts +1 -1
- package/src/components/Collapsible/Collapsible.module.css +7 -5
- package/src/components/Collapsible/Collapsible.tsx +7 -6
- package/src/components/Collapsible/Collapsible.vue +30 -26
- package/src/components/Container/Container.module.css +2 -0
- package/src/components/Container/Container.tsx +1 -1
- package/src/components/Container/Container.vue +13 -12
- package/src/components/CopyButton/CopyButton.module.css +20 -18
- package/src/components/CopyButton/CopyButton.tsx +21 -14
- package/src/components/CopyButton/CopyButton.vue +41 -31
- package/src/components/Dial/Dial.module.css +26 -11
- package/src/components/Dial/Dial.tsx +18 -18
- package/src/components/Dial/Dial.vue +57 -60
- package/src/components/Dialog/Dialog.module.css +4 -2
- package/src/components/Dialog/Dialog.tsx +22 -13
- package/src/components/Dialog/Dialog.vue +34 -30
- package/src/components/Divider/Divider.module.css +5 -3
- package/src/components/Divider/Divider.tsx +6 -4
- package/src/components/Divider/Divider.vue +13 -16
- package/src/components/DropdownMenu/DropdownMenu.module.css +8 -6
- package/src/components/DropdownMenu/DropdownMenu.tsx +11 -8
- package/src/components/DropdownMenu/DropdownMenu.vue +24 -27
- package/src/components/EmptyState/EmptyState.module.css +6 -4
- package/src/components/EmptyState/EmptyState.tsx +6 -6
- package/src/components/EmptyState/EmptyState.vue +14 -17
- package/src/components/Fab/Fab.module.css +19 -17
- package/src/components/Fab/Fab.tsx +11 -9
- package/src/components/Fab/Fab.vue +29 -26
- package/src/components/Fieldset/Fieldset.module.css +2 -0
- package/src/components/Fieldset/Fieldset.tsx +4 -3
- package/src/components/Fieldset/Fieldset.vue +4 -4
- package/src/components/FormField/FormField.module.css +5 -3
- package/src/components/FormField/FormField.tsx +7 -7
- package/src/components/FormField/FormField.vue +4 -4
- package/src/components/Grid/Grid.module.css +2 -0
- package/src/components/Grid/Grid.tsx +1 -1
- package/src/components/Grid/Grid.vue +25 -22
- package/src/components/HoldToConfirm/HoldToConfirm.module.css +13 -11
- package/src/components/HoldToConfirm/HoldToConfirm.tsx +11 -9
- package/src/components/HoldToConfirm/HoldToConfirm.vue +37 -32
- package/src/components/IconButton/IconButton.module.css +7 -5
- package/src/components/IconButton/IconButton.tsx +2 -1
- package/src/components/IconButton/IconButton.vue +15 -14
- package/src/components/Input/Input.module.css +12 -10
- package/src/components/Input/Input.tsx +9 -7
- package/src/components/Input/Input.vue +45 -35
- package/src/components/InputGroup/InputGroup.module.css +8 -6
- package/src/components/InputGroup/InputGroup.tsx +5 -4
- package/src/components/InputGroup/InputGroup.vue +41 -36
- package/src/components/Kbd/Kbd.module.css +9 -7
- package/src/components/Kbd/Kbd.tsx +1 -1
- package/src/components/Kbd/Kbd.vue +1 -1
- package/src/components/Link/Link.module.css +4 -2
- package/src/components/Link/Link.tsx +4 -3
- package/src/components/Link/Link.vue +13 -16
- package/src/components/LivePill/LivePill.module.css +39 -37
- package/src/components/LivePill/LivePill.tsx +11 -10
- package/src/components/LivePill/LivePill.vue +38 -40
- package/src/components/Meter/Meter.module.css +5 -3
- package/src/components/Meter/Meter.tsx +9 -8
- package/src/components/Meter/Meter.vue +52 -43
- package/src/components/MorphButton/MorphButton.module.css +11 -9
- package/src/components/MorphButton/MorphButton.tsx +20 -10
- package/src/components/MorphButton/MorphButton.vue +29 -25
- package/src/components/NumberInput/NumberInput.module.css +7 -5
- package/src/components/NumberInput/NumberInput.tsx +11 -8
- package/src/components/NumberInput/NumberInput.vue +69 -57
- package/src/components/Pagination/Pagination.module.css +147 -5
- package/src/components/Pagination/Pagination.tsx +216 -41
- package/src/components/Pagination/Pagination.vue +201 -36
- package/src/components/Pagination/labels.ts +38 -0
- package/src/components/PasswordInput/PasswordInput.module.css +10 -8
- package/src/components/PasswordInput/PasswordInput.tsx +15 -7
- package/src/components/PasswordInput/PasswordInput.vue +20 -16
- package/src/components/PasswordInput/index.ts +1 -1
- package/src/components/PickerWheel/DateWheel.vue +20 -12
- package/src/components/PickerWheel/PickerWheel.module.css +15 -6
- package/src/components/PickerWheel/PickerWheel.tsx +70 -44
- package/src/components/PickerWheel/PickerWheel.vue +39 -38
- package/src/components/PickerWheel/TimeWheel.vue +23 -21
- package/src/components/PickerWheel/WheelColumn.vue +7 -5
- package/src/components/Popover/Popover.module.css +5 -3
- package/src/components/Popover/Popover.tsx +17 -8
- package/src/components/Popover/Popover.vue +26 -25
- package/src/components/ProgressBar/ProgressBar.module.css +4 -2
- package/src/components/ProgressBar/ProgressBar.tsx +6 -5
- package/src/components/ProgressBar/ProgressBar.vue +28 -25
- package/src/components/Prose/Prose.module.css +5 -3
- package/src/components/Prose/Prose.tsx +1 -1
- package/src/components/Prose/Prose.vue +5 -8
- package/src/components/Radio/Radio.module.css +10 -8
- package/src/components/Radio/Radio.tsx +10 -8
- package/src/components/Radio/Radio.vue +8 -8
- package/src/components/Radio/RadioGroup.vue +33 -35
- package/src/components/Radio/radioContext.ts +12 -0
- package/src/components/Retime/Retime.vue +25 -22
- package/src/components/RulerScrubber/RulerScrubber.module.css +11 -2
- package/src/components/RulerScrubber/RulerScrubber.tsx +19 -18
- package/src/components/RulerScrubber/RulerScrubber.vue +50 -54
- package/src/components/ScrollArea/ScrollArea.module.css +17 -15
- package/src/components/ScrollArea/ScrollArea.tsx +5 -4
- package/src/components/ScrollArea/ScrollArea.vue +15 -17
- package/src/components/SearchInput/SearchInput.module.css +6 -4
- package/src/components/SearchInput/SearchInput.tsx +15 -8
- package/src/components/SearchInput/SearchInput.vue +20 -17
- package/src/components/SearchInput/index.ts +1 -1
- package/src/components/SegmentedControl/SegmentedControl.module.css +7 -5
- package/src/components/SegmentedControl/SegmentedControl.tsx +9 -5
- package/src/components/SegmentedControl/SegmentedControl.vue +25 -29
- package/src/components/Select/Select.module.css +19 -17
- package/src/components/Select/Select.tsx +30 -17
- package/src/components/Select/Select.vue +62 -57
- package/src/components/Sheet/Sheet.module.css +6 -4
- package/src/components/Sheet/Sheet.tsx +39 -29
- package/src/components/Sheet/Sheet.vue +46 -40
- package/src/components/Skeleton/Skeleton.module.css +4 -2
- package/src/components/Skeleton/Skeleton.tsx +3 -2
- package/src/components/Skeleton/Skeleton.vue +16 -18
- package/src/components/Slider/Slider.module.css +14 -12
- package/src/components/Slider/Slider.tsx +20 -9
- package/src/components/Slider/Slider.vue +47 -37
- package/src/components/Spinner/Spinner.module.css +2 -0
- package/src/components/Spinner/Spinner.tsx +3 -3
- package/src/components/Spinner/Spinner.vue +9 -12
- package/src/components/Split/Split.module.css +2 -0
- package/src/components/Split/Split.tsx +3 -3
- package/src/components/Split/Split.vue +19 -17
- package/src/components/SplitFlap/SplitFlap.module.css +9 -7
- package/src/components/SplitFlap/SplitFlap.tsx +2 -2
- package/src/components/SplitFlap/SplitFlap.vue +24 -21
- package/src/components/Stack/Stack.module.css +2 -0
- package/src/components/Stack/Stack.tsx +1 -1
- package/src/components/Stack/Stack.vue +13 -12
- package/src/components/SwipeDeck/SwipeDeck.module.css +13 -11
- package/src/components/SwipeDeck/SwipeDeck.tsx +23 -28
- package/src/components/SwipeDeck/SwipeDeck.vue +32 -38
- package/src/components/Switch/Switch.module.css +10 -8
- package/src/components/Switch/Switch.tsx +6 -5
- package/src/components/Switch/Switch.vue +22 -24
- package/src/components/Table/Table.module.css +24 -22
- package/src/components/Table/Table.tsx +27 -30
- package/src/components/Table/Table.vue +93 -79
- package/src/components/TableOfContents/TableOfContents.module.css +9 -7
- package/src/components/TableOfContents/TableOfContents.tsx +8 -8
- package/src/components/TableOfContents/TableOfContents.vue +20 -23
- package/src/components/Tabs/Tab.vue +3 -0
- package/src/components/Tabs/TabList.vue +2 -2
- package/src/components/Tabs/TabPanel.vue +2 -0
- package/src/components/Tabs/Tabs.module.css +4 -2
- package/src/components/Tabs/Tabs.tsx +10 -5
- package/src/components/Tabs/Tabs.vue +1 -1
- package/src/components/Tag/Tag.module.css +12 -10
- package/src/components/Tag/Tag.tsx +13 -15
- package/src/components/Tag/Tag.vue +12 -14
- package/src/components/Textarea/Textarea.module.css +8 -6
- package/src/components/Textarea/Textarea.tsx +4 -3
- package/src/components/Textarea/Textarea.vue +32 -34
- package/src/components/ThemeToggle/ThemeToggle.module.css +2 -0
- package/src/components/ThemeToggle/ThemeToggle.tsx +7 -7
- package/src/components/ThemeToggle/ThemeToggle.vue +24 -22
- package/src/components/Toast/Toast.module.css +17 -15
- package/src/components/Toast/Toast.tsx +51 -34
- package/src/components/Toast/Toast.vue +35 -24
- package/src/components/Toast/ToastItem.vue +17 -16
- package/src/components/Toggle/Toggle.module.css +11 -9
- package/src/components/Toggle/Toggle.tsx +3 -2
- package/src/components/Toggle/Toggle.vue +13 -15
- package/src/components/Tooltip/Tooltip.module.css +5 -3
- package/src/components/Tooltip/Tooltip.tsx +1 -0
- package/src/components/Tooltip/Tooltip.vue +13 -18
- package/src/components/VisuallyHidden/VisuallyHidden.module.css +2 -0
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +1 -1
- package/src/components/VisuallyHidden/VisuallyHidden.vue +5 -8
- package/src/{internal → icons}/icons.module.css +4 -2
- package/src/{internal → icons}/icons.tsx +15 -16
- package/src/internal/FieldMessage.module.css +5 -3
- package/src/internal/FieldMessage.tsx +2 -2
- package/src/internal/FieldMessage.vue +2 -2
- package/src/internal/Roll.module.css +5 -3
- package/src/internal/feel.ts +12 -10
- package/src/internal/fling.ts +3 -3
- package/src/internal/liquid.ts +12 -10
- package/src/internal/liquidMatter.ts +1 -1
- package/src/internal/liquidMore.ts +7 -7
- package/src/internal/motion/checkbox.ts +4 -4
- package/src/internal/motion/fling.ts +19 -9
- package/src/internal/motion/holdToConfirm.ts +3 -3
- package/src/internal/motion/index.ts +8 -6
- package/src/internal/motion/liquid.ts +16 -4
- package/src/internal/motion/liquidMatter.ts +8 -6
- package/src/internal/motion/liquidMore.ts +44 -25
- package/src/internal/motion/livePill.ts +1 -1
- package/src/internal/motion/numberInput.ts +2 -2
- package/src/internal/motion/pickerWheel.ts +7 -4
- package/src/internal/motion/ruler.ts +1 -1
- package/src/internal/motion/scrollArea.ts +3 -3
- package/src/internal/motion/scrollFrame.ts +9 -7
- package/src/internal/motion/scrubber.ts +39 -20
- package/src/internal/motion/slider.ts +38 -4
- package/src/internal/motion/softPress.ts +10 -9
- package/src/internal/motion/splitFlap.ts +4 -4
- package/src/internal/motion/swipeDeck.ts +38 -7
- package/src/internal/motion/table.ts +3 -6
- package/src/internal/motion/themeIcon.ts +1 -1
- package/src/internal/motion/themeReveal.ts +1 -1
- package/src/internal/motion/toast.ts +3 -3
- package/src/internal/motion.ts +7 -8
- package/src/internal/scrollFrame.ts +3 -3
- package/src/internal/useScrub.ts +1 -15
- package/src/internal/vue/useScrub.ts +2 -6
- package/src/tokens.css +81 -421
- package/src/{internal/vueIcons.ts → icons/vue.ts} +5 -5
|
@@ -9,43 +9,40 @@ import styles from './Dial.module.css'
|
|
|
9
9
|
|
|
10
10
|
// The Vue Dial: the same look (Dial.module.css), turn and landing as the React one.
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{ min: 0, max: 100, step: 1, strong: () => [], variant: 'printed', formatValue: String, haptics: false },
|
|
42
|
-
)
|
|
43
|
-
const emit = defineEmits<{ /** The value under the index while the dial still turns. */ scrub: [value: number] }>()
|
|
12
|
+
const { defaultValue, min = 0, max = 100, step = 1, marks, strong = [], variant = 'printed', formatValue = String, formatMark, detail, resetValue, haptics = false } = defineProps<{
|
|
13
|
+
/** Visible name of the dial, also read by screen readers. */
|
|
14
|
+
label: string
|
|
15
|
+
/** Starting value when there is no v-model. Undefined starts at min. */
|
|
16
|
+
defaultValue?: number
|
|
17
|
+
/** Lowest value. */
|
|
18
|
+
min?: number
|
|
19
|
+
/** Highest value. */
|
|
20
|
+
max?: number
|
|
21
|
+
/** Size of one step. Every step is a mark the dial is drawn onto. */
|
|
22
|
+
step?: number
|
|
23
|
+
/** Values with a printed label. Page Up and Page Down jump between them. Defaults to min and max. */
|
|
24
|
+
marks?: number[]
|
|
25
|
+
/** Values drawn stronger, such as the usual setting. */
|
|
26
|
+
strong?: number[]
|
|
27
|
+
/** "printed": the scale is printed on the knob and turns under a fixed index. "mercury": a solid knob with a few named levels. "arc": the rim of a large dial, swiped sideways. */
|
|
28
|
+
variant?: 'printed' | 'mercury' | 'arc'
|
|
29
|
+
/** Turns the value into the readout and what screen readers hear. */
|
|
30
|
+
formatValue?: (value: number) => string
|
|
31
|
+
/** Turns a mark into its printed label. Defaults to formatValue. */
|
|
32
|
+
formatMark?: (value: number) => string
|
|
33
|
+
/** A line under the readout, such as what the value means. The detail slot replaces it. */
|
|
34
|
+
detail?: string
|
|
35
|
+
/** A double click goes back to this value. */
|
|
36
|
+
resetValue?: number
|
|
37
|
+
/** A short buzz on each step while it turns, on phones that can (Android). */
|
|
38
|
+
haptics?: boolean
|
|
39
|
+
}>()
|
|
40
|
+
const emit = defineEmits<{ /** The value the dial came to rest on, once it rests. */ valueCommit: [value: number] }>()
|
|
44
41
|
const slots = useSlots()
|
|
45
42
|
|
|
46
|
-
/** The value, set
|
|
43
|
+
/** The value under the index, set on each new one while the dial turns. Use v-model, or leave it out and the dial keeps its own value. */
|
|
47
44
|
const model = defineModel<number>()
|
|
48
|
-
const local = ref(
|
|
45
|
+
const local = ref(defaultValue ?? min)
|
|
49
46
|
const raw = computed({
|
|
50
47
|
get: () => model.value ?? local.value,
|
|
51
48
|
set: (next: number) => {
|
|
@@ -57,17 +54,17 @@ const raw = computed({
|
|
|
57
54
|
const labelId = useId()
|
|
58
55
|
const detailId = useId()
|
|
59
56
|
const goo = useId().replace(/:/g, '')
|
|
60
|
-
const scale = computed(() => ({ min
|
|
57
|
+
const scale = computed(() => ({ min, max, step, marks, variant }))
|
|
61
58
|
const dial = computed(() => dialScale(scale.value))
|
|
62
|
-
const value = computed(() => clamp(raw.value,
|
|
63
|
-
const strongSet = computed(() => new Set(
|
|
64
|
-
const markText = (v: number) => (
|
|
59
|
+
const value = computed(() => clamp(raw.value, min, dial.value.top))
|
|
60
|
+
const strongSet = computed(() => new Set(strong.map((v) => roundTo(v, step, min))))
|
|
61
|
+
const markText = (v: number) => (formatMark ?? formatValue)(v)
|
|
65
62
|
// The arc's rim: its radius and the length of one step along it, both tokens.
|
|
66
63
|
const rim = ref<Rim | null>(null)
|
|
67
64
|
const wheel = wheelSteps()
|
|
68
65
|
|
|
69
66
|
// The drag, keys, tap and wheel (motion/dial.ts) on the shared scrubber.
|
|
70
|
-
const sc = useScrub(() => ({ value: value.value, ...dialScrub(scale.value, rim.value, wheel),
|
|
67
|
+
const sc = useScrub(() => ({ value: value.value, ...dialScrub(scale.value, rim.value, wheel), onMark: (v: number) => (raw.value = v), onSettle: (v: number) => emit('valueCommit', v), haptics }))
|
|
71
68
|
const scrubEl = sc.el
|
|
72
69
|
|
|
73
70
|
// The arc takes only sideways touches, so the page still scrolls under a finger on it (motion/dial.ts).
|
|
@@ -75,42 +72,42 @@ let stopTouch = () => {}
|
|
|
75
72
|
const measureRim = () => {
|
|
76
73
|
stopTouch()
|
|
77
74
|
stopTouch = () => {}
|
|
78
|
-
if (
|
|
75
|
+
if (variant !== 'arc' || !scrubEl.value) return
|
|
79
76
|
rim.value = { r: tokenNumber(scrubEl.value, '--gooee-dial-arc-radius'), gap: tokenNumber(scrubEl.value, '--gooee-dial-arc-gap') }
|
|
80
77
|
stopTouch = arcTouch(scrubEl.value)
|
|
81
78
|
}
|
|
82
79
|
onMounted(measureRim)
|
|
83
|
-
watch(() =>
|
|
80
|
+
watch(() => variant, measureRim, { flush: 'post' })
|
|
84
81
|
onBeforeUnmount(() => stopTouch())
|
|
85
82
|
|
|
86
83
|
const shown = computed(() => dial.value.land(sc.at.value))
|
|
87
|
-
watch(shown, (v) => emit('scrub', v))
|
|
88
84
|
|
|
89
|
-
const hasDetail = computed(() => !!(
|
|
85
|
+
const hasDetail = computed(() => !!(detail || slots.detail))
|
|
90
86
|
const index = computed(() => dial.value.all.indexOf(value.value))
|
|
91
87
|
const sliderAttrs = computed(() => ({
|
|
92
88
|
role: 'slider',
|
|
93
89
|
tabindex: 0,
|
|
94
90
|
'aria-labelledby': labelId,
|
|
95
91
|
'aria-describedby': hasDetail.value ? detailId : undefined,
|
|
96
|
-
'aria-valuemin':
|
|
92
|
+
'aria-valuemin': min,
|
|
97
93
|
'aria-valuemax': dial.value.top,
|
|
98
94
|
'aria-valuenow': value.value,
|
|
99
|
-
'aria-valuetext':
|
|
95
|
+
'aria-valuetext': variant === 'mercury' && index.value >= 0 ? `${formatValue(value.value)}, ${index.value + 1} of ${dial.value.all.length}` : formatValue(value.value),
|
|
96
|
+
'data-slot': 'dial-control',
|
|
100
97
|
'data-moving': sc.moving.value || undefined,
|
|
101
98
|
}))
|
|
102
|
-
const onDblclick = () =>
|
|
99
|
+
const onDblclick = () => resetValue !== undefined && sc.go(dial.value.land(resetValue))
|
|
103
100
|
|
|
104
101
|
// Mercury: the bump on the knob and each level's dot and drop.
|
|
105
102
|
const mercury = computed(() => {
|
|
106
103
|
const { all, stepDeg } = dial.value
|
|
107
104
|
const at = sc.at.value
|
|
108
|
-
const [bx, by] = polar(-135 + ((at -
|
|
105
|
+
const [bx, by] = polar(-135 + ((at - min) / step) * stepDeg, KNOB)
|
|
109
106
|
const levels = all.map((v, i) => {
|
|
110
107
|
const a = -135 + i * stepDeg
|
|
111
108
|
const [x, y] = polar(a, DOT)
|
|
112
109
|
const [lx, ly] = polar(a, DOT + 22)
|
|
113
|
-
const p = pull(at - v,
|
|
110
|
+
const p = pull(at - v, step)
|
|
114
111
|
const [dx, dy] = polar(a, DOT - 12 * p)
|
|
115
112
|
return { v, x, y, lx, ly, anchor: Math.abs(a) < 1 ? 'middle' : a < 0 ? 'end' : 'start', on: v === shown.value, dx, dy, dr: p * 9 }
|
|
116
113
|
})
|
|
@@ -124,9 +121,9 @@ const arcMarks = computed(() => {
|
|
|
124
121
|
if (degPerStep <= 0) return []
|
|
125
122
|
const at = sc.at.value
|
|
126
123
|
return dial.value.all.flatMap((v, i) => {
|
|
127
|
-
const a = ((v - at) /
|
|
124
|
+
const a = ((v - at) / step) * degPerStep
|
|
128
125
|
if (Math.abs(a) > 22) return []
|
|
129
|
-
const p = pull(at - v,
|
|
126
|
+
const p = pull(at - v, step * 1.2)
|
|
130
127
|
const tier = dial.value.labelled.includes(v) ? 'major' : i % 2 === 0 ? 'mid' : 'minor'
|
|
131
128
|
return [{ v, a, p, tier }]
|
|
132
129
|
})
|
|
@@ -134,7 +131,6 @@ const arcMarks = computed(() => {
|
|
|
134
131
|
|
|
135
132
|
// Printed: the face turns under the index.
|
|
136
133
|
const printed = computed(() => {
|
|
137
|
-
const { min, max, step, marks } = props
|
|
138
134
|
const { all, labelled, top } = dial.value
|
|
139
135
|
const turned = ((sc.at.value - min) / (max - min || 1)) * SWEEP
|
|
140
136
|
// The face prints min, the middle and max unless marks say otherwise; the keys still jump by marks.
|
|
@@ -154,11 +150,11 @@ const printed = computed(() => {
|
|
|
154
150
|
</script>
|
|
155
151
|
|
|
156
152
|
<template>
|
|
157
|
-
<div :class="[styles.root, styles[variant]]">
|
|
153
|
+
<div data-slot="dial" :class="[styles.root, styles[variant]]">
|
|
158
154
|
<div :class="styles.head">
|
|
159
|
-
<span :id="labelId" :class="styles.label">{{ label }}</span>
|
|
155
|
+
<span :id="labelId" data-slot="dial-label" :class="styles.label">{{ label }}</span>
|
|
160
156
|
<Roll :text="formatValue(shown)" :class="styles.readout" :still="sc.moving.value" />
|
|
161
|
-
<span v-if="hasDetail" :id="detailId" :class="styles.detail"><slot name="detail">{{ detail }}</slot></span>
|
|
157
|
+
<span v-if="hasDetail" :id="detailId" data-slot="dial-detail" :class="styles.detail"><slot name="detail">{{ detail }}</slot></span>
|
|
162
158
|
</div>
|
|
163
159
|
<div v-if="variant === 'mercury'" ref="scrubEl" :class="styles.mercuryHit" v-bind="sliderAttrs" v-on="sc.handlers" @dblclick="onDblclick">
|
|
164
160
|
<svg :viewBox="`0 0 ${W} ${H}`" :class="styles.mercurySvg" aria-hidden="true">
|
|
@@ -170,8 +166,8 @@ const printed = computed(() => {
|
|
|
170
166
|
</filter>
|
|
171
167
|
</defs>
|
|
172
168
|
<g v-for="l in mercury.levels" :key="l.v">
|
|
173
|
-
<circle :cx="l.x" :cy="l.y" :r="3.5" :class="styles.dot" :data-
|
|
174
|
-
<text :x="l.lx" :y="l.ly" :text-anchor="l.anchor" dominant-baseline="middle" :class="styles.level" :data-
|
|
169
|
+
<circle :cx="l.x" :cy="l.y" :r="3.5" data-slot="dial-tick" :class="styles.dot" :data-selected="l.on || undefined" />
|
|
170
|
+
<text :x="l.lx" :y="l.ly" :text-anchor="l.anchor" dominant-baseline="middle" data-slot="dial-mark" :class="styles.level" :data-selected="l.on || undefined">{{ markText(l.v) }}</text>
|
|
175
171
|
</g>
|
|
176
172
|
<g :filter="`url(#${goo})`" :class="styles.metal">
|
|
177
173
|
<circle :cx="CX" :cy="CY" :r="KNOB" />
|
|
@@ -187,8 +183,8 @@ const printed = computed(() => {
|
|
|
187
183
|
<div :class="styles.hub">
|
|
188
184
|
<span :class="styles.disc" />
|
|
189
185
|
<span v-for="m in arcMarks" :key="m.v" :class="styles.arcMark" :style="{ transform: `rotate(${m.a}deg) translateY(calc(var(--gooee-dial-arc-radius) * -1))` }">
|
|
190
|
-
<i :class="styles.arcTick" :data-tier="m.tier" :style="{ background: ink(m.p, 'var(--gooee-color-border-strong)', 'var(--gooee-color-accent)'), transform: `scaleY(${1 + m.p * 0.7})` }" />
|
|
191
|
-
<span v-if="m.tier === 'major'" :class="styles.arcNum" :style="{ color: ink(m.p), transform: `translateX(-50%) scale(${1 + m.p * 0.3})` }">{{ markText(m.v) }}</span>
|
|
186
|
+
<i data-slot="dial-tick" :class="styles.arcTick" :data-tier="m.tier" :style="{ background: ink(m.p, 'var(--gooee-color-border-strong)', 'var(--gooee-color-accent)'), transform: `scaleY(${1 + m.p * 0.7})` }" />
|
|
187
|
+
<span v-if="m.tier === 'major'" data-slot="dial-mark" :class="styles.arcNum" :style="{ color: ink(m.p), transform: `translateX(-50%) scale(${1 + m.p * 0.3})` }">{{ markText(m.v) }}</span>
|
|
192
188
|
<span v-if="strongSet.has(m.v)" :class="styles.arcStrong" />
|
|
193
189
|
</span>
|
|
194
190
|
</div>
|
|
@@ -205,15 +201,16 @@ const printed = computed(() => {
|
|
|
205
201
|
<div :class="styles.face" :style="{ transform: `rotate(${printed.turned}deg)` }" aria-hidden="true">
|
|
206
202
|
<span v-for="t in printed.ticks" :key="t.v" :class="styles.spoke" :style="{ transform: `rotate(${t.at}deg)` }">
|
|
207
203
|
<i
|
|
204
|
+
data-slot="dial-tick"
|
|
208
205
|
:class="styles.tick"
|
|
209
206
|
:data-major="t.major || undefined"
|
|
210
207
|
:data-fine="t.fine || undefined"
|
|
211
208
|
:data-strong="strongSet.has(t.v) || undefined"
|
|
212
|
-
:data-
|
|
209
|
+
:data-selected="t.v === shown || undefined"
|
|
213
210
|
:style="{ background: ink(t.p, 'var(--gooee-color-border-strong)', 'var(--gooee-color-accent)'), transform: `scaleY(${1 + t.p * 0.5})` }"
|
|
214
211
|
/>
|
|
215
212
|
<span v-if="t.num" :class="styles.numAt" :style="{ transform: `translateY(var(--num-r)) rotate(${-(t.at + printed.turned)}deg)` }">
|
|
216
|
-
<span :class="styles.num" :style="{ color: ink(t.p), transform: `translate(-50%, -50%) scale(${1 + t.p * 0.45})`, fontWeight: `calc(var(--gooee-weight-medium) + (var(--gooee-weight-semibold) - var(--gooee-weight-medium)) * ${t.p.toFixed(3)})` }">{{
|
|
213
|
+
<span data-slot="dial-mark" :class="styles.num" :style="{ color: ink(t.p), transform: `translate(-50%, -50%) scale(${1 + t.p * 0.45})`, fontWeight: `calc(var(--gooee-weight-medium) + (var(--gooee-weight-semibold) - var(--gooee-weight-medium)) * ${t.p.toFixed(3)})` }">{{
|
|
217
214
|
markText(t.v)
|
|
218
215
|
}}</span>
|
|
219
216
|
</span>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.overlay {
|
|
2
3
|
position: fixed;
|
|
3
4
|
inset: 0;
|
|
@@ -101,7 +102,7 @@
|
|
|
101
102
|
color: var(--gooee-color-fg-muted);
|
|
102
103
|
font-size: var(--gooee-icon-lg);
|
|
103
104
|
cursor: pointer;
|
|
104
|
-
transition: background-color var(--gooee-motion-fast) var(--gooee-ease-
|
|
105
|
+
transition: background-color var(--gooee-motion-fast) var(--gooee-ease-morph);
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
/* Looks 32px, keeps a 44px touch area. */
|
|
@@ -109,7 +110,7 @@
|
|
|
109
110
|
|
|
110
111
|
/* Only the icon turns and presses. The button is square to the pointer even though it looks round,
|
|
111
112
|
so turning it would move its corners out from under the pointer and make it flicker. */
|
|
112
|
-
.close svg { transition: transform var(--gooee-motion-slow) var(--gooee-ease-
|
|
113
|
+
.close svg { transition: transform var(--gooee-motion-slow) var(--gooee-ease-morph); }
|
|
113
114
|
|
|
114
115
|
@media (hover: hover) {
|
|
115
116
|
.close:hover { background: var(--gooee-color-surface-hover); color: var(--gooee-color-fg); }
|
|
@@ -194,3 +195,4 @@
|
|
|
194
195
|
|
|
195
196
|
@keyframes slideUp { from { transform: translateY(100%); } }
|
|
196
197
|
@keyframes slideDown { to { transform: translateY(100%); } }
|
|
198
|
+
}
|
|
@@ -4,7 +4,7 @@ import { useId, useRef, type ReactNode, type RefObject } from 'react'
|
|
|
4
4
|
import { cx } from '../../internal/cx'
|
|
5
5
|
import { useDragClose } from '../../internal/fling'
|
|
6
6
|
import { useFocusTrap } from '../../internal/focus'
|
|
7
|
-
import { XIcon } from '../../
|
|
7
|
+
import { XIcon } from '../../icons/icons'
|
|
8
8
|
import { useDismiss, useScrollLock } from '../../internal/layers'
|
|
9
9
|
import { useDialogMorph } from '../../internal/liquid'
|
|
10
10
|
import { Portal } from '../../internal/Portal'
|
|
@@ -28,14 +28,21 @@ export type DialogProps = {
|
|
|
28
28
|
size?: 'sm' | 'md' | 'lg'
|
|
29
29
|
/** Set false for dialogs that must not close by a stray tap, like unsaved work. */
|
|
30
30
|
dismissOnOverlay?: boolean
|
|
31
|
-
/**
|
|
32
|
-
|
|
31
|
+
/** Text for the dialog's controls, so you can translate it. Missing keys use the English defaults. */
|
|
32
|
+
labels?: Partial<DialogLabels>
|
|
33
33
|
/** Element to focus first. Defaults to the first focusable element. */
|
|
34
34
|
initialFocus?: RefObject<HTMLElement | null>
|
|
35
35
|
/** Extra class for the dialog panel. */
|
|
36
36
|
className?: string
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export type DialogLabels = {
|
|
40
|
+
/** Screen reader name for the close button. */
|
|
41
|
+
close: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const defaultLabels: DialogLabels = { close: 'Close' }
|
|
45
|
+
|
|
39
46
|
export function Dialog({
|
|
40
47
|
open,
|
|
41
48
|
onOpenChange,
|
|
@@ -45,10 +52,11 @@ export function Dialog({
|
|
|
45
52
|
footer,
|
|
46
53
|
size = 'md',
|
|
47
54
|
dismissOnOverlay = true,
|
|
48
|
-
|
|
55
|
+
labels: labelsProp,
|
|
49
56
|
initialFocus,
|
|
50
57
|
className,
|
|
51
58
|
}: DialogProps) {
|
|
59
|
+
const labels = { ...defaultLabels, ...labelsProp }
|
|
52
60
|
const id = useId()
|
|
53
61
|
const panelRef = useRef<HTMLDivElement>(null)
|
|
54
62
|
const { mounted, state } = usePresence(open, 'morph-out')
|
|
@@ -68,8 +76,8 @@ export function Dialog({
|
|
|
68
76
|
if (!mounted) return null
|
|
69
77
|
return (
|
|
70
78
|
<Portal>
|
|
71
|
-
<div className={styles.overlay} data-state={state} aria-hidden="true" />
|
|
72
|
-
<div className={styles.positioner}>
|
|
79
|
+
<div data-slot="dialog-overlay" className={styles.overlay} data-state={state} aria-hidden="true" />
|
|
80
|
+
<div data-slot="dialog" className={styles.positioner}>
|
|
73
81
|
<div
|
|
74
82
|
ref={panelRef}
|
|
75
83
|
role="dialog"
|
|
@@ -77,22 +85,23 @@ export function Dialog({
|
|
|
77
85
|
aria-labelledby={`${id}-title`}
|
|
78
86
|
aria-describedby={description ? `${id}-desc` : undefined}
|
|
79
87
|
tabIndex={-1}
|
|
88
|
+
data-slot="dialog-content"
|
|
80
89
|
className={cx(styles.panel, styles[size], className)}
|
|
81
90
|
data-state={state}
|
|
82
91
|
{...(dismissOnOverlay ? grab : {})}
|
|
83
92
|
>
|
|
84
|
-
{dismissOnOverlay && <span className={styles.handle} aria-hidden="true" />}
|
|
85
|
-
<header className={styles.header}>
|
|
93
|
+
{dismissOnOverlay && <span data-slot="dialog-handle" className={styles.handle} aria-hidden="true" />}
|
|
94
|
+
<header data-slot="dialog-header" className={styles.header}>
|
|
86
95
|
<div className={styles.titles}>
|
|
87
|
-
<h2 id={`${id}-title`} className={styles.title}>{title}</h2>
|
|
88
|
-
{description && <p id={`${id}-desc`} className={styles.description}>{description}</p>}
|
|
96
|
+
<h2 id={`${id}-title`} data-slot="dialog-title" className={styles.title}>{title}</h2>
|
|
97
|
+
{description && <p id={`${id}-desc`} data-slot="dialog-description" className={styles.description}>{description}</p>}
|
|
89
98
|
</div>
|
|
90
|
-
<button type="button" className={styles.close} aria-label={
|
|
99
|
+
<button type="button" data-slot="dialog-close" className={styles.close} aria-label={labels.close} data-skip-initial-focus onClick={() => onOpenChange(false)}>
|
|
91
100
|
<XIcon />
|
|
92
101
|
</button>
|
|
93
102
|
</header>
|
|
94
|
-
{children && <div className={styles.body}>{children}</div>}
|
|
95
|
-
{footer && <footer className={styles.footer}>{footer}</footer>}
|
|
103
|
+
{children && <div data-slot="dialog-body" className={styles.body}>{children}</div>}
|
|
104
|
+
{footer && <footer data-slot="dialog-footer" className={styles.footer}>{footer}</footer>}
|
|
96
105
|
</div>
|
|
97
106
|
</div>
|
|
98
107
|
</Portal>
|
|
@@ -9,23 +9,26 @@ import styles from './Dialog.module.css'
|
|
|
9
9
|
|
|
10
10
|
// The Vue Dialog: the same look (Dialog.module.css), morph, focus and drag to close as the React one.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
export type DialogLabels = {
|
|
13
|
+
/** Screen reader name for the close button. */
|
|
14
|
+
close: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { description, size = 'md', dismissOnOverlay = true, labels: labelsProp, initialFocus } = defineProps<{
|
|
18
|
+
/** Heading of the dialog. Also its accessible name. The title slot replaces it. */
|
|
19
|
+
title?: string
|
|
20
|
+
/** Short text under the title, read out when the dialog opens. The description slot replaces it. */
|
|
21
|
+
description?: string
|
|
22
|
+
/** Maximum width of the panel. */
|
|
23
|
+
size?: 'sm' | 'md' | 'lg'
|
|
24
|
+
/** Set false for dialogs that must not close by a stray tap, like unsaved work. */
|
|
25
|
+
dismissOnOverlay?: boolean
|
|
26
|
+
/** Text for the dialog's controls, so you can translate it. Missing keys use the English defaults. */
|
|
27
|
+
labels?: Partial<DialogLabels>
|
|
28
|
+
/** Element to focus first. Defaults to the first focusable element. */
|
|
29
|
+
initialFocus?: HTMLElement | null
|
|
30
|
+
}>()
|
|
31
|
+
const labels = computed<DialogLabels>(() => ({ close: 'Close', ...labelsProp }))
|
|
29
32
|
|
|
30
33
|
/** Shows the dialog. Use v-model:open; the close button, Esc, an outside tap or a pull down set it false. */
|
|
31
34
|
const open = defineModel<boolean>('open', { required: true })
|
|
@@ -33,7 +36,7 @@ const slots = defineSlots<{ default?: () => unknown; title?: () => unknown; desc
|
|
|
33
36
|
|
|
34
37
|
const id = useId()
|
|
35
38
|
const panel = ref<HTMLElement | null>(null)
|
|
36
|
-
const hasDescription = computed(() => !!(
|
|
39
|
+
const hasDescription = computed(() => !!(description || slots.description))
|
|
37
40
|
const close = () => (open.value = false)
|
|
38
41
|
|
|
39
42
|
// Stays in the page through the fold, then leaves.
|
|
@@ -87,7 +90,7 @@ watch(
|
|
|
87
90
|
stop()
|
|
88
91
|
if (!open.value || !panel.value) return
|
|
89
92
|
const el = panel.value
|
|
90
|
-
release.push(lockScroll(), dismissable(() => [el], close, { outside:
|
|
93
|
+
release.push(lockScroll(), dismissable(() => [el], close, { outside: dismissOnOverlay }), trapFocus(el, { initialFocus }))
|
|
91
94
|
},
|
|
92
95
|
{ immediate: true, flush: 'post' },
|
|
93
96
|
)
|
|
@@ -96,18 +99,18 @@ onBeforeUnmount(() => {
|
|
|
96
99
|
clearTimeout(leaving)
|
|
97
100
|
stop()
|
|
98
101
|
morph.destroy()
|
|
99
|
-
drag.
|
|
102
|
+
drag.destroy()
|
|
100
103
|
})
|
|
101
104
|
|
|
102
105
|
const grab = computed(() =>
|
|
103
|
-
|
|
106
|
+
dismissOnOverlay ? { onPointerdown: drag.down, onPointermove: drag.move, onPointerup: drag.up, onPointercancel: drag.up } : {},
|
|
104
107
|
)
|
|
105
108
|
</script>
|
|
106
109
|
|
|
107
110
|
<template>
|
|
108
111
|
<Teleport v-if="mounted" to="body">
|
|
109
|
-
<div :class="styles.overlay" :data-state="state" aria-hidden="true" />
|
|
110
|
-
<div :class="styles.positioner">
|
|
112
|
+
<div data-slot="dialog-overlay" :class="styles.overlay" :data-state="state" aria-hidden="true" />
|
|
113
|
+
<div data-slot="dialog" :class="styles.positioner">
|
|
111
114
|
<div
|
|
112
115
|
ref="panel"
|
|
113
116
|
role="dialog"
|
|
@@ -115,24 +118,25 @@ const grab = computed(() =>
|
|
|
115
118
|
:aria-labelledby="`${id}-title`"
|
|
116
119
|
:aria-describedby="hasDescription ? `${id}-desc` : undefined"
|
|
117
120
|
tabindex="-1"
|
|
121
|
+
data-slot="dialog-content"
|
|
118
122
|
:class="[styles.panel, styles[size]]"
|
|
119
123
|
:data-state="state"
|
|
120
124
|
v-bind="grab"
|
|
121
125
|
>
|
|
122
|
-
<span v-if="dismissOnOverlay" :class="styles.handle" aria-hidden="true" />
|
|
123
|
-
<header :class="styles.header">
|
|
126
|
+
<span v-if="dismissOnOverlay" data-slot="dialog-handle" :class="styles.handle" aria-hidden="true" />
|
|
127
|
+
<header data-slot="dialog-header" :class="styles.header">
|
|
124
128
|
<div :class="styles.titles">
|
|
125
|
-
<h2 :id="`${id}-title`" :class="styles.title"><slot name="title">{{ title }}</slot></h2>
|
|
126
|
-
<p v-if="hasDescription" :id="`${id}-desc`" :class="styles.description"><slot name="description">{{ description }}</slot></p>
|
|
129
|
+
<h2 :id="`${id}-title`" data-slot="dialog-title" :class="styles.title"><slot name="title">{{ title }}</slot></h2>
|
|
130
|
+
<p v-if="hasDescription" :id="`${id}-desc`" data-slot="dialog-description" :class="styles.description"><slot name="description">{{ description }}</slot></p>
|
|
127
131
|
</div>
|
|
128
|
-
<button type="button" :class="styles.close" :aria-label="
|
|
132
|
+
<button type="button" data-slot="dialog-close" :class="styles.close" :aria-label="labels.close" data-skip-initial-focus="true" @click="close">
|
|
129
133
|
<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
130
134
|
<path d="M6 6l12 12M18 6L6 18" />
|
|
131
135
|
</svg>
|
|
132
136
|
</button>
|
|
133
137
|
</header>
|
|
134
|
-
<div v-if="slots.default" :class="styles.body"><slot /></div>
|
|
135
|
-
<footer v-if="slots.footer" :class="styles.footer"><slot name="footer" /></footer>
|
|
138
|
+
<div v-if="slots.default" data-slot="dialog-body" :class="styles.body"><slot /></div>
|
|
139
|
+
<footer v-if="slots.footer" data-slot="dialog-footer" :class="styles.footer"><slot name="footer" /></footer>
|
|
136
140
|
</div>
|
|
137
141
|
</div>
|
|
138
142
|
</Teleport>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
3
|
flex: none;
|
|
3
4
|
background: var(--gooee-color-border);
|
|
@@ -7,8 +8,8 @@
|
|
|
7
8
|
.vertical { align-self: stretch; width: var(--gooee-line); min-height: 1em; }
|
|
8
9
|
|
|
9
10
|
.animated.horizontal,
|
|
10
|
-
.animated .line { animation: drawX var(--gooee-motion-slower) var(--gooee-ease-
|
|
11
|
-
.animated.vertical { animation: drawY var(--gooee-motion-slower) var(--gooee-ease-
|
|
11
|
+
.animated .line { animation: drawX var(--gooee-motion-slower) var(--gooee-ease-morph); }
|
|
12
|
+
.animated.vertical { animation: drawY var(--gooee-motion-slower) var(--gooee-ease-morph); }
|
|
12
13
|
|
|
13
14
|
.labelled {
|
|
14
15
|
display: flex;
|
|
@@ -32,8 +33,9 @@
|
|
|
32
33
|
color: var(--gooee-color-fg-muted);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
.animated .text { animation: fade var(--gooee-motion-slower) var(--gooee-ease-
|
|
36
|
+
.animated .text { animation: fade var(--gooee-motion-slower) var(--gooee-ease-morph); }
|
|
36
37
|
|
|
37
38
|
@keyframes drawX { from { transform: scaleX(0); } }
|
|
38
39
|
@keyframes drawY { from { transform: scaleY(0); } }
|
|
39
40
|
@keyframes fade { from { opacity: 0; } }
|
|
41
|
+
}
|
|
@@ -17,10 +17,10 @@ export function Divider({ orientation = 'horizontal', label, animated = true, cl
|
|
|
17
17
|
if (label && orientation === 'horizontal') {
|
|
18
18
|
// A separator hides its children, so the role sits on the lines and the label is still read.
|
|
19
19
|
return (
|
|
20
|
-
<div className={cx(styles.labelled, animated && styles.animated, className)}>
|
|
21
|
-
<span className={styles.line} role="separator" aria-orientation="horizontal" />
|
|
22
|
-
<span className={styles.text}>{label}</span>
|
|
23
|
-
<span className={styles.line} role="separator" aria-orientation="horizontal" />
|
|
20
|
+
<div data-slot="divider" data-orientation="horizontal" className={cx(styles.labelled, animated && styles.animated, className)}>
|
|
21
|
+
<span data-slot="divider-line" className={styles.line} role="separator" aria-orientation="horizontal" />
|
|
22
|
+
<span data-slot="divider-label" className={styles.text}>{label}</span>
|
|
23
|
+
<span data-slot="divider-line" className={styles.line} role="separator" aria-orientation="horizontal" />
|
|
24
24
|
</div>
|
|
25
25
|
)
|
|
26
26
|
}
|
|
@@ -28,6 +28,8 @@ export function Divider({ orientation = 'horizontal', label, animated = true, cl
|
|
|
28
28
|
<div
|
|
29
29
|
role="separator"
|
|
30
30
|
aria-orientation={orientation}
|
|
31
|
+
data-slot="divider"
|
|
32
|
+
data-orientation={orientation}
|
|
31
33
|
className={cx(styles.root, styles[orientation], animated && styles.animated, className)}
|
|
32
34
|
/>
|
|
33
35
|
)
|
|
@@ -2,26 +2,23 @@
|
|
|
2
2
|
import styles from './Divider.module.css'
|
|
3
3
|
|
|
4
4
|
// The Vue Divider: the same look (Divider.module.css) as the React one.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}>(),
|
|
14
|
-
{ orientation: 'horizontal', animated: true },
|
|
15
|
-
)
|
|
5
|
+
const { orientation = 'horizontal', animated = true } = defineProps<{
|
|
6
|
+
/** Direction of the line. A vertical line stretches to the height of its flex row. */
|
|
7
|
+
orientation?: 'horizontal' | 'vertical'
|
|
8
|
+
/** Text in the middle of a horizontal line, such as "or". The label slot replaces it. */
|
|
9
|
+
label?: string
|
|
10
|
+
/** Draws the line in from the centre when it mounts. */
|
|
11
|
+
animated?: boolean
|
|
12
|
+
}>()
|
|
16
13
|
const slots = defineSlots<{ label?: () => unknown }>()
|
|
17
14
|
</script>
|
|
18
15
|
|
|
19
16
|
<template>
|
|
20
17
|
<!-- A separator hides its children, so the role sits on the lines and the label is still read. -->
|
|
21
|
-
<div v-if="(label || slots.label) && orientation === 'horizontal'" :class="[styles.labelled, animated && styles.animated]">
|
|
22
|
-
<span :class="styles.line" role="separator" aria-orientation="horizontal" />
|
|
23
|
-
<span :class="styles.text"><slot name="label">{{ label }}</slot></span>
|
|
24
|
-
<span :class="styles.line" role="separator" aria-orientation="horizontal" />
|
|
18
|
+
<div v-if="(label || slots.label) && orientation === 'horizontal'" data-slot="divider" data-orientation="horizontal" :class="[styles.labelled, animated && styles.animated]">
|
|
19
|
+
<span data-slot="divider-line" :class="styles.line" role="separator" aria-orientation="horizontal" />
|
|
20
|
+
<span data-slot="divider-label" :class="styles.text"><slot name="label">{{ label }}</slot></span>
|
|
21
|
+
<span data-slot="divider-line" :class="styles.line" role="separator" aria-orientation="horizontal" />
|
|
25
22
|
</div>
|
|
26
|
-
<div v-else role="separator" :aria-orientation="orientation" :class="[styles.root, styles[orientation], animated && styles.animated]" />
|
|
23
|
+
<div v-else role="separator" :aria-orientation="orientation" data-slot="divider" :data-orientation="orientation" :class="[styles.root, styles[orientation], animated && styles.animated]" />
|
|
27
24
|
</template>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.menu {
|
|
2
3
|
--oy: calc(var(--gooee-shift-sm) * -1);
|
|
3
4
|
z-index: var(--gooee-z-popover);
|
|
@@ -15,13 +16,13 @@
|
|
|
15
16
|
outline: none;
|
|
16
17
|
isolation: isolate;
|
|
17
18
|
transform-origin: top left;
|
|
18
|
-
animation: menuIn var(--gooee-motion-base) var(--gooee-ease-
|
|
19
|
+
animation: menuIn var(--gooee-motion-base) var(--gooee-ease-morph);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
.menu[data-side="top"] { --oy: var(--gooee-shift-sm); transform-origin: bottom left; }
|
|
22
23
|
|
|
23
24
|
.menu[data-state="closed"] {
|
|
24
|
-
animation: menuOut var(--gooee-motion-fast) var(--gooee-ease-
|
|
25
|
+
animation: menuOut var(--gooee-motion-fast) var(--gooee-ease-morph) forwards;
|
|
25
26
|
pointer-events: none;
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -42,9 +43,9 @@
|
|
|
42
43
|
cursor: pointer;
|
|
43
44
|
outline: none;
|
|
44
45
|
user-select: none;
|
|
45
|
-
animation: itemIn var(--gooee-motion-slow) var(--gooee-ease-
|
|
46
|
+
animation: itemIn var(--gooee-motion-slow) var(--gooee-ease-morph) backwards;
|
|
46
47
|
animation-delay: calc(var(--i) * var(--gooee-motion-stagger));
|
|
47
|
-
transition: background-color var(--gooee-motion-fast) var(--gooee-ease-
|
|
48
|
+
transition: background-color var(--gooee-motion-fast) var(--gooee-ease-morph);
|
|
48
49
|
--gooee-bead: var(--gooee-color-surface-hover);
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
.menu[data-bead] .item[data-destructive]:not([aria-disabled]):is(:focus, :active) { background: transparent; }
|
|
67
68
|
|
|
68
69
|
.item:focus { background: var(--gooee-color-surface-hover); }
|
|
69
|
-
.item:focus-visible { box-shadow: inset 0 0 0 var(--gooee-
|
|
70
|
+
.item:focus-visible { box-shadow: inset 0 0 0 var(--gooee-focus-width) var(--gooee-color-fg); }
|
|
70
71
|
|
|
71
72
|
.item:active:not([aria-disabled]) {
|
|
72
73
|
background: var(--gooee-color-surface-active);
|
|
@@ -88,7 +89,7 @@
|
|
|
88
89
|
display: inline-flex;
|
|
89
90
|
font-size: var(--gooee-icon-md);
|
|
90
91
|
color: var(--gooee-color-fg-muted);
|
|
91
|
-
transition: transform var(--gooee-motion-base) var(--gooee-ease-
|
|
92
|
+
transition: transform var(--gooee-motion-base) var(--gooee-ease-morph);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
.item:focus .icon { transform: translateX(var(--gooee-space-1)); color: var(--gooee-color-fg); }
|
|
@@ -132,3 +133,4 @@
|
|
|
132
133
|
@keyframes itemIn {
|
|
133
134
|
from { opacity: 0; transform: translateX(calc(var(--gooee-shift-sm) * -1)); }
|
|
134
135
|
}
|
|
136
|
+
}
|