|
1 | 1 | <script setup lang="tsx">
|
2 | 2 | /** @jsxImportSource vue */
|
3 |
| -import { AnimateNumber } from 'motion-plus-vue' |
4 |
| -import { motion } from 'motion-v' |
5 | 3 | import { ref } from 'vue'
|
6 | 4 |
|
7 |
| -const isCompact = ref(false) |
8 |
| -const isCurrency = ref(false) |
9 |
| -
|
10 |
| -function Switch({ isOn, toggle }: { isOn: boolean, toggle: () => void }) { |
11 |
| - return ( |
12 |
| - <motion.button |
13 |
| - class="switch-container" |
14 |
| - style={{ |
15 |
| - justifyContent: `flex-${isOn ? 'end' : 'start'}`, |
16 |
| - }} |
17 |
| - initial={false} |
18 |
| - animate={{ |
19 |
| - backgroundColor: isOn |
20 |
| - ? 'var(--hue-6-transparent)' |
21 |
| - : '#586d8c33', |
22 |
| - }} |
23 |
| - onClick={toggle} |
24 |
| - focus={{ |
25 |
| - outline: '2px solid #4ff0b7', |
26 |
| - }} |
27 |
| - > |
28 |
| - <motion.div |
29 |
| - class="switch-handle" |
30 |
| - layout |
31 |
| - data-is-on={isOn} |
32 |
| - transition={{ |
33 |
| - type: 'spring', |
34 |
| - visualDuration: 0.2, |
35 |
| - bounce: 0.2, |
36 |
| - }} |
37 |
| - /> |
38 |
| - </motion.button> |
39 |
| - ) |
40 |
| -} |
| 5 | +const isShow = ref(false) |
41 | 6 | </script>
|
42 | 7 |
|
43 | 8 | <template>
|
44 |
| - <div class="container"> |
45 |
| - <AnimateNumber |
46 |
| - :format="{ |
47 |
| - notation: isCompact ? 'compact' : undefined, |
48 |
| - compactDisplay: isCompact ? 'short' : undefined, |
49 |
| - roundingMode: isCompact ? 'trunc' : undefined, |
50 |
| - style: isCurrency ? 'currency' : undefined, |
51 |
| - currency: isCurrency ? 'USD' : undefined, |
52 |
| - }" |
53 |
| - locales="en-US" |
54 |
| - class="number" |
55 |
| - :transition="{ |
56 |
| - visualDuration: 0.6, |
57 |
| - type: 'spring', |
58 |
| - bounce: 0.25, |
59 |
| - opacity: { duration: 0.3, ease: 'linear' }, |
| 9 | + <button @click="isShow = !isShow"> |
| 10 | + show |
| 11 | + </button> |
| 12 | + <MotionConfig reduced-motion="user"> |
| 13 | + <Motion |
| 14 | + class="w-[100px] h-[100px] bg-red-500" |
| 15 | + :animate="{ |
| 16 | + scale: isShow ? 1 : 0.5, |
60 | 17 | }"
|
61 |
| - :value="123.49" |
62 | 18 | />
|
63 |
| - <div class="controls"> |
64 |
| - <div> |
65 |
| - Currency: |
66 |
| - <Switch |
67 |
| - :is-on="isCurrency" |
68 |
| - :toggle="() => isCurrency = !isCurrency" |
69 |
| - /> |
70 |
| - </div> |
71 |
| - <div> |
72 |
| - Compact: |
73 |
| - <Switch |
74 |
| - :is-on="isCompact" |
75 |
| - :toggle="() => isCompact = !isCompact" |
76 |
| - /> |
77 |
| - </div> |
78 |
| - </div> |
79 |
| - </div> |
| 19 | + </MotionConfig> |
80 | 20 | </template>
|
81 | 21 |
|
82 | 22 | <style>
|
|
0 commit comments