@remix-run/ui 0.2.0 → 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/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 +22 -0
- package/dist/animation/spring.js +22 -0
- package/dist/animation/spring.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/{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/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/{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/{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 +3 -0
- 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 +2 -2
- 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.js +1 -1
- package/dist/components/select/select.js.map +1 -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 +2 -2
- package/dist/runtime/component.js +1 -1
- package/dist/runtime/component.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/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 +2 -3
- package/dist/runtime/jsx.js.map +1 -1
- package/dist/server/stream.js +3 -2
- package/dist/server/stream.js.map +1 -1
- package/dist/style/style.js +27 -10
- package/dist/style/style.js.map +1 -1
- package/package.json +3 -3
- 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 +22 -0
- 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 +53 -12
- package/src/components/breadcrumbs/{demos/basic.demo.tsx → basic.demo.tsx} +1 -0
- package/src/components/breadcrumbs/{demos/separator.demo.tsx → separator.demo.tsx} +1 -0
- 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/{demos/overview.demo.tsx → overview.demo.tsx} +1 -0
- 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 +73 -1
- package/src/components/popover/{demos/overview.demo.tsx → overview.demo.tsx} +1 -0
- package/src/components/popover/popover.ts +18 -9
- 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 +1 -1
- package/src/runtime/client-entries.ts +1 -5
- package/src/runtime/component.ts +3 -3
- 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/frame.ts +218 -41
- package/src/runtime/jsx.ts +6 -10
- package/src/server/stream.ts +7 -2
- package/src/style/style.ts +29 -10
- 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,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
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { addEventListeners, createMixin } from '@remix-run/ui'
|
|
2
|
+
|
|
3
|
+
export const dragVelocityReleaseEventType = 'rmx:drag-velocity-release' as const
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
interface HTMLElementEventMap {
|
|
7
|
+
[dragVelocityReleaseEventType]: DragVelocityEvent
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class DragVelocityEvent extends Event {
|
|
12
|
+
clientX: number
|
|
13
|
+
clientY: number
|
|
14
|
+
velocityX: number // px/s
|
|
15
|
+
velocityY: number // px/s
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
type: typeof dragVelocityReleaseEventType,
|
|
19
|
+
init: { clientX: number; clientY: number; velocityX: number; velocityY: number },
|
|
20
|
+
) {
|
|
21
|
+
super(type, { bubbles: true, cancelable: true })
|
|
22
|
+
this.clientX = init.clientX
|
|
23
|
+
this.clientY = init.clientY
|
|
24
|
+
this.velocityX = init.velocityX
|
|
25
|
+
this.velocityY = init.velocityY
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const baseDragVelocityEvents = createMixin<HTMLElement>((handle) => {
|
|
30
|
+
let target: HTMLElement
|
|
31
|
+
let isTracking = false
|
|
32
|
+
let pointerId: number | null = null
|
|
33
|
+
let lastX = 0
|
|
34
|
+
let lastY = 0
|
|
35
|
+
let lastTime = 0
|
|
36
|
+
let velocityX = 0
|
|
37
|
+
let velocityY = 0
|
|
38
|
+
|
|
39
|
+
let onPointerDown = (event: PointerEvent) => {
|
|
40
|
+
if (!event.isPrimary) return
|
|
41
|
+
isTracking = true
|
|
42
|
+
pointerId = event.pointerId
|
|
43
|
+
lastX = event.clientX
|
|
44
|
+
lastY = event.clientY
|
|
45
|
+
lastTime = performance.now()
|
|
46
|
+
velocityX = 0
|
|
47
|
+
velocityY = 0
|
|
48
|
+
target.setPointerCapture(event.pointerId)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let onPointerMove = (event: PointerEvent) => {
|
|
52
|
+
if (!isTracking) return
|
|
53
|
+
if (!event.isPrimary) return
|
|
54
|
+
if (pointerId != null && event.pointerId !== pointerId) return
|
|
55
|
+
|
|
56
|
+
let now = performance.now()
|
|
57
|
+
let dt = (now - lastTime) / 1000 // seconds
|
|
58
|
+
|
|
59
|
+
if (dt > 0) {
|
|
60
|
+
// Smooth velocity with some decay of previous velocity
|
|
61
|
+
let newVelocityX = (event.clientX - lastX) / dt
|
|
62
|
+
let newVelocityY = (event.clientY - lastY) / dt
|
|
63
|
+
velocityX = velocityX * 0.5 + newVelocityX * 0.5
|
|
64
|
+
velocityY = velocityY * 0.5 + newVelocityY * 0.5
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
lastX = event.clientX
|
|
68
|
+
lastY = event.clientY
|
|
69
|
+
lastTime = now
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let onPointerUp = (event: PointerEvent) => {
|
|
73
|
+
if (!isTracking) return
|
|
74
|
+
if (!event.isPrimary) return
|
|
75
|
+
if (pointerId != null && event.pointerId !== pointerId) return
|
|
76
|
+
isTracking = false
|
|
77
|
+
pointerId = null
|
|
78
|
+
|
|
79
|
+
// If too much time passed since last move, velocity is zero
|
|
80
|
+
let timeSinceLastMove = (performance.now() - lastTime) / 1000
|
|
81
|
+
if (timeSinceLastMove > 0.1) {
|
|
82
|
+
velocityX = 0
|
|
83
|
+
velocityY = 0
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
target.dispatchEvent(
|
|
87
|
+
new DragVelocityEvent(dragVelocityReleaseEventType, {
|
|
88
|
+
clientX: event.clientX,
|
|
89
|
+
clientY: event.clientY,
|
|
90
|
+
velocityX,
|
|
91
|
+
velocityY,
|
|
92
|
+
}),
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let onPointerCancel = () => {
|
|
97
|
+
isTracking = false
|
|
98
|
+
pointerId = null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
handle.addEventListener('insert', (event) => {
|
|
102
|
+
target = event.node
|
|
103
|
+
addEventListeners(target, handle.signal, {
|
|
104
|
+
pointerdown: onPointerDown,
|
|
105
|
+
pointermove: onPointerMove,
|
|
106
|
+
pointerup: onPointerUp,
|
|
107
|
+
pointercancel: onPointerCancel,
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
type DragVelocityEventsMixin = typeof baseDragVelocityEvents & {
|
|
113
|
+
readonly release: typeof dragVelocityReleaseEventType
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const dragVelocityEvents: DragVelocityEventsMixin = Object.assign(baseDragVelocityEvents, {
|
|
117
|
+
release: dragVelocityReleaseEventType,
|
|
118
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { css } from '@remix-run/ui'
|
|
2
|
+
import { animateEntrance, spring } from '@remix-run/ui/animation'
|
|
3
|
+
|
|
4
|
+
export function EnterAnimation() {
|
|
5
|
+
return () => (
|
|
6
|
+
<div
|
|
7
|
+
mix={[
|
|
8
|
+
css({
|
|
9
|
+
width: 100,
|
|
10
|
+
height: 100,
|
|
11
|
+
backgroundColor: '#dd00ee',
|
|
12
|
+
borderRadius: '50%',
|
|
13
|
+
}),
|
|
14
|
+
animateEntrance({
|
|
15
|
+
opacity: 0,
|
|
16
|
+
transform: 'scale(0)',
|
|
17
|
+
...spring({ duration: 400, bounce: 0.5 }),
|
|
18
|
+
}),
|
|
19
|
+
]}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Handle } from '@remix-run/ui'
|
|
2
|
+
import { css, on } from '@remix-run/ui'
|
|
3
|
+
|
|
4
|
+
import { animateEntrance, animateExit, spring } from '@remix-run/ui/animation'
|
|
5
|
+
|
|
6
|
+
export function ExitAnimation(handle: Handle) {
|
|
7
|
+
let isVisible = true
|
|
8
|
+
|
|
9
|
+
let shouldAnimate = false
|
|
10
|
+
handle.queueTask(() => {
|
|
11
|
+
shouldAnimate = true
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
return () => (
|
|
15
|
+
<div
|
|
16
|
+
mix={[
|
|
17
|
+
css({
|
|
18
|
+
display: 'flex',
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
width: '100px',
|
|
21
|
+
height: '160px',
|
|
22
|
+
position: 'relative',
|
|
23
|
+
}),
|
|
24
|
+
]}
|
|
25
|
+
>
|
|
26
|
+
{isVisible && (
|
|
27
|
+
<div
|
|
28
|
+
key="exit-animation"
|
|
29
|
+
mix={[
|
|
30
|
+
css({
|
|
31
|
+
width: '100px',
|
|
32
|
+
height: '100px',
|
|
33
|
+
backgroundColor: '#0cdcf7',
|
|
34
|
+
borderRadius: '10px',
|
|
35
|
+
}),
|
|
36
|
+
animateEntrance(
|
|
37
|
+
shouldAnimate && {
|
|
38
|
+
opacity: 0,
|
|
39
|
+
transform: 'scale(0)',
|
|
40
|
+
...spring('snappy'),
|
|
41
|
+
},
|
|
42
|
+
),
|
|
43
|
+
animateExit({
|
|
44
|
+
opacity: 0,
|
|
45
|
+
transform: 'scale(0)',
|
|
46
|
+
...spring(),
|
|
47
|
+
}),
|
|
48
|
+
]}
|
|
49
|
+
/>
|
|
50
|
+
)}
|
|
51
|
+
<button
|
|
52
|
+
mix={[
|
|
53
|
+
css({
|
|
54
|
+
backgroundColor: '#0cdcf7',
|
|
55
|
+
borderRadius: '10px',
|
|
56
|
+
padding: '10px 20px',
|
|
57
|
+
color: '#0f1115',
|
|
58
|
+
border: 'none',
|
|
59
|
+
cursor: 'pointer',
|
|
60
|
+
position: 'absolute',
|
|
61
|
+
bottom: 0,
|
|
62
|
+
left: 0,
|
|
63
|
+
right: 0,
|
|
64
|
+
transition: `transform 100ms ease-in-out`,
|
|
65
|
+
'&:active': {
|
|
66
|
+
transform: 'translateY(1px)',
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
on('click', () => {
|
|
70
|
+
isVisible = !isVisible
|
|
71
|
+
handle.update()
|
|
72
|
+
}),
|
|
73
|
+
]}
|
|
74
|
+
>
|
|
75
|
+
{isVisible ? 'Hide' : 'Show'}
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { css, on, type Handle } from '@remix-run/ui'
|
|
2
|
+
import { animateLayout } from '@remix-run/ui/animation'
|
|
3
|
+
|
|
4
|
+
export function FlipToggle(handle: Handle) {
|
|
5
|
+
let isOn = false
|
|
6
|
+
|
|
7
|
+
return () => (
|
|
8
|
+
<button
|
|
9
|
+
mix={[
|
|
10
|
+
css({
|
|
11
|
+
width: 90,
|
|
12
|
+
height: 50,
|
|
13
|
+
backgroundColor: 'rgba(153, 17, 255, 0.2)',
|
|
14
|
+
borderRadius: 50,
|
|
15
|
+
cursor: 'pointer',
|
|
16
|
+
display: 'flex',
|
|
17
|
+
padding: 10,
|
|
18
|
+
border: 'none',
|
|
19
|
+
}),
|
|
20
|
+
on('click', () => {
|
|
21
|
+
isOn = !isOn
|
|
22
|
+
handle.update()
|
|
23
|
+
}),
|
|
24
|
+
]}
|
|
25
|
+
style={{
|
|
26
|
+
// The actual layout property that changes
|
|
27
|
+
justifyContent: isOn ? 'flex-start' : 'flex-end',
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
<div
|
|
31
|
+
mix={[
|
|
32
|
+
css({
|
|
33
|
+
width: 30,
|
|
34
|
+
height: 30,
|
|
35
|
+
backgroundColor: '#9911ff',
|
|
36
|
+
borderRadius: '50%',
|
|
37
|
+
}),
|
|
38
|
+
animateLayout({
|
|
39
|
+
duration: 200,
|
|
40
|
+
easing: 'ease-in-out',
|
|
41
|
+
}),
|
|
42
|
+
]}
|
|
43
|
+
/>
|
|
44
|
+
</button>
|
|
45
|
+
)
|
|
46
|
+
}
|