@remix-run/ui 0.1.2 → 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.
- package/README.md +9 -7
- package/dist/animation/demos/animation.demo.d.ts +5 -0
- package/dist/animation/demos/animation.demo.js +92 -0
- package/dist/animation/demos/animation.demo.js.map +1 -0
- package/dist/animation/demos/aspect-ratio.d.ts +2 -0
- package/dist/animation/demos/aspect-ratio.js +69 -0
- package/dist/animation/demos/aspect-ratio.js.map +1 -0
- package/dist/animation/demos/bouncy-switch.d.ts +2 -0
- package/dist/animation/demos/bouncy-switch.js +36 -0
- package/dist/animation/demos/bouncy-switch.js.map +1 -0
- package/dist/animation/demos/color-interpolation.d.ts +1 -0
- package/dist/animation/demos/color-interpolation.js +53 -0
- package/dist/animation/demos/color-interpolation.js.map +1 -0
- package/dist/animation/demos/cube.d.ts +2 -0
- package/dist/animation/demos/cube.js +86 -0
- package/dist/animation/demos/cube.js.map +1 -0
- package/dist/animation/demos/default-animate.d.ts +2 -0
- package/dist/animation/demos/default-animate.js +89 -0
- package/dist/animation/demos/default-animate.js.map +1 -0
- package/dist/animation/demos/drag-release.d.ts +24 -0
- package/dist/animation/demos/drag-release.js +96 -0
- package/dist/animation/demos/drag-release.js.map +1 -0
- package/dist/animation/demos/enter.d.ts +1 -0
- package/dist/animation/demos/enter.js +19 -0
- package/dist/animation/demos/enter.js.map +1 -0
- package/dist/animation/demos/exit.d.ts +2 -0
- package/dist/animation/demos/exit.js +58 -0
- package/dist/animation/demos/exit.js.map +1 -0
- package/dist/animation/demos/flip-toggle.d.ts +2 -0
- package/dist/animation/demos/flip-toggle.js +37 -0
- package/dist/animation/demos/flip-toggle.js.map +1 -0
- package/dist/animation/demos/hold-to-confirm.d.ts +13 -0
- package/dist/animation/demos/hold-to-confirm.js +211 -0
- package/dist/animation/demos/hold-to-confirm.js.map +1 -0
- package/dist/animation/demos/html-content.d.ts +2 -0
- package/dist/animation/demos/html-content.js +30 -0
- package/dist/animation/demos/html-content.js.map +1 -0
- package/dist/animation/demos/interruptible-keyframes.d.ts +1 -0
- package/dist/animation/demos/interruptible-keyframes.js +48 -0
- package/dist/animation/demos/interruptible-keyframes.js.map +1 -0
- package/dist/animation/demos/keyframes.d.ts +1 -0
- package/dist/animation/demos/keyframes.js +24 -0
- package/dist/animation/demos/keyframes.js.map +1 -0
- package/dist/animation/demos/material-ripple.d.ts +2 -0
- package/dist/animation/demos/material-ripple.js +127 -0
- package/dist/animation/demos/material-ripple.js.map +1 -0
- package/dist/animation/demos/mixin-presence-list.d.ts +2 -0
- package/dist/animation/demos/mixin-presence-list.js +88 -0
- package/dist/animation/demos/mixin-presence-list.js.map +1 -0
- package/dist/animation/demos/mixin-reclaim.d.ts +2 -0
- package/dist/animation/demos/mixin-reclaim.js +90 -0
- package/dist/animation/demos/mixin-reclaim.js.map +1 -0
- package/dist/animation/demos/multi-state-badge.d.ts +2 -0
- package/dist/animation/demos/multi-state-badge.js +231 -0
- package/dist/animation/demos/multi-state-badge.js.map +1 -0
- package/dist/animation/demos/press.d.ts +2 -0
- package/dist/animation/demos/press.js +63 -0
- package/dist/animation/demos/press.js.map +1 -0
- package/dist/animation/demos/reordering.d.ts +2 -0
- package/dist/animation/demos/reordering.js +50 -0
- package/dist/animation/demos/reordering.js.map +1 -0
- package/dist/animation/demos/rolling-square.d.ts +2 -0
- package/dist/animation/demos/rolling-square.js +42 -0
- package/dist/animation/demos/rolling-square.js.map +1 -0
- package/dist/animation/demos/rotate.d.ts +1 -0
- package/dist/animation/demos/rotate.js +18 -0
- package/dist/animation/demos/rotate.js.map +1 -0
- package/dist/animation/demos/shared-layout.d.ts +2 -0
- package/dist/animation/demos/shared-layout.js +114 -0
- package/dist/animation/demos/shared-layout.js.map +1 -0
- package/dist/animation/demos/spring.demo.d.ts +6 -0
- package/dist/animation/demos/spring.demo.js +304 -0
- package/dist/animation/demos/spring.demo.js.map +1 -0
- package/dist/animation/demos/transition-options.d.ts +1 -0
- package/dist/animation/demos/transition-options.js +21 -0
- package/dist/animation/demos/transition-options.js.map +1 -0
- package/dist/animation/spring.d.ts +24 -31
- package/dist/animation/spring.js +31 -8
- package/dist/animation/spring.js.map +1 -1
- package/dist/components/accordion/accordion.d.ts +6 -6
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/accordion/demos/card.demo.d.ts +1 -0
- package/dist/components/accordion/demos/card.demo.js +1 -0
- package/dist/components/accordion/demos/card.demo.js.map +1 -1
- package/dist/components/accordion/demos/multiple.demo.d.ts +1 -0
- package/dist/components/accordion/demos/multiple.demo.js +1 -0
- package/dist/components/accordion/demos/multiple.demo.js.map +1 -1
- package/dist/components/accordion/demos/overview.demo.d.ts +1 -0
- package/dist/components/accordion/demos/overview.demo.js +1 -0
- package/dist/components/accordion/demos/overview.demo.js.map +1 -1
- package/dist/components/anchor/anchor.d.ts +8 -1
- package/dist/components/anchor/anchor.js +30 -11
- package/dist/components/anchor/anchor.js.map +1 -1
- package/dist/components/breadcrumbs/{demos/basic.demo.d.ts → basic.demo.d.ts} +1 -0
- package/dist/components/breadcrumbs/{demos/basic.demo.js → basic.demo.js} +1 -0
- package/dist/components/breadcrumbs/basic.demo.js.map +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +1 -1
- package/dist/components/breadcrumbs/{demos/separator.demo.d.ts → separator.demo.d.ts} +1 -0
- package/dist/components/breadcrumbs/{demos/separator.demo.js → separator.demo.js} +1 -0
- package/dist/components/breadcrumbs/separator.demo.js.map +1 -0
- package/dist/components/button/button.d.ts +4 -4
- package/dist/components/button/button.js +3 -1
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button/demos/aliases.demo.d.ts +1 -0
- package/dist/components/button/demos/aliases.demo.js +1 -0
- package/dist/components/button/demos/aliases.demo.js.map +1 -1
- package/dist/components/button/demos/basic.demo.d.ts +1 -0
- package/dist/components/button/demos/basic.demo.js +1 -0
- package/dist/components/button/demos/basic.demo.js.map +1 -1
- package/dist/components/button/demos/states.demo.d.ts +1 -0
- package/dist/components/button/demos/states.demo.js +1 -0
- package/dist/components/button/demos/states.demo.js.map +1 -1
- package/dist/components/combobox/combobox.d.ts +10 -10
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/combobox/{demos/overview.demo.d.ts → overview.demo.d.ts} +1 -0
- package/dist/components/combobox/{demos/overview.demo.js → overview.demo.js} +1 -0
- package/dist/components/combobox/overview.demo.js.map +1 -0
- package/dist/components/listbox/listbox.d.ts +3 -3
- package/dist/components/listbox/listbox.js.map +1 -1
- package/dist/components/listbox/{demos/overview.demo.d.ts → overview.demo.d.ts} +1 -0
- package/dist/components/listbox/{demos/overview.demo.js → overview.demo.js} +1 -0
- package/dist/components/listbox/overview.demo.js.map +1 -0
- package/dist/components/menu/demos/bubbling.demo.d.ts +1 -0
- package/dist/components/menu/demos/bubbling.demo.js +1 -0
- package/dist/components/menu/demos/bubbling.demo.js.map +1 -1
- package/dist/components/menu/demos/context-trigger.demo.d.ts +7 -0
- package/dist/components/menu/demos/context-trigger.demo.js +87 -0
- package/dist/components/menu/demos/context-trigger.demo.js.map +1 -0
- package/dist/components/menu/demos/overview.demo.d.ts +1 -0
- package/dist/components/menu/demos/overview.demo.js +1 -0
- package/dist/components/menu/demos/overview.demo.js.map +1 -1
- package/dist/components/menu/menu.d.ts +15 -12
- package/dist/components/menu/menu.js +55 -0
- package/dist/components/menu/menu.js.map +1 -1
- package/dist/components/popover/{demos/overview.demo.d.ts → overview.demo.d.ts} +1 -0
- package/dist/components/popover/{demos/overview.demo.js → overview.demo.js} +1 -0
- package/dist/components/popover/overview.demo.js.map +1 -0
- package/dist/components/popover/popover.d.ts +7 -7
- package/dist/components/popover/popover.js +11 -4
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/select/{demos/deconstructed.demo.d.ts → deconstructed.demo.d.ts} +1 -0
- package/dist/components/select/{demos/deconstructed.demo.js → deconstructed.demo.js} +1 -0
- package/dist/components/select/deconstructed.demo.js.map +1 -0
- package/dist/components/select/{demos/overview.demo.d.ts → overview.demo.d.ts} +1 -0
- package/dist/components/select/{demos/overview.demo.js → overview.demo.js} +1 -0
- package/dist/components/select/overview.demo.js.map +1 -0
- package/dist/components/select/select.d.ts +10 -10
- package/dist/components/select/select.js +1 -1
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/tabs/tabs.d.ts +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interactions/keydown/keydown.d.ts +1 -1
- package/dist/interactions/outside-click/outside-click-mixin.d.ts +2 -1
- package/dist/interactions/typeahead/typeahead-mixin.d.ts +3 -1
- package/dist/runtime/client-entries.d.ts +1 -2
- package/dist/runtime/client-entries.js.map +1 -1
- package/dist/runtime/component.d.ts +20 -17
- package/dist/runtime/component.js +15 -6
- package/dist/runtime/component.js.map +1 -1
- package/dist/runtime/core/attributes.d.ts +3 -1
- package/dist/runtime/core/attributes.js +19 -1
- package/dist/runtime/core/attributes.js.map +1 -1
- package/dist/runtime/core/props.js +6 -5
- package/dist/runtime/core/props.js.map +1 -1
- package/dist/runtime/demos/basic.demo.d.ts +6 -0
- package/dist/runtime/demos/basic.demo.js +16 -0
- package/dist/runtime/demos/basic.demo.js.map +1 -0
- package/dist/runtime/demos/controlled-uncontrolled-values.demo.d.ts +6 -0
- package/dist/runtime/demos/controlled-uncontrolled-values.demo.js +77 -0
- package/dist/runtime/demos/controlled-uncontrolled-values.demo.js.map +1 -0
- package/dist/runtime/demos/keyed-list.demo.d.ts +6 -0
- package/dist/runtime/demos/keyed-list.demo.js +62 -0
- package/dist/runtime/demos/keyed-list.demo.js.map +1 -0
- package/dist/runtime/demos/readme.demo.d.ts +5 -0
- package/dist/runtime/demos/readme.demo.js +396 -0
- package/dist/runtime/demos/readme.demo.js.map +1 -0
- package/dist/runtime/diff-dom.js +194 -21
- package/dist/runtime/diff-dom.js.map +1 -1
- package/dist/runtime/dom.d.ts +16 -9
- package/dist/runtime/frame.d.ts +7 -0
- package/dist/runtime/frame.js +176 -41
- package/dist/runtime/frame.js.map +1 -1
- package/dist/runtime/jsx.d.ts +3 -4
- package/dist/runtime/jsx.js.map +1 -1
- package/dist/runtime/mixins/link-mixin.d.ts +5 -1
- package/dist/runtime/mixins/link-mixin.js.map +1 -1
- package/dist/runtime/mixins/mixin.d.ts +2 -1
- package/dist/runtime/mixins/mixin.js.map +1 -1
- package/dist/runtime/mixins/ref-mixin.d.ts +2 -1
- package/dist/runtime/mixins/ref-mixin.js.map +1 -1
- package/dist/runtime/reconcile.d.ts +1 -1
- package/dist/runtime/reconcile.js +19 -5
- package/dist/runtime/reconcile.js.map +1 -1
- package/dist/runtime/scheduler.d.ts +10 -10
- package/dist/runtime/scheduler.js +1 -1
- package/dist/runtime/scheduler.js.map +1 -1
- package/dist/runtime/svg-attributes.js +1 -0
- package/dist/runtime/svg-attributes.js.map +1 -1
- package/dist/runtime/to-vnode.js +2 -2
- package/dist/runtime/to-vnode.js.map +1 -1
- package/dist/runtime/vnode.d.ts +6 -1
- package/dist/runtime/vnode.js +4 -0
- package/dist/runtime/vnode.js.map +1 -1
- package/dist/server/stream.d.ts +2 -0
- package/dist/server/stream.js +82 -11
- package/dist/server/stream.js.map +1 -1
- package/dist/style/css-mixin.d.ts +2 -1
- package/dist/style/css-mixin.js.map +1 -1
- package/dist/style/index.d.ts +1 -1
- package/dist/style/style.js +27 -10
- package/dist/style/style.js.map +1 -1
- package/dist/style/stylesheet.d.ts +13 -13
- package/dist/style/stylesheet.js.map +1 -1
- package/dist/theme/contract.d.ts +24 -222
- package/dist/theme/contract.js +2 -2
- package/dist/theme/contract.js.map +1 -1
- package/dist/theme/glyph-contract.d.ts +1 -3
- package/dist/theme/glyph-contract.js.map +1 -1
- package/dist/theme/presets/rmx-01/index.d.ts +4 -2
- package/dist/theme/presets/rmx-01/index.js.map +1 -1
- package/dist/utils/scroll-lock.d.ts +3 -3
- package/dist/utils/scroll-lock.js.map +1 -1
- package/package.json +4 -4
- package/src/animation/README.md +7 -5
- package/src/animation/demos/animation.demo.tsx +194 -0
- package/src/animation/demos/aspect-ratio.tsx +120 -0
- package/src/animation/demos/bouncy-switch.tsx +47 -0
- package/src/animation/demos/color-interpolation.tsx +73 -0
- package/src/animation/demos/cube.tsx +116 -0
- package/src/animation/demos/default-animate.tsx +129 -0
- package/src/animation/demos/drag-release.ts +118 -0
- package/src/animation/demos/enter.tsx +22 -0
- package/src/animation/demos/exit.tsx +79 -0
- package/src/animation/demos/flip-toggle.tsx +46 -0
- package/src/animation/demos/hold-to-confirm.tsx +317 -0
- package/src/animation/demos/html-content.tsx +41 -0
- package/src/animation/demos/interruptible-keyframes.tsx +62 -0
- package/src/animation/demos/keyframes.tsx +29 -0
- package/src/animation/demos/material-ripple.tsx +158 -0
- package/src/animation/demos/mixin-presence-list.tsx +121 -0
- package/src/animation/demos/mixin-reclaim.tsx +125 -0
- package/src/animation/demos/multi-state-badge.tsx +426 -0
- package/src/animation/demos/press.tsx +67 -0
- package/src/animation/demos/reordering.tsx +65 -0
- package/src/animation/demos/rolling-square.tsx +57 -0
- package/src/animation/demos/rotate.tsx +21 -0
- package/src/animation/demos/shared-layout.tsx +211 -0
- package/src/animation/demos/spring.demo.tsx +385 -0
- package/src/animation/demos/transition-options.tsx +24 -0
- package/src/animation/spring.ts +43 -9
- package/src/components/accordion/accordion.tsx +7 -5
- package/src/components/accordion/demos/card.demo.tsx +1 -0
- package/src/components/accordion/demos/multiple.demo.tsx +1 -0
- package/src/components/accordion/demos/overview.demo.tsx +1 -0
- package/src/components/anchor/README.md +11 -3
- package/src/components/anchor/anchor.ts +54 -13
- package/src/components/breadcrumbs/{demos/basic.demo.tsx → basic.demo.tsx} +1 -0
- package/src/components/breadcrumbs/breadcrumbs.tsx +1 -1
- package/src/components/breadcrumbs/{demos/separator.demo.tsx → separator.demo.tsx} +1 -0
- package/src/components/button/button.tsx +30 -18
- package/src/components/button/demos/aliases.demo.tsx +1 -0
- package/src/components/button/demos/basic.demo.tsx +1 -0
- package/src/components/button/demos/states.demo.tsx +1 -0
- package/src/components/combobox/README.md +1 -1
- package/src/components/combobox/combobox.tsx +30 -12
- package/src/components/combobox/{demos/overview.demo.tsx → overview.demo.tsx} +1 -0
- package/src/components/glyph/glyph.tsx +2 -2
- package/src/components/listbox/listbox.ts +88 -83
- package/src/components/listbox/{demos/overview.demo.tsx → overview.demo.tsx} +1 -0
- package/src/components/menu/README.md +26 -2
- package/src/components/menu/demos/bubbling.demo.tsx +1 -0
- package/src/components/menu/demos/context-trigger.demo.tsx +133 -0
- package/src/components/menu/demos/overview.demo.tsx +1 -0
- package/src/components/menu/menu.tsx +100 -16
- package/src/components/popover/{demos/overview.demo.tsx → overview.demo.tsx} +1 -0
- package/src/components/popover/popover.ts +101 -81
- package/src/components/select/{demos/deconstructed.demo.tsx → deconstructed.demo.tsx} +1 -0
- package/src/components/select/{demos/overview.demo.tsx → overview.demo.tsx} +1 -0
- package/src/components/select/select.tsx +27 -10
- package/src/index.ts +1 -0
- package/src/runtime/client-entries.ts +1 -5
- package/src/runtime/component.ts +37 -15
- package/src/runtime/core/attributes.ts +21 -0
- package/src/runtime/core/props.ts +6 -4
- package/src/runtime/demos/basic.demo.tsx +21 -0
- package/src/runtime/demos/controlled-uncontrolled-values.demo.tsx +177 -0
- package/src/runtime/demos/keyed-list.demo.tsx +94 -0
- package/src/runtime/demos/readme.demo.tsx +702 -0
- package/src/runtime/diff-dom.ts +270 -20
- package/src/runtime/dom.ts +16 -9
- package/src/runtime/frame.ts +218 -41
- package/src/runtime/jsx.ts +7 -11
- package/src/runtime/mixins/link-mixin.ts +88 -86
- package/src/runtime/mixins/mixin.ts +9 -1
- package/src/runtime/mixins/ref-mixin.ts +4 -5
- package/src/runtime/reconcile.ts +23 -14
- package/src/runtime/scheduler.ts +20 -20
- package/src/runtime/svg-attributes.ts +1 -0
- package/src/runtime/to-vnode.ts +2 -2
- package/src/runtime/vnode.ts +10 -0
- package/src/server/README.md +4 -2
- package/src/server/stream.ts +84 -10
- package/src/style/css-mixin.ts +6 -1
- package/src/style/index.ts +1 -2
- package/src/style/style.ts +29 -10
- package/src/style/stylesheet.ts +14 -2
- package/src/theme/contract.ts +37 -5
- package/src/theme/glyph-contract.ts +3 -1
- package/src/theme/presets/rmx-01/index.ts +4 -2
- package/src/utils/scroll-lock.ts +7 -3
- package/dist/components/breadcrumbs/demos/basic.demo.js.map +0 -1
- package/dist/components/breadcrumbs/demos/separator.demo.js.map +0 -1
- package/dist/components/combobox/demos/overview.demo.js.map +0 -1
- package/dist/components/listbox/demos/overview.demo.js.map +0 -1
- package/dist/components/popover/demos/overview.demo.js.map +0 -1
- package/dist/components/select/demos/deconstructed.demo.js.map +0 -1
- package/dist/components/select/demos/overview.demo.js.map +0 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { css, on, type Handle, type RemixNode } from '@remix-run/ui'
|
|
2
|
+
import { DefaultAnimate } from './default-animate.tsx'
|
|
3
|
+
import { EnterAnimation } from './enter.tsx'
|
|
4
|
+
import { ExitAnimation } from './exit.tsx'
|
|
5
|
+
import { Press } from './press.tsx'
|
|
6
|
+
import { HTMLContent } from './html-content.tsx'
|
|
7
|
+
import { Keyframes } from './keyframes.tsx'
|
|
8
|
+
import { InterruptibleKeyframes } from './interruptible-keyframes.tsx'
|
|
9
|
+
import { RollingSquare } from './rolling-square.tsx'
|
|
10
|
+
import { Rotate } from './rotate.tsx'
|
|
11
|
+
import { TransitionOptions } from './transition-options.tsx'
|
|
12
|
+
import { Cube } from './cube.tsx'
|
|
13
|
+
import { SharedLayout } from './shared-layout.tsx'
|
|
14
|
+
import { AspectRatio } from './aspect-ratio.tsx'
|
|
15
|
+
import { BouncySwitch } from './bouncy-switch.tsx'
|
|
16
|
+
import { ColorInterpolation } from './color-interpolation.tsx'
|
|
17
|
+
import { FlipToggle } from './flip-toggle.tsx'
|
|
18
|
+
import { Reordering } from './reordering.tsx'
|
|
19
|
+
import { MultiStateBadge } from './multi-state-badge.tsx'
|
|
20
|
+
import { HoldToConfirm } from './hold-to-confirm.tsx'
|
|
21
|
+
import { MaterialRipple } from './material-ripple.tsx'
|
|
22
|
+
|
|
23
|
+
function Tile(handle: Handle<{ title: string; children: RemixNode; notes?: string }>) {
|
|
24
|
+
let remountKey = 0
|
|
25
|
+
|
|
26
|
+
return () => {
|
|
27
|
+
let { title, children, notes } = handle.props
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
mix={[
|
|
32
|
+
css({
|
|
33
|
+
backgroundColor: 'white',
|
|
34
|
+
padding: '40px',
|
|
35
|
+
borderRadius: 12,
|
|
36
|
+
boxShadow: '0 0 10px 0 rgba(0, 0, 0, 0.1)',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
flexDirection: 'column',
|
|
40
|
+
gap: 12,
|
|
41
|
+
position: 'relative',
|
|
42
|
+
}),
|
|
43
|
+
]}
|
|
44
|
+
>
|
|
45
|
+
<button
|
|
46
|
+
mix={[
|
|
47
|
+
css({
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
bottom: 8,
|
|
50
|
+
right: 8,
|
|
51
|
+
width: 18,
|
|
52
|
+
height: 18,
|
|
53
|
+
padding: 0,
|
|
54
|
+
border: 'none',
|
|
55
|
+
background: 'transparent',
|
|
56
|
+
cursor: 'pointer',
|
|
57
|
+
opacity: 0.4,
|
|
58
|
+
'&:hover': {
|
|
59
|
+
opacity: 1,
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
on('click', () => {
|
|
63
|
+
remountKey++
|
|
64
|
+
handle.update()
|
|
65
|
+
}),
|
|
66
|
+
]}
|
|
67
|
+
title="Replay animation"
|
|
68
|
+
>
|
|
69
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
70
|
+
<path d="M1 4v6h6M23 20v-6h-6" />
|
|
71
|
+
<path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15" />
|
|
72
|
+
</svg>
|
|
73
|
+
</button>
|
|
74
|
+
<h3 mix={[css({ margin: 0 })]}>{title}</h3>
|
|
75
|
+
<div
|
|
76
|
+
key={remountKey}
|
|
77
|
+
mix={[
|
|
78
|
+
css({
|
|
79
|
+
flex: 1,
|
|
80
|
+
display: 'flex',
|
|
81
|
+
alignItems: 'center',
|
|
82
|
+
justifyContent: 'center',
|
|
83
|
+
minHeight: 280,
|
|
84
|
+
}),
|
|
85
|
+
]}
|
|
86
|
+
>
|
|
87
|
+
{children}
|
|
88
|
+
</div>
|
|
89
|
+
{notes && (
|
|
90
|
+
<p
|
|
91
|
+
mix={[
|
|
92
|
+
css({
|
|
93
|
+
margin: 0,
|
|
94
|
+
fontSize: 12,
|
|
95
|
+
color: '#666',
|
|
96
|
+
textAlign: 'center',
|
|
97
|
+
maxWidth: '200px',
|
|
98
|
+
}),
|
|
99
|
+
]}
|
|
100
|
+
>
|
|
101
|
+
{notes}
|
|
102
|
+
</p>
|
|
103
|
+
)}
|
|
104
|
+
</div>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @name Animation Gallery
|
|
111
|
+
* @description A collection of motion and animation experiments adapted from the standalone demos.
|
|
112
|
+
*/
|
|
113
|
+
export default function AnimationGallery() {
|
|
114
|
+
return () => (
|
|
115
|
+
<>
|
|
116
|
+
<h1 mix={[css({ marginBottom: 0, '& + p': { marginTop: 0 } })]}>Animations</h1>
|
|
117
|
+
<p>
|
|
118
|
+
Most animations are adapted from <a href="https://www.motion.dev">Motion</a>. Thank you for
|
|
119
|
+
your work <a href="https://motion.dev/@matt">Matt Perry</a>!
|
|
120
|
+
</p>
|
|
121
|
+
<div
|
|
122
|
+
mix={[
|
|
123
|
+
css({
|
|
124
|
+
display: 'grid',
|
|
125
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(320px, 1fr))',
|
|
126
|
+
gap: 24,
|
|
127
|
+
marginTop: 40,
|
|
128
|
+
}),
|
|
129
|
+
]}
|
|
130
|
+
>
|
|
131
|
+
<Tile title="Default Animate" notes="animateEntrance + animateLayout defaults">
|
|
132
|
+
<DefaultAnimate />
|
|
133
|
+
</Tile>
|
|
134
|
+
<Tile title="Rolling Square" notes="CSS transition with spring() timing function">
|
|
135
|
+
<RollingSquare />
|
|
136
|
+
</Tile>
|
|
137
|
+
<Tile title="Enter Animation" notes="animateEntrance() with spring physics">
|
|
138
|
+
<EnterAnimation />
|
|
139
|
+
</Tile>
|
|
140
|
+
<Tile title="Exit Animation" notes="animateEntrance() + animateExit()">
|
|
141
|
+
<ExitAnimation />
|
|
142
|
+
</Tile>
|
|
143
|
+
<Tile title="Press Interaction" notes="CSS transition + pointer/keyboard events">
|
|
144
|
+
<Press />
|
|
145
|
+
</Tile>
|
|
146
|
+
<Tile title="HTML Content" notes="rAF loop with spring iterator for text">
|
|
147
|
+
<HTMLContent />
|
|
148
|
+
</Tile>
|
|
149
|
+
<Tile title="Keyframes" notes="CSS @keyframes with infinite loop">
|
|
150
|
+
<Keyframes />
|
|
151
|
+
</Tile>
|
|
152
|
+
<Tile title="Interruptible Keyframes" notes="Web Animations API with commitStyles()">
|
|
153
|
+
<InterruptibleKeyframes />
|
|
154
|
+
</Tile>
|
|
155
|
+
<Tile title="Rotate" notes="CSS @keyframes (one-shot)">
|
|
156
|
+
<Rotate />
|
|
157
|
+
</Tile>
|
|
158
|
+
<Tile title="Transition Options" notes="animateEntrance() with cubic-bezier + delay">
|
|
159
|
+
<TransitionOptions />
|
|
160
|
+
</Tile>
|
|
161
|
+
<Tile title="3D Cube" notes="rAF loop with direct style manipulation">
|
|
162
|
+
<Cube />
|
|
163
|
+
</Tile>
|
|
164
|
+
<Tile title="Shared Layout" notes="CSS Grid overlap for simultaneous enter/exit">
|
|
165
|
+
<SharedLayout />
|
|
166
|
+
</Tile>
|
|
167
|
+
<Tile title="Aspect Ratio">
|
|
168
|
+
<AspectRatio />
|
|
169
|
+
</Tile>
|
|
170
|
+
<Tile title="Bouncy Switch" notes="Spring up, bounce down with CSS linear()">
|
|
171
|
+
<BouncySwitch />
|
|
172
|
+
</Tile>
|
|
173
|
+
<Tile title="FLIP Toggle" notes="animateLayout() with interruptible WAAPI">
|
|
174
|
+
<FlipToggle />
|
|
175
|
+
</Tile>
|
|
176
|
+
<Tile title="Reordering" notes="animateLayout() with auto-shuffling list">
|
|
177
|
+
<Reordering />
|
|
178
|
+
</Tile>
|
|
179
|
+
<Tile title="Color Interpolation" notes="sRGB vs OKLCH color space">
|
|
180
|
+
<ColorInterpolation />
|
|
181
|
+
</Tile>
|
|
182
|
+
<Tile title="Multi-State Badge" notes="Animated icon/label swap with WAAPI shake">
|
|
183
|
+
<MultiStateBadge />
|
|
184
|
+
</Tile>
|
|
185
|
+
<Tile title="Hold to Confirm" notes="Custom interaction with progress tracking">
|
|
186
|
+
<HoldToConfirm />
|
|
187
|
+
</Tile>
|
|
188
|
+
<Tile title="Material Ripple" notes="Pointer-tracked ripples with enter/exit animations">
|
|
189
|
+
<MaterialRipple />
|
|
190
|
+
</Tile>
|
|
191
|
+
</div>
|
|
192
|
+
</>
|
|
193
|
+
)
|
|
194
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type Handle } from '@remix-run/ui'
|
|
2
|
+
import { css, on } from '@remix-run/ui'
|
|
3
|
+
|
|
4
|
+
import { spring } from '@remix-run/ui/animation'
|
|
5
|
+
|
|
6
|
+
export function AspectRatio(handle: Handle) {
|
|
7
|
+
let aspectRatio = 1
|
|
8
|
+
let width = 100
|
|
9
|
+
|
|
10
|
+
return () => (
|
|
11
|
+
<div
|
|
12
|
+
mix={[
|
|
13
|
+
css({
|
|
14
|
+
display: 'flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
flexDirection: 'column',
|
|
17
|
+
gap: 20,
|
|
18
|
+
}),
|
|
19
|
+
]}
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
22
|
+
mix={[
|
|
23
|
+
css({
|
|
24
|
+
display: 'flex',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
width: 180,
|
|
28
|
+
height: 180,
|
|
29
|
+
}),
|
|
30
|
+
]}
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
mix={[
|
|
34
|
+
css({
|
|
35
|
+
backgroundColor: '#8df0cc',
|
|
36
|
+
borderRadius: 10,
|
|
37
|
+
transition: spring.transition(['width', 'aspect-ratio'], 'bouncy'),
|
|
38
|
+
}),
|
|
39
|
+
]}
|
|
40
|
+
style={{
|
|
41
|
+
width,
|
|
42
|
+
aspectRatio,
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
<div mix={[css({ display: 'flex', flexDirection: 'column', gap: 12, width: '100%' })]}>
|
|
47
|
+
<label
|
|
48
|
+
mix={[
|
|
49
|
+
css({
|
|
50
|
+
display: 'flex',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
gap: 10,
|
|
53
|
+
fontSize: 13,
|
|
54
|
+
color: '#666',
|
|
55
|
+
}),
|
|
56
|
+
]}
|
|
57
|
+
>
|
|
58
|
+
<span mix={[css({ width: 50, flexShrink: 0 })]}>Ratio</span>
|
|
59
|
+
<input
|
|
60
|
+
type="range"
|
|
61
|
+
value={aspectRatio}
|
|
62
|
+
min={0.2}
|
|
63
|
+
max={3}
|
|
64
|
+
step={0.1}
|
|
65
|
+
mix={[
|
|
66
|
+
css(rangeInputCss),
|
|
67
|
+
on('input', (event) => {
|
|
68
|
+
let value = event.currentTarget.value
|
|
69
|
+
|
|
70
|
+
aspectRatio = parseFloat(value)
|
|
71
|
+
handle.update()
|
|
72
|
+
}),
|
|
73
|
+
]}
|
|
74
|
+
/>
|
|
75
|
+
<span mix={[css({ width: 32, textAlign: 'right', fontVariantNumeric: 'tabular-nums' })]}>
|
|
76
|
+
{aspectRatio.toFixed(1)}
|
|
77
|
+
</span>
|
|
78
|
+
</label>
|
|
79
|
+
<label
|
|
80
|
+
mix={[
|
|
81
|
+
css({
|
|
82
|
+
display: 'flex',
|
|
83
|
+
alignItems: 'center',
|
|
84
|
+
gap: 10,
|
|
85
|
+
fontSize: 13,
|
|
86
|
+
color: '#666',
|
|
87
|
+
}),
|
|
88
|
+
]}
|
|
89
|
+
>
|
|
90
|
+
<span mix={[css({ width: 50, flexShrink: 0 })]}>Width</span>
|
|
91
|
+
<input
|
|
92
|
+
type="range"
|
|
93
|
+
value={width}
|
|
94
|
+
min={20}
|
|
95
|
+
max={160}
|
|
96
|
+
step={5}
|
|
97
|
+
mix={[
|
|
98
|
+
css(rangeInputCss),
|
|
99
|
+
on('input', (event) => {
|
|
100
|
+
let value = event.currentTarget.value
|
|
101
|
+
|
|
102
|
+
width = parseFloat(value)
|
|
103
|
+
handle.update()
|
|
104
|
+
}),
|
|
105
|
+
]}
|
|
106
|
+
/>
|
|
107
|
+
<span mix={[css({ width: 32, textAlign: 'right', fontVariantNumeric: 'tabular-nums' })]}>
|
|
108
|
+
{width}
|
|
109
|
+
</span>
|
|
110
|
+
</label>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const rangeInputCss = {
|
|
117
|
+
flex: 1,
|
|
118
|
+
accentColor: '#8df0cc',
|
|
119
|
+
cursor: 'pointer',
|
|
120
|
+
} as const
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Handle } from '@remix-run/ui'
|
|
2
|
+
import { css, on } from '@remix-run/ui'
|
|
3
|
+
|
|
4
|
+
import { spring } from '@remix-run/ui/animation'
|
|
5
|
+
|
|
6
|
+
const bounceEasing = `linear(0, 0.258 12%, 0.424 18.3%, 0.633 24.4%, 0.999 33.3%, 0.783 39.8%, 0.733 42.5%, 0.716 45.1%, 0.731 47.6%, 0.777 50.2%, 0.999 57.7%, 0.906 61.7%, 0.883 63.5%, 0.876 65.2%, 0.901 68.7%, 0.999 74.5%, 0.964 77.4%, 0.953 80.1%, 0.961 82.6%, 1 88.2%, 0.99 91.9%, 1)`
|
|
7
|
+
|
|
8
|
+
export function BouncySwitch(handle: Handle) {
|
|
9
|
+
let isOn = true
|
|
10
|
+
|
|
11
|
+
return () => (
|
|
12
|
+
<div
|
|
13
|
+
mix={[
|
|
14
|
+
css({
|
|
15
|
+
height: 160,
|
|
16
|
+
backgroundColor: '#ff6b35',
|
|
17
|
+
display: 'flex',
|
|
18
|
+
flexDirection: 'column',
|
|
19
|
+
justifyContent: 'flex-end',
|
|
20
|
+
borderRadius: 50,
|
|
21
|
+
padding: 10,
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
}),
|
|
24
|
+
on('click', () => {
|
|
25
|
+
isOn = !isOn
|
|
26
|
+
handle.update()
|
|
27
|
+
}),
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
<div
|
|
31
|
+
mix={[
|
|
32
|
+
css({
|
|
33
|
+
width: 60,
|
|
34
|
+
height: 60,
|
|
35
|
+
backgroundColor: 'white',
|
|
36
|
+
borderRadius: 30,
|
|
37
|
+
willChange: 'transform',
|
|
38
|
+
}),
|
|
39
|
+
]}
|
|
40
|
+
style={{
|
|
41
|
+
transform: isOn ? 'translateY(-100px)' : 'translateY(0)',
|
|
42
|
+
transition: isOn ? `transform ${spring()}` : `transform 800ms ${bounceEasing}`,
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { css } from '@remix-run/ui'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* A comparison of color interpolation methods.
|
|
5
|
+
*
|
|
6
|
+
* The "dimming effect" in browser animations happens because sRGB is
|
|
7
|
+
* gamma-encoded, so linear interpolation passes through desaturated colors.
|
|
8
|
+
*
|
|
9
|
+
* The OKLCH box uses the @property hack: register a custom property as <number>,
|
|
10
|
+
* animate it 0→1, then use color-mix(in oklch, ...) with that number.
|
|
11
|
+
*/
|
|
12
|
+
export function ColorInterpolation() {
|
|
13
|
+
return () => (
|
|
14
|
+
<div mix={[css({ display: 'flex', gap: 30, alignItems: 'center', justifyContent: 'center' })]}>
|
|
15
|
+
<style>
|
|
16
|
+
{`
|
|
17
|
+
@property --color-t {
|
|
18
|
+
syntax: '<number>';
|
|
19
|
+
inherits: false;
|
|
20
|
+
initial-value: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@keyframes color-t-anim {
|
|
24
|
+
0%, 100% { --color-t: 0; }
|
|
25
|
+
50% { --color-t: 1; }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.oklch-box {
|
|
29
|
+
animation: color-t-anim 4s linear infinite;
|
|
30
|
+
background-color: color-mix(
|
|
31
|
+
in oklch,
|
|
32
|
+
#ff0088 calc((1 - var(--color-t)) * 100%),
|
|
33
|
+
#0d63f8 calc(var(--color-t) * 100%)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
`}
|
|
37
|
+
</style>
|
|
38
|
+
|
|
39
|
+
<div mix={[css({ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 16 })]}>
|
|
40
|
+
<div
|
|
41
|
+
mix={[
|
|
42
|
+
css({
|
|
43
|
+
width: 100,
|
|
44
|
+
height: 100,
|
|
45
|
+
borderRadius: 8,
|
|
46
|
+
backgroundColor: '#ff0088',
|
|
47
|
+
'@keyframes srgb-color': {
|
|
48
|
+
'0%, 100%': { backgroundColor: '#ff0088' },
|
|
49
|
+
'50%': { backgroundColor: '#0d63f8' },
|
|
50
|
+
},
|
|
51
|
+
animation: 'srgb-color 4s linear infinite',
|
|
52
|
+
}),
|
|
53
|
+
]}
|
|
54
|
+
/>
|
|
55
|
+
<div mix={[css({ fontSize: 14, color: '#666' })]}>sRGB</div>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div mix={[css({ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 16 })]}>
|
|
59
|
+
<div
|
|
60
|
+
className="oklch-box"
|
|
61
|
+
mix={[
|
|
62
|
+
css({
|
|
63
|
+
width: 100,
|
|
64
|
+
height: 100,
|
|
65
|
+
borderRadius: 8,
|
|
66
|
+
}),
|
|
67
|
+
]}
|
|
68
|
+
/>
|
|
69
|
+
<div mix={[css({ fontSize: 14, color: '#666' })]}>OKLCH</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { Handle } from '@remix-run/ui'
|
|
2
|
+
import { css, ref } from '@remix-run/ui'
|
|
3
|
+
|
|
4
|
+
export function Cube(handle: Handle) {
|
|
5
|
+
let cube: HTMLDivElement
|
|
6
|
+
|
|
7
|
+
function animate(t: number) {
|
|
8
|
+
if (handle.signal.aborted) return
|
|
9
|
+
|
|
10
|
+
let rotate = Math.sin(t / 10000) * 200
|
|
11
|
+
let y = (1 + Math.sin(t / 1000)) * -25
|
|
12
|
+
cube.style.transform = `translateY(${y}px) rotateX(${rotate}deg) rotateY(${rotate}deg)`
|
|
13
|
+
|
|
14
|
+
requestAnimationFrame(animate)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return () => (
|
|
18
|
+
<div
|
|
19
|
+
mix={[
|
|
20
|
+
css({
|
|
21
|
+
perspective: '400px',
|
|
22
|
+
width: '100px',
|
|
23
|
+
height: '100px',
|
|
24
|
+
}),
|
|
25
|
+
]}
|
|
26
|
+
>
|
|
27
|
+
<div
|
|
28
|
+
mix={[
|
|
29
|
+
ref((node) => {
|
|
30
|
+
cube = node
|
|
31
|
+
requestAnimationFrame(animate)
|
|
32
|
+
}),
|
|
33
|
+
css({
|
|
34
|
+
width: '100px',
|
|
35
|
+
height: '100px',
|
|
36
|
+
position: 'relative',
|
|
37
|
+
transformStyle: 'preserve-3d',
|
|
38
|
+
}),
|
|
39
|
+
]}
|
|
40
|
+
>
|
|
41
|
+
<div
|
|
42
|
+
mix={[
|
|
43
|
+
css({
|
|
44
|
+
position: 'absolute',
|
|
45
|
+
width: '100%',
|
|
46
|
+
height: '100%',
|
|
47
|
+
opacity: 0.6,
|
|
48
|
+
transform: 'rotateY(0deg) translateZ(50px)',
|
|
49
|
+
backgroundColor: '#ff0055',
|
|
50
|
+
}),
|
|
51
|
+
]}
|
|
52
|
+
/>
|
|
53
|
+
<div
|
|
54
|
+
mix={[
|
|
55
|
+
css({
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
width: '100%',
|
|
58
|
+
height: '100%',
|
|
59
|
+
opacity: 0.6,
|
|
60
|
+
transform: 'rotateY(90deg) translateZ(50px)',
|
|
61
|
+
backgroundColor: '#0099ff',
|
|
62
|
+
}),
|
|
63
|
+
]}
|
|
64
|
+
/>
|
|
65
|
+
<div
|
|
66
|
+
mix={[
|
|
67
|
+
css({
|
|
68
|
+
position: 'absolute',
|
|
69
|
+
width: '100%',
|
|
70
|
+
height: '100%',
|
|
71
|
+
opacity: 0.6,
|
|
72
|
+
transform: 'rotateY(180deg) translateZ(50px)',
|
|
73
|
+
backgroundColor: '#22cc88',
|
|
74
|
+
}),
|
|
75
|
+
]}
|
|
76
|
+
/>
|
|
77
|
+
<div
|
|
78
|
+
mix={[
|
|
79
|
+
css({
|
|
80
|
+
position: 'absolute',
|
|
81
|
+
width: '100%',
|
|
82
|
+
height: '100%',
|
|
83
|
+
opacity: 0.6,
|
|
84
|
+
transform: 'rotateY(-90deg) translateZ(50px)',
|
|
85
|
+
backgroundColor: '#ffaa00',
|
|
86
|
+
}),
|
|
87
|
+
]}
|
|
88
|
+
/>
|
|
89
|
+
<div
|
|
90
|
+
mix={[
|
|
91
|
+
css({
|
|
92
|
+
position: 'absolute',
|
|
93
|
+
width: '100%',
|
|
94
|
+
height: '100%',
|
|
95
|
+
opacity: 0.6,
|
|
96
|
+
transform: 'rotateX(90deg) translateZ(50px)',
|
|
97
|
+
backgroundColor: '#aa00ff',
|
|
98
|
+
}),
|
|
99
|
+
]}
|
|
100
|
+
/>
|
|
101
|
+
<div
|
|
102
|
+
mix={[
|
|
103
|
+
css({
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
width: '100%',
|
|
106
|
+
height: '100%',
|
|
107
|
+
opacity: 0.6,
|
|
108
|
+
transform: 'rotateX(-90deg) translateZ(50px)',
|
|
109
|
+
backgroundColor: '#ff00aa',
|
|
110
|
+
}),
|
|
111
|
+
]}
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { css, on, type Handle } from '@remix-run/ui'
|
|
2
|
+
import { animateEntrance, animateLayout } from '@remix-run/ui/animation'
|
|
3
|
+
|
|
4
|
+
let nextId = 1
|
|
5
|
+
function createItem() {
|
|
6
|
+
return { id: nextId++, label: `Item ${nextId - 1}` }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function DefaultAnimate(handle: Handle) {
|
|
10
|
+
let items = [createItem(), createItem()]
|
|
11
|
+
|
|
12
|
+
return () => (
|
|
13
|
+
<div
|
|
14
|
+
mix={[
|
|
15
|
+
css({
|
|
16
|
+
display: 'flex',
|
|
17
|
+
flexDirection: 'column',
|
|
18
|
+
gap: 10,
|
|
19
|
+
width: 200,
|
|
20
|
+
alignSelf: 'flex-start',
|
|
21
|
+
}),
|
|
22
|
+
]}
|
|
23
|
+
>
|
|
24
|
+
<div mix={[css({ display: 'flex', gap: 8, marginBottom: 8 })]}>
|
|
25
|
+
<button
|
|
26
|
+
mix={[
|
|
27
|
+
css({
|
|
28
|
+
flex: 1,
|
|
29
|
+
padding: '8px 12px',
|
|
30
|
+
border: 'none',
|
|
31
|
+
borderRadius: 6,
|
|
32
|
+
backgroundColor: '#10b981',
|
|
33
|
+
color: 'white',
|
|
34
|
+
cursor: 'pointer',
|
|
35
|
+
fontWeight: 500,
|
|
36
|
+
'&:hover': { backgroundColor: '#059669' },
|
|
37
|
+
}),
|
|
38
|
+
on('click', () => {
|
|
39
|
+
items.unshift(createItem())
|
|
40
|
+
handle.update()
|
|
41
|
+
}),
|
|
42
|
+
]}
|
|
43
|
+
>
|
|
44
|
+
Add
|
|
45
|
+
</button>
|
|
46
|
+
<button
|
|
47
|
+
mix={[
|
|
48
|
+
css({
|
|
49
|
+
flex: 1,
|
|
50
|
+
padding: '8px 12px',
|
|
51
|
+
border: 'none',
|
|
52
|
+
borderRadius: 6,
|
|
53
|
+
backgroundColor: '#6366f1',
|
|
54
|
+
color: 'white',
|
|
55
|
+
cursor: 'pointer',
|
|
56
|
+
fontWeight: 500,
|
|
57
|
+
'&:hover': { backgroundColor: '#4f46e5' },
|
|
58
|
+
}),
|
|
59
|
+
on('click', () => {
|
|
60
|
+
// Shuffle the array
|
|
61
|
+
for (let i = items.length - 1; i > 0; i--) {
|
|
62
|
+
let j = Math.floor(Math.random() * (i + 1))
|
|
63
|
+
;[items[i], items[j]] = [items[j], items[i]]
|
|
64
|
+
}
|
|
65
|
+
handle.update()
|
|
66
|
+
}),
|
|
67
|
+
]}
|
|
68
|
+
>
|
|
69
|
+
Shuffle
|
|
70
|
+
</button>
|
|
71
|
+
</div>
|
|
72
|
+
{items.map((item) => (
|
|
73
|
+
<div
|
|
74
|
+
key={item.id}
|
|
75
|
+
mix={[
|
|
76
|
+
animateEntrance(),
|
|
77
|
+
animateLayout(),
|
|
78
|
+
css({
|
|
79
|
+
display: 'flex',
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
justifyContent: 'space-between',
|
|
82
|
+
padding: '12px 16px',
|
|
83
|
+
backgroundColor: '#f1f5f9',
|
|
84
|
+
borderRadius: 8,
|
|
85
|
+
fontSize: 14,
|
|
86
|
+
fontWeight: 500,
|
|
87
|
+
color: '#334155',
|
|
88
|
+
}),
|
|
89
|
+
]}
|
|
90
|
+
>
|
|
91
|
+
<span>{item.label}</span>
|
|
92
|
+
<button
|
|
93
|
+
mix={[
|
|
94
|
+
css({
|
|
95
|
+
width: 20,
|
|
96
|
+
height: 20,
|
|
97
|
+
padding: 0,
|
|
98
|
+
border: 'none',
|
|
99
|
+
borderRadius: 4,
|
|
100
|
+
backgroundColor: 'transparent',
|
|
101
|
+
color: '#94a3b8',
|
|
102
|
+
cursor: 'pointer',
|
|
103
|
+
display: 'flex',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
justifyContent: 'center',
|
|
106
|
+
'&:hover': { backgroundColor: '#e2e8f0', color: '#64748b' },
|
|
107
|
+
}),
|
|
108
|
+
on('click', () => {
|
|
109
|
+
items = items.filter((i) => i.id !== item.id)
|
|
110
|
+
handle.update()
|
|
111
|
+
}),
|
|
112
|
+
]}
|
|
113
|
+
>
|
|
114
|
+
<svg
|
|
115
|
+
width="12"
|
|
116
|
+
height="12"
|
|
117
|
+
viewBox="0 0 24 24"
|
|
118
|
+
fill="none"
|
|
119
|
+
stroke="currentColor"
|
|
120
|
+
strokeWidth="2.5"
|
|
121
|
+
>
|
|
122
|
+
<path d="M18 6L6 18M6 6l12 12" />
|
|
123
|
+
</svg>
|
|
124
|
+
</button>
|
|
125
|
+
</div>
|
|
126
|
+
))}
|
|
127
|
+
</div>
|
|
128
|
+
)
|
|
129
|
+
}
|