@oxyhq/bloom 0.1.6 → 0.1.8
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/lib/commonjs/avatar/Avatar.js +12 -3
- package/lib/commonjs/avatar/Avatar.js.map +1 -1
- package/lib/commonjs/button/Button.js +53 -19
- package/lib/commonjs/button/Button.js.map +1 -1
- package/lib/commonjs/collapsible/Collapsible.js +42 -3
- package/lib/commonjs/collapsible/Collapsible.js.map +1 -1
- package/lib/commonjs/image-resolver/context.js +20 -0
- package/lib/commonjs/image-resolver/context.js.map +1 -0
- package/lib/commonjs/image-resolver/index.js +19 -0
- package/lib/commonjs/image-resolver/index.js.map +1 -0
- package/lib/commonjs/loading/Loading.js +2 -1
- package/lib/commonjs/loading/Loading.js.map +1 -1
- package/lib/commonjs/skeleton/index.js +31 -8
- package/lib/commonjs/skeleton/index.js.map +1 -1
- package/lib/commonjs/styles/tokens.js +31 -1
- package/lib/commonjs/styles/tokens.js.map +1 -1
- package/lib/commonjs/switch/Switch.js +10 -7
- package/lib/commonjs/switch/Switch.js.map +1 -1
- package/lib/module/avatar/Avatar.js +12 -3
- package/lib/module/avatar/Avatar.js.map +1 -1
- package/lib/module/button/Button.js +55 -21
- package/lib/module/button/Button.js.map +1 -1
- package/lib/module/collapsible/Collapsible.js +44 -5
- package/lib/module/collapsible/Collapsible.js.map +1 -1
- package/lib/module/image-resolver/context.js +16 -0
- package/lib/module/image-resolver/context.js.map +1 -0
- package/lib/module/image-resolver/index.js +4 -0
- package/lib/module/image-resolver/index.js.map +1 -0
- package/lib/module/loading/Loading.js +2 -1
- package/lib/module/loading/Loading.js.map +1 -1
- package/lib/module/skeleton/index.js +31 -8
- package/lib/module/skeleton/index.js.map +1 -1
- package/lib/module/styles/tokens.js +30 -0
- package/lib/module/styles/tokens.js.map +1 -1
- package/lib/module/switch/Switch.js +10 -7
- package/lib/module/switch/Switch.js.map +1 -1
- package/lib/typescript/commonjs/avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/Button.d.ts.map +1 -1
- package/lib/typescript/commonjs/collapsible/Collapsible.d.ts.map +1 -1
- package/lib/typescript/commonjs/image-resolver/context.d.ts +8 -0
- package/lib/typescript/commonjs/image-resolver/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/image-resolver/index.d.ts +2 -0
- package/lib/typescript/commonjs/image-resolver/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/loading/Loading.d.ts.map +1 -1
- package/lib/typescript/commonjs/skeleton/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/styles/tokens.d.ts +29 -0
- package/lib/typescript/commonjs/styles/tokens.d.ts.map +1 -1
- package/lib/typescript/commonjs/switch/Switch.d.ts.map +1 -1
- package/lib/typescript/module/avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/module/button/Button.d.ts.map +1 -1
- package/lib/typescript/module/collapsible/Collapsible.d.ts.map +1 -1
- package/lib/typescript/module/image-resolver/context.d.ts +8 -0
- package/lib/typescript/module/image-resolver/context.d.ts.map +1 -0
- package/lib/typescript/module/image-resolver/index.d.ts +2 -0
- package/lib/typescript/module/image-resolver/index.d.ts.map +1 -0
- package/lib/typescript/module/loading/Loading.d.ts.map +1 -1
- package/lib/typescript/module/skeleton/index.d.ts.map +1 -1
- package/lib/typescript/module/styles/tokens.d.ts +29 -0
- package/lib/typescript/module/styles/tokens.d.ts.map +1 -1
- package/lib/typescript/module/switch/Switch.d.ts.map +1 -1
- package/package.json +12 -1
- package/src/avatar/Avatar.tsx +13 -3
- package/src/button/Button.tsx +53 -20
- package/src/collapsible/Collapsible.tsx +40 -6
- package/src/image-resolver/context.ts +16 -0
- package/src/image-resolver/index.ts +1 -0
- package/src/loading/Loading.tsx +2 -1
- package/src/skeleton/index.tsx +42 -12
- package/src/styles/tokens.ts +21 -0
- package/src/switch/Switch.tsx +5 -7
package/src/loading/Loading.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React, { memo, useEffect, useMemo } from 'react';
|
|
|
2
2
|
import { View, Text, StyleSheet, type DimensionValue } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { useTheme } from '../theme/use-theme';
|
|
5
|
+
import { animation } from '../styles/tokens';
|
|
5
6
|
import { SpinnerIcon } from './SpinnerIcon';
|
|
6
7
|
import type {
|
|
7
8
|
LoadingProps,
|
|
@@ -108,7 +109,7 @@ const TopLoading: React.FC<TopLoadingProps> = ({
|
|
|
108
109
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
109
110
|
const translateY = useSharedValue(showLoading ? 0 : -targetHeight);
|
|
110
111
|
|
|
111
|
-
const timingConfig = { duration:
|
|
112
|
+
const timingConfig = { duration: animation.duration.slow, easing: Easing.out(Easing.cubic) };
|
|
112
113
|
|
|
113
114
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
114
115
|
useEffect(() => {
|
package/src/skeleton/index.tsx
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View, type ViewStyle, type TextStyle, StyleSheet } from 'react-native';
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated, View, type ViewStyle, type TextStyle, StyleSheet } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { useTheme } from '../theme/use-theme';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const SHIMMER_DURATION = 1500;
|
|
7
|
+
const SHIMMER_MIN_OPACITY = 0.4;
|
|
8
|
+
const SHIMMER_MAX_OPACITY = 1;
|
|
9
|
+
|
|
10
|
+
function useShimmer() {
|
|
11
|
+
const opacity = useRef(new Animated.Value(SHIMMER_MAX_OPACITY)).current;
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const loop = Animated.loop(
|
|
15
|
+
Animated.sequence([
|
|
16
|
+
Animated.timing(opacity, {
|
|
17
|
+
toValue: SHIMMER_MIN_OPACITY,
|
|
18
|
+
duration: SHIMMER_DURATION / 2,
|
|
19
|
+
useNativeDriver: true,
|
|
20
|
+
}),
|
|
21
|
+
Animated.timing(opacity, {
|
|
22
|
+
toValue: SHIMMER_MAX_OPACITY,
|
|
23
|
+
duration: SHIMMER_DURATION / 2,
|
|
24
|
+
useNativeDriver: true,
|
|
25
|
+
}),
|
|
26
|
+
]),
|
|
27
|
+
);
|
|
28
|
+
loop.start();
|
|
29
|
+
return () => loop.stop();
|
|
30
|
+
}, [opacity]);
|
|
31
|
+
|
|
32
|
+
return opacity;
|
|
33
|
+
}
|
|
9
34
|
|
|
10
35
|
export function Text({
|
|
11
36
|
blend,
|
|
@@ -15,6 +40,7 @@ export function Text({
|
|
|
15
40
|
blend?: boolean;
|
|
16
41
|
}) {
|
|
17
42
|
const { colors } = useTheme();
|
|
43
|
+
const shimmer = useShimmer();
|
|
18
44
|
const flattened = StyleSheet.flatten(style);
|
|
19
45
|
const width = (flattened as ViewStyle)?.width;
|
|
20
46
|
const lineHeight = (flattened?.lineHeight as number) || 14;
|
|
@@ -26,13 +52,13 @@ export function Text({
|
|
|
26
52
|
{ maxWidth: width as number },
|
|
27
53
|
{ paddingVertical: lineHeight * 0.15 },
|
|
28
54
|
]}>
|
|
29
|
-
<View
|
|
55
|
+
<Animated.View
|
|
30
56
|
style={[
|
|
31
57
|
styles.textInner,
|
|
32
58
|
{
|
|
33
59
|
backgroundColor: colors.contrast50,
|
|
34
60
|
height: lineHeight * 0.7,
|
|
35
|
-
opacity: blend ? 0.6 : 1,
|
|
61
|
+
opacity: Animated.multiply(shimmer, blend ? 0.6 : 1),
|
|
36
62
|
},
|
|
37
63
|
]}
|
|
38
64
|
/>
|
|
@@ -52,20 +78,22 @@ export function Circle({
|
|
|
52
78
|
style?: ViewStyle | ViewStyle[];
|
|
53
79
|
}) {
|
|
54
80
|
const { colors } = useTheme();
|
|
81
|
+
const shimmer = useShimmer();
|
|
82
|
+
|
|
55
83
|
return (
|
|
56
|
-
<View
|
|
84
|
+
<Animated.View
|
|
57
85
|
style={[
|
|
58
86
|
styles.circle,
|
|
59
87
|
{
|
|
60
88
|
backgroundColor: colors.contrast50,
|
|
61
89
|
width: size,
|
|
62
90
|
height: size,
|
|
63
|
-
opacity: blend ? 0.6 : 1,
|
|
91
|
+
opacity: Animated.multiply(shimmer, blend ? 0.6 : 1),
|
|
64
92
|
},
|
|
65
93
|
style,
|
|
66
94
|
]}>
|
|
67
95
|
{children}
|
|
68
|
-
</View>
|
|
96
|
+
</Animated.View>
|
|
69
97
|
);
|
|
70
98
|
}
|
|
71
99
|
|
|
@@ -79,15 +107,17 @@ export function Pill({
|
|
|
79
107
|
style?: ViewStyle | ViewStyle[];
|
|
80
108
|
}) {
|
|
81
109
|
const { colors } = useTheme();
|
|
110
|
+
const shimmer = useShimmer();
|
|
111
|
+
|
|
82
112
|
return (
|
|
83
|
-
<View
|
|
113
|
+
<Animated.View
|
|
84
114
|
style={[
|
|
85
115
|
styles.pill,
|
|
86
116
|
{
|
|
87
117
|
backgroundColor: colors.contrast50,
|
|
88
118
|
width: size * 1.618,
|
|
89
119
|
height: size,
|
|
90
|
-
opacity: blend ? 0.6 : 1,
|
|
120
|
+
opacity: Animated.multiply(shimmer, blend ? 0.6 : 1),
|
|
91
121
|
},
|
|
92
122
|
style,
|
|
93
123
|
]}
|
package/src/styles/tokens.ts
CHANGED
|
@@ -57,6 +57,27 @@ export const borderRadius = {
|
|
|
57
57
|
full: 999,
|
|
58
58
|
} as const;
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Gradient definitions for icon system.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* Animation timing and spring tokens.
|
|
65
|
+
* Centralized values ensure consistent motion across all components.
|
|
66
|
+
*/
|
|
67
|
+
export const animation = {
|
|
68
|
+
duration: {
|
|
69
|
+
instant: 100,
|
|
70
|
+
fast: 150,
|
|
71
|
+
normal: 200,
|
|
72
|
+
slow: 300,
|
|
73
|
+
},
|
|
74
|
+
spring: {
|
|
75
|
+
snappy: { friction: 8, tension: 100 },
|
|
76
|
+
gentle: { friction: 8, tension: 60 },
|
|
77
|
+
bouncy: { friction: 6, tension: 120 },
|
|
78
|
+
},
|
|
79
|
+
} as const;
|
|
80
|
+
|
|
60
81
|
/**
|
|
61
82
|
* Gradient definitions for icon system.
|
|
62
83
|
*/
|
package/src/switch/Switch.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React, { memo, useEffect, useRef } from 'react';
|
|
|
2
2
|
import { Pressable, Animated } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { useTheme } from '../theme/use-theme';
|
|
5
|
+
import { animation } from '../styles/tokens';
|
|
5
6
|
import type { SwitchProps } from './types';
|
|
6
7
|
|
|
7
8
|
const TRACK = { default: { w: 44, h: 26 }, sm: { w: 36, h: 22 } } as const;
|
|
@@ -19,8 +20,7 @@ const SwitchComponent = React.forwardRef<React.ElementRef<typeof Pressable>, Swi
|
|
|
19
20
|
Animated.spring(anim, {
|
|
20
21
|
toValue: value ? 1 : 0,
|
|
21
22
|
useNativeDriver: false,
|
|
22
|
-
|
|
23
|
-
tension: 60,
|
|
23
|
+
...animation.spring.gentle,
|
|
24
24
|
}).start();
|
|
25
25
|
}, [value, anim]);
|
|
26
26
|
|
|
@@ -29,8 +29,7 @@ const SwitchComponent = React.forwardRef<React.ElementRef<typeof Pressable>, Swi
|
|
|
29
29
|
Animated.spring(pressAnim, {
|
|
30
30
|
toValue: 1,
|
|
31
31
|
useNativeDriver: false,
|
|
32
|
-
|
|
33
|
-
tension: 100,
|
|
32
|
+
...animation.spring.snappy,
|
|
34
33
|
}).start();
|
|
35
34
|
};
|
|
36
35
|
|
|
@@ -38,8 +37,7 @@ const SwitchComponent = React.forwardRef<React.ElementRef<typeof Pressable>, Swi
|
|
|
38
37
|
Animated.spring(pressAnim, {
|
|
39
38
|
toValue: 0,
|
|
40
39
|
useNativeDriver: false,
|
|
41
|
-
|
|
42
|
-
tension: 60,
|
|
40
|
+
...animation.spring.gentle,
|
|
43
41
|
}).start();
|
|
44
42
|
};
|
|
45
43
|
|
|
@@ -79,7 +77,7 @@ const SwitchComponent = React.forwardRef<React.ElementRef<typeof Pressable>, Swi
|
|
|
79
77
|
onPressIn={onPressIn}
|
|
80
78
|
onPressOut={onPressOut}
|
|
81
79
|
style={[{ opacity: disabled ? 0.4 : 1 }, style]}
|
|
82
|
-
hitSlop={
|
|
80
|
+
hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
|
|
83
81
|
testID={testID}
|
|
84
82
|
>
|
|
85
83
|
<Animated.View
|