@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.
Files changed (70) hide show
  1. package/lib/commonjs/avatar/Avatar.js +12 -3
  2. package/lib/commonjs/avatar/Avatar.js.map +1 -1
  3. package/lib/commonjs/button/Button.js +53 -19
  4. package/lib/commonjs/button/Button.js.map +1 -1
  5. package/lib/commonjs/collapsible/Collapsible.js +42 -3
  6. package/lib/commonjs/collapsible/Collapsible.js.map +1 -1
  7. package/lib/commonjs/image-resolver/context.js +20 -0
  8. package/lib/commonjs/image-resolver/context.js.map +1 -0
  9. package/lib/commonjs/image-resolver/index.js +19 -0
  10. package/lib/commonjs/image-resolver/index.js.map +1 -0
  11. package/lib/commonjs/loading/Loading.js +2 -1
  12. package/lib/commonjs/loading/Loading.js.map +1 -1
  13. package/lib/commonjs/skeleton/index.js +31 -8
  14. package/lib/commonjs/skeleton/index.js.map +1 -1
  15. package/lib/commonjs/styles/tokens.js +31 -1
  16. package/lib/commonjs/styles/tokens.js.map +1 -1
  17. package/lib/commonjs/switch/Switch.js +10 -7
  18. package/lib/commonjs/switch/Switch.js.map +1 -1
  19. package/lib/module/avatar/Avatar.js +12 -3
  20. package/lib/module/avatar/Avatar.js.map +1 -1
  21. package/lib/module/button/Button.js +55 -21
  22. package/lib/module/button/Button.js.map +1 -1
  23. package/lib/module/collapsible/Collapsible.js +44 -5
  24. package/lib/module/collapsible/Collapsible.js.map +1 -1
  25. package/lib/module/image-resolver/context.js +16 -0
  26. package/lib/module/image-resolver/context.js.map +1 -0
  27. package/lib/module/image-resolver/index.js +4 -0
  28. package/lib/module/image-resolver/index.js.map +1 -0
  29. package/lib/module/loading/Loading.js +2 -1
  30. package/lib/module/loading/Loading.js.map +1 -1
  31. package/lib/module/skeleton/index.js +31 -8
  32. package/lib/module/skeleton/index.js.map +1 -1
  33. package/lib/module/styles/tokens.js +30 -0
  34. package/lib/module/styles/tokens.js.map +1 -1
  35. package/lib/module/switch/Switch.js +10 -7
  36. package/lib/module/switch/Switch.js.map +1 -1
  37. package/lib/typescript/commonjs/avatar/Avatar.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/button/Button.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/collapsible/Collapsible.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/image-resolver/context.d.ts +8 -0
  41. package/lib/typescript/commonjs/image-resolver/context.d.ts.map +1 -0
  42. package/lib/typescript/commonjs/image-resolver/index.d.ts +2 -0
  43. package/lib/typescript/commonjs/image-resolver/index.d.ts.map +1 -0
  44. package/lib/typescript/commonjs/loading/Loading.d.ts.map +1 -1
  45. package/lib/typescript/commonjs/skeleton/index.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/styles/tokens.d.ts +29 -0
  47. package/lib/typescript/commonjs/styles/tokens.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/switch/Switch.d.ts.map +1 -1
  49. package/lib/typescript/module/avatar/Avatar.d.ts.map +1 -1
  50. package/lib/typescript/module/button/Button.d.ts.map +1 -1
  51. package/lib/typescript/module/collapsible/Collapsible.d.ts.map +1 -1
  52. package/lib/typescript/module/image-resolver/context.d.ts +8 -0
  53. package/lib/typescript/module/image-resolver/context.d.ts.map +1 -0
  54. package/lib/typescript/module/image-resolver/index.d.ts +2 -0
  55. package/lib/typescript/module/image-resolver/index.d.ts.map +1 -0
  56. package/lib/typescript/module/loading/Loading.d.ts.map +1 -1
  57. package/lib/typescript/module/skeleton/index.d.ts.map +1 -1
  58. package/lib/typescript/module/styles/tokens.d.ts +29 -0
  59. package/lib/typescript/module/styles/tokens.d.ts.map +1 -1
  60. package/lib/typescript/module/switch/Switch.d.ts.map +1 -1
  61. package/package.json +12 -1
  62. package/src/avatar/Avatar.tsx +13 -3
  63. package/src/button/Button.tsx +53 -20
  64. package/src/collapsible/Collapsible.tsx +40 -6
  65. package/src/image-resolver/context.ts +16 -0
  66. package/src/image-resolver/index.ts +1 -0
  67. package/src/loading/Loading.tsx +2 -1
  68. package/src/skeleton/index.tsx +42 -12
  69. package/src/styles/tokens.ts +21 -0
  70. package/src/switch/Switch.tsx +5 -7
@@ -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: 250, easing: Easing.out(Easing.cubic) };
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(() => {
@@ -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
- type SkeletonProps = {
7
- blend?: boolean;
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
  ]}
@@ -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
  */
@@ -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
- friction: 8,
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
- friction: 8,
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
- friction: 8,
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={4}
80
+ hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
83
81
  testID={testID}
84
82
  >
85
83
  <Animated.View