gooee 0.52.0 → 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clamp, pull, speedTracker } from '../feel'
|
|
2
|
-
import { easing,
|
|
2
|
+
import { easing, motionMs } from '../motion'
|
|
3
3
|
import { release } from './fling'
|
|
4
4
|
|
|
5
5
|
// A stack of cards: the top one is thrown to either side to decide. The part keeps the decisions as its
|
|
@@ -9,12 +9,43 @@ import { release } from './fling'
|
|
|
9
9
|
export type DeckSide = -1 | 1
|
|
10
10
|
export type DeckDir = 'start' | 'end'
|
|
11
11
|
|
|
12
|
+
/** SwipeDeck's text, shared by React and Vue. */
|
|
13
|
+
export type SwipeDeckLabels = {
|
|
14
|
+
/** The two button words, for the start side then the end side. */
|
|
15
|
+
actions: [string, string]
|
|
16
|
+
/** What screen readers say was done, start then end, such as "Passed" and "Saved". */
|
|
17
|
+
decided: [string, string]
|
|
18
|
+
/** Screen reader name of the undo button. */
|
|
19
|
+
undo: string
|
|
20
|
+
/** Shown when every card has been decided. */
|
|
21
|
+
empty: string
|
|
22
|
+
/** What screen readers call the deck. */
|
|
23
|
+
deck: string
|
|
24
|
+
/** Said after a decision, about the card now on top. */
|
|
25
|
+
next: (index: number, total: number, name: string) => string
|
|
26
|
+
/** Said after the last card is decided. */
|
|
27
|
+
last: string
|
|
28
|
+
/** Said when undo brings a card back. */
|
|
29
|
+
undone: (name: string, index: number, total: number) => string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const defaultSwipeDeckLabels: SwipeDeckLabels = {
|
|
33
|
+
actions: ['Pass', 'Save'],
|
|
34
|
+
decided: ['Passed', 'Saved'],
|
|
35
|
+
undo: 'Undo the last decision',
|
|
36
|
+
empty: 'That was the last card.',
|
|
37
|
+
deck: 'card deck',
|
|
38
|
+
next: (index, total, name) => `Card ${index} of ${total}: ${name}.`,
|
|
39
|
+
last: 'No more cards.',
|
|
40
|
+
undone: (name, index, total) => `Brought back: ${name}. Card ${index} of ${total}.`,
|
|
41
|
+
}
|
|
42
|
+
|
|
12
43
|
/** What a drag needs from a pointer event: native and React events both have these. */
|
|
13
44
|
type Press = { clientX: number; clientY: number; pointerId: number; pointerType: string; button: number; timeStamp: number; currentTarget: EventTarget | null }
|
|
14
45
|
|
|
15
46
|
// A press is a drag only once it moves this far sideways, so a tap on a card's own button stays a tap.
|
|
16
47
|
const SLOP = 8
|
|
17
|
-
// The throw rule: past --gooee-deck-throw of the card's width, or a flick this fast that has moved at least FLICK_MIN.
|
|
48
|
+
// The throw rule: past --gooee-swipe-deck-throw of the card's width, or a flick this fast that has moved at least FLICK_MIN.
|
|
18
49
|
const FLICK = 600
|
|
19
50
|
const FLICK_MIN = 40
|
|
20
51
|
const TILT = 0.06
|
|
@@ -58,7 +89,7 @@ export function createSwipeDeck(o: SwipeDeckOptions) {
|
|
|
58
89
|
const physical = (dir: DeckDir): DeckSide => ((dir === 'end') !== rtl() ? 1 : -1)
|
|
59
90
|
const widthOf = () => o.top()?.offsetWidth || o.deck()?.offsetWidth || 300
|
|
60
91
|
const line = () => widthOf() * share
|
|
61
|
-
const reduced = () =>
|
|
92
|
+
const reduced = () => motionMs('morph-out') === 0
|
|
62
93
|
|
|
63
94
|
const paint = (x: number) => {
|
|
64
95
|
at = x
|
|
@@ -106,7 +137,7 @@ export function createSwipeDeck(o: SwipeDeckOptions) {
|
|
|
106
137
|
busy = true
|
|
107
138
|
stop()
|
|
108
139
|
if (reduced()) {
|
|
109
|
-
const anim = el.animate({ opacity: [1, 0] }, { duration:
|
|
140
|
+
const anim = el.animate({ opacity: [1, 0] }, { duration: motionMs('base'), easing: easing('morph'), fill: 'forwards' })
|
|
110
141
|
let ended = false
|
|
111
142
|
const end = () => {
|
|
112
143
|
if (ended) return
|
|
@@ -157,10 +188,10 @@ export function createSwipeDeck(o: SwipeDeckOptions) {
|
|
|
157
188
|
named,
|
|
158
189
|
physical,
|
|
159
190
|
fly,
|
|
160
|
-
/** Reads the throw line from --gooee-deck-throw. Call once the deck is in the page. */
|
|
191
|
+
/** Reads the throw line from --gooee-swipe-deck-throw. Call once the deck is in the page. */
|
|
161
192
|
mount() {
|
|
162
193
|
const root = o.root()
|
|
163
|
-
share = (root ? parseFloat(getComputedStyle(root).getPropertyValue('--gooee-deck-throw')) || 0 : 0) || share
|
|
194
|
+
share = (root ? parseFloat(getComputedStyle(root).getPropertyValue('--gooee-swipe-deck-throw')) || 0 : 0) || share
|
|
164
195
|
},
|
|
165
196
|
destroy: () => stop(),
|
|
166
197
|
/** Asks to bring the last card back from `side`. False while a card is moving: then nothing changes. */
|
|
@@ -179,7 +210,7 @@ export function createSwipeDeck(o: SwipeDeckOptions) {
|
|
|
179
210
|
undoing = null
|
|
180
211
|
if (!el) return playQueue()
|
|
181
212
|
if (reduced()) {
|
|
182
|
-
const anim = el.animate({ opacity: [0, 1] }, { duration:
|
|
213
|
+
const anim = el.animate({ opacity: [0, 1] }, { duration: motionMs('base'), easing: easing('morph') })
|
|
183
214
|
let ended = false
|
|
184
215
|
anim.finished.then(
|
|
185
216
|
() => !ended && playQueue(),
|
|
@@ -58,13 +58,10 @@ export function revealCell(el: HTMLElement, target: EventTarget | null) {
|
|
|
58
58
|
else if (r.right > box.right) el.scrollLeft += r.right - box.right
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
* they snap there with the spring, so the table visibly splits apart and closes up again. Returns the new places.
|
|
64
|
-
*/
|
|
65
|
-
export function flipRows(table: HTMLElement, last: Map<string, number>, regrouped: boolean) {
|
|
61
|
+
/** FLIP: rows glide from their last place to the new one. Returns the new places. */
|
|
62
|
+
export function flipRows(table: HTMLElement, last: Map<string, number>) {
|
|
66
63
|
const duration = motionMs('slow')
|
|
67
|
-
const ease = easing(
|
|
64
|
+
const ease = easing('morph')
|
|
68
65
|
const now = new Map<string, number>()
|
|
69
66
|
table.querySelectorAll<HTMLElement>('tbody [data-row-id]').forEach((tr) => {
|
|
70
67
|
const rid = tr.dataset.rowId!
|
|
@@ -62,7 +62,7 @@ export function createThemeIcon(body: () => SVGPathElement | null, start: number
|
|
|
62
62
|
cancelAnimationFrame(raf)
|
|
63
63
|
if (!el) return
|
|
64
64
|
const from = shown
|
|
65
|
-
const length = motionMs('
|
|
65
|
+
const length = motionMs('morph-out')
|
|
66
66
|
if (from === to || !length || prefersReducedMotion()) {
|
|
67
67
|
shown = to
|
|
68
68
|
draw(el, to)
|
|
@@ -33,7 +33,7 @@ function radiusFor(share: number, x: number, y: number, reach: number) {
|
|
|
33
33
|
*/
|
|
34
34
|
export function themeReveal(origin: Element | null, applyNow: () => void | Promise<void>) {
|
|
35
35
|
const root = document.documentElement
|
|
36
|
-
const ms = motionMs('
|
|
36
|
+
const ms = motionMs('morph-out')
|
|
37
37
|
if (prefersReducedMotion() || !ms) return void applyNow()
|
|
38
38
|
running?.skipTransition()
|
|
39
39
|
root.dataset.gooeeThemeSwitch = ''
|
|
@@ -6,7 +6,7 @@ import { castShadow, frames, layer, morphEase, motionFor, shadowOf } from './liq
|
|
|
6
6
|
// The toast stack, the same in every framework: where each toast sits, how long it stays, the throw
|
|
7
7
|
// that sends it away, and the drop it buds out of.
|
|
8
8
|
|
|
9
|
-
export type
|
|
9
|
+
export type ToastTone = 'neutral' | 'info' | 'success' | 'danger'
|
|
10
10
|
export type ToastOrigin = HTMLElement | { x: number; y: number }
|
|
11
11
|
export type ToastLeaving = false | 'down' | 'left' | 'right'
|
|
12
12
|
|
|
@@ -25,7 +25,7 @@ export function toastSay(prev: string, opts: { title?: string; description?: str
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/** Where each toast sits, newest first, and how tall the stack is. */
|
|
28
|
-
export function toastLayout<T extends { id: number; leaving: ToastLeaving }>(items: T[], heights: Record<number, number>, expanded: boolean,
|
|
28
|
+
export function toastLayout<T extends { id: number; leaving: ToastLeaving }>(items: T[], heights: Record<number, number>, expanded: boolean, max: number) {
|
|
29
29
|
const live = items.filter((t) => !t.leaving)
|
|
30
30
|
const order = [...items].reverse()
|
|
31
31
|
let offset = 0
|
|
@@ -37,7 +37,7 @@ export function toastLayout<T extends { id: number; leaving: ToastLeaving }>(ite
|
|
|
37
37
|
return { t, index, y }
|
|
38
38
|
})
|
|
39
39
|
const frontHeight = live.length ? (heights[live[live.length - 1].id] ?? 64) : 0
|
|
40
|
-
const stackHeight = expanded ? offset : frontHeight + Math.min(live.length - 1,
|
|
40
|
+
const stackHeight = expanded ? offset : frontHeight + Math.min(live.length - 1, max - 1) * TOAST_PEEK
|
|
41
41
|
return { layout, live: live.length, frontHeight, height: live.length ? stackHeight : 0 }
|
|
42
42
|
}
|
|
43
43
|
|
package/src/internal/motion.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { MORPH, type Curve } from './feel'
|
|
2
2
|
|
|
3
|
-
export type MotionToken = 'instant' | 'fast' | 'base' | 'slow' | 'slower' | '
|
|
3
|
+
export type MotionToken = 'instant' | 'fast' | 'base' | 'slow' | 'slower' | 'morph' | 'morph-out' | 'stagger' | 'delay-tooltip'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function readMotionMs(name: string): number {
|
|
5
|
+
/** A duration custom property in ms, read at run time. For a part's own token; the shared ones go through motionMs. */
|
|
6
|
+
export function durationOf(property: string): number {
|
|
8
7
|
if (typeof window === 'undefined') return 0
|
|
9
|
-
const
|
|
10
|
-
const raw = style.getPropertyValue(`--gooee-motion-${name}`).trim()
|
|
8
|
+
const raw = getComputedStyle(document.documentElement).getPropertyValue(property).trim()
|
|
11
9
|
if (!raw) return 0
|
|
12
10
|
const match = raw.match(/(-?[\d.]+)(ms|s)\b/)
|
|
13
11
|
if (!match) return 0
|
|
@@ -17,11 +15,12 @@ export function readMotionMs(name: string): number {
|
|
|
17
15
|
return times ? base * parseFloat(times[1]) : base
|
|
18
16
|
}
|
|
19
17
|
|
|
18
|
+
/** A --gooee-motion-* token in ms, read at run time, so reduced motion (0ms) and Retime reach JS timers too. */
|
|
20
19
|
export function motionMs(token: MotionToken): number {
|
|
21
|
-
return
|
|
20
|
+
return durationOf(`--gooee-motion-${token}`)
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
export function easing(name: '
|
|
23
|
+
export function easing(name: 'morph' | 'in-out' | 'linear'): string {
|
|
25
24
|
if (typeof window === 'undefined') return 'ease'
|
|
26
25
|
return getComputedStyle(document.documentElement).getPropertyValue(`--gooee-ease-${name}`).trim() || 'ease'
|
|
27
26
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useLayoutEffect, useRef } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { createScrollFrame, type ScrollReader } from './motion/scrollFrame'
|
|
3
3
|
|
|
4
4
|
export { bandProgress, easeToward, readScrollTokens, scrollTokens, type ScrollFrame, type ScrollReader, type ScrollTokens } from './motion/scrollFrame'
|
|
5
5
|
|
|
6
|
-
/** React's hold on
|
|
6
|
+
/** React's hold on createScrollFrame (motion/scrollFrame.ts): calls the latest `read` on mount and every frame while the page moves. */
|
|
7
7
|
export function useScrollFrame(read: ScrollReader, active = true) {
|
|
8
8
|
const ref = useRef(read)
|
|
9
9
|
useLayoutEffect(() => {
|
|
@@ -11,6 +11,6 @@ export function useScrollFrame(read: ScrollReader, active = true) {
|
|
|
11
11
|
})
|
|
12
12
|
useLayoutEffect(() => {
|
|
13
13
|
if (!active) return
|
|
14
|
-
return
|
|
14
|
+
return createScrollFrame((f) => ref.current(f)).destroy
|
|
15
15
|
}, [active])
|
|
16
16
|
}
|
package/src/internal/useScrub.ts
CHANGED
|
@@ -22,8 +22,7 @@ export function useScrub(o: UseScrubOptions) {
|
|
|
22
22
|
const wheels = !!o.wheel
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
const el = ref.current
|
|
25
|
-
if (
|
|
26
|
-
return s.wheelOn(el)
|
|
25
|
+
if (el && wheels) s.listenWheel(el)
|
|
27
26
|
}, [s, wheels])
|
|
28
27
|
useEffect(() => () => s.destroy(), [s])
|
|
29
28
|
|
|
@@ -40,16 +39,3 @@ export function useScrub(o: UseScrubOptions) {
|
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
export { ink, sideways, tokenNumber } from './motion/scrubLook'
|
|
43
|
-
|
|
44
|
-
/** Calls `fn` each time `value` changes (by `key`), but not for the value it starts with. */
|
|
45
|
-
export function useOnChange<T>(value: T, fn: ((value: T) => void) | undefined, key = String(value)) {
|
|
46
|
-
const latest = useRef(fn)
|
|
47
|
-
latest.current = fn
|
|
48
|
-
const seen = useRef(key)
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (seen.current === key) return
|
|
51
|
-
seen.current = key
|
|
52
|
-
latest.current?.(value)
|
|
53
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
-
}, [key])
|
|
55
|
-
}
|
|
@@ -18,14 +18,10 @@ export function useScrub(options: () => UseScrubOptions) {
|
|
|
18
18
|
// when it came to rest.
|
|
19
19
|
watch([() => options().value, moving], () => s.sync(options().value), { flush: 'post' })
|
|
20
20
|
|
|
21
|
-
let stopWheel = () => {}
|
|
22
21
|
onMounted(() => {
|
|
23
|
-
if (el.value && options().wheel)
|
|
24
|
-
})
|
|
25
|
-
onBeforeUnmount(() => {
|
|
26
|
-
stopWheel()
|
|
27
|
-
s.destroy()
|
|
22
|
+
if (el.value && options().wheel) s.listenWheel(el.value)
|
|
28
23
|
})
|
|
24
|
+
onBeforeUnmount(() => s.destroy())
|
|
29
25
|
|
|
30
26
|
return {
|
|
31
27
|
el,
|