jp-composter 0.1.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.
Files changed (194) hide show
  1. package/dist/index.d.mts +997 -0
  2. package/dist/index.d.ts +997 -0
  3. package/dist/index.js +36837 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +36778 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +66 -0
  8. package/src/SliceUI/IconMoon.tsx +33 -0
  9. package/src/SliceUI/assets/Anatomy diagram copy.svg +19 -0
  10. package/src/SliceUI/assets/Anatomy diagram.svg +19 -0
  11. package/src/SliceUI/assets/Anatomycheck.svg +15 -0
  12. package/src/SliceUI/assets/Anatomyinput.svg +32 -0
  13. package/src/SliceUI/assets/Checkbox.jpg +0 -0
  14. package/src/SliceUI/assets/Diagram copy.svg +15 -0
  15. package/src/SliceUI/assets/Diagram.jpg +0 -0
  16. package/src/SliceUI/assets/Diagram.svg +15 -0
  17. package/src/SliceUI/assets/Frame 5 copy.png +0 -0
  18. package/src/SliceUI/assets/Frame 5.png +0 -0
  19. package/src/SliceUI/assets/Frame 65.png +0 -0
  20. package/src/SliceUI/assets/Frame_65.png +0 -0
  21. package/src/SliceUI/assets/Icon copy.svg +3 -0
  22. package/src/SliceUI/assets/Icon.svg +3 -0
  23. package/src/SliceUI/assets/Icon_Bridging copy.svg +39 -0
  24. package/src/SliceUI/assets/Icon_Bridging.svg +39 -0
  25. package/src/SliceUI/assets/Icon_Consistent copy.svg +39 -0
  26. package/src/SliceUI/assets/Icon_Consistent.svg +39 -0
  27. package/src/SliceUI/assets/Icon_Plug copy.svg +38 -0
  28. package/src/SliceUI/assets/Icon_Plug.svg +38 -0
  29. package/src/SliceUI/assets/Icon_Reusable copy.svg +39 -0
  30. package/src/SliceUI/assets/Icon_Reusable.svg +39 -0
  31. package/src/SliceUI/assets/Layer_1.png +0 -0
  32. package/src/SliceUI/assets/accessibility.png +0 -0
  33. package/src/SliceUI/assets/accessibility.svg +1 -0
  34. package/src/SliceUI/assets/addon-library.png +0 -0
  35. package/src/SliceUI/assets/assets.png +0 -0
  36. package/src/SliceUI/assets/avif-test-image.avif +0 -0
  37. package/src/SliceUI/assets/bridging.svg +13 -0
  38. package/src/SliceUI/assets/consistent.svg +11 -0
  39. package/src/SliceUI/assets/context.png +0 -0
  40. package/src/SliceUI/assets/discord.svg +1 -0
  41. package/src/SliceUI/assets/docs.png +0 -0
  42. package/src/SliceUI/assets/figma-plugin.png +0 -0
  43. package/src/SliceUI/assets/github.svg +1 -0
  44. package/src/SliceUI/assets/resources/Anatomy diagram.svg +19 -0
  45. package/src/SliceUI/assets/resources/Anatomycheck.svg +15 -0
  46. package/src/SliceUI/assets/resources/Anatomyinput.svg +32 -0
  47. package/src/SliceUI/assets/resources/Diagram.svg +15 -0
  48. package/src/SliceUI/assets/resources/Frame 5.png +0 -0
  49. package/src/SliceUI/assets/resources/Frame 65.png +0 -0
  50. package/src/SliceUI/assets/resources/Icon.svg +3 -0
  51. package/src/SliceUI/assets/resources/Icon_Bridging.svg +39 -0
  52. package/src/SliceUI/assets/resources/Icon_Consistent.svg +39 -0
  53. package/src/SliceUI/assets/resources/Icon_Plug.svg +38 -0
  54. package/src/SliceUI/assets/resources/Icon_Reusable.svg +39 -0
  55. package/src/SliceUI/assets/resources/fonts/FontIcon.json +150 -0
  56. package/src/SliceUI/assets/resources/fonts/Lato-Black.ttf +0 -0
  57. package/src/SliceUI/assets/resources/fonts/Lato-Bold.ttf +0 -0
  58. package/src/SliceUI/assets/resources/fonts/Lato-Heavy.ttf +0 -0
  59. package/src/SliceUI/assets/resources/fonts/Lato-Medium.ttf +0 -0
  60. package/src/SliceUI/assets/resources/fonts/Lato-Regular.ttf +0 -0
  61. package/src/SliceUI/assets/resources/fonts/Lato.woff2 +0 -0
  62. package/src/SliceUI/assets/resources/fonts/icomoon.eot +0 -0
  63. package/src/SliceUI/assets/resources/fonts/icomoon.svg +601 -0
  64. package/src/SliceUI/assets/resources/fonts/icomoon.ttf +0 -0
  65. package/src/SliceUI/assets/resources/fonts/icomoon.woff +0 -0
  66. package/src/SliceUI/assets/resources/fonts/selection.json +1 -0
  67. package/src/SliceUI/assets/share.png +0 -0
  68. package/src/SliceUI/assets/styling.png +0 -0
  69. package/src/SliceUI/assets/testing.png +0 -0
  70. package/src/SliceUI/assets/theming.png +0 -0
  71. package/src/SliceUI/assets/tutorials.svg +1 -0
  72. package/src/SliceUI/assets/youtube.svg +1 -0
  73. package/src/SliceUI/automation/helper.ts +29 -0
  74. package/src/SliceUI/avatar/Avatar.tsx +237 -0
  75. package/src/SliceUI/avatar/Token.ts +116 -0
  76. package/src/SliceUI/avatar/Type.ts +36 -0
  77. package/src/SliceUI/avatar/helper.ts +53 -0
  78. package/src/SliceUI/badge/Badge.tsx +308 -0
  79. package/src/SliceUI/badge/Token.ts +202 -0
  80. package/src/SliceUI/badge/Type.ts +46 -0
  81. package/src/SliceUI/badge/helper.ts +39 -0
  82. package/src/SliceUI/button/Button.tsx +243 -0
  83. package/src/SliceUI/button/Token.ts +138 -0
  84. package/src/SliceUI/button/Type.ts +34 -0
  85. package/src/SliceUI/button/helper.ts +125 -0
  86. package/src/SliceUI/checkbox/Checkbox.tsx +176 -0
  87. package/src/SliceUI/checkbox/Token.ts +128 -0
  88. package/src/SliceUI/checkbox/Type.ts +35 -0
  89. package/src/SliceUI/chip/Chip.tsx +290 -0
  90. package/src/SliceUI/chip/Token.ts +151 -0
  91. package/src/SliceUI/chip/Type.ts +43 -0
  92. package/src/SliceUI/chip/helper.ts +40 -0
  93. package/src/SliceUI/colors/Pallete.ts +151 -0
  94. package/src/SliceUI/colors/Token.ts +110 -0
  95. package/src/SliceUI/colors/Type.ts +56 -0
  96. package/src/SliceUI/contextProvider/context.tsx +108 -0
  97. package/src/SliceUI/divider/Divider.tsx +109 -0
  98. package/src/SliceUI/divider/Token.ts +18 -0
  99. package/src/SliceUI/divider/Type.ts +26 -0
  100. package/src/SliceUI/icon/CustomIcon.ts +4 -0
  101. package/src/SliceUI/icon/IcoMoonIcon.tsx +11 -0
  102. package/src/SliceUI/icon/Icon.tsx +38 -0
  103. package/src/SliceUI/icon/Token.ts +14 -0
  104. package/src/SliceUI/icon/Type.ts +13 -0
  105. package/src/SliceUI/icon/selection.json +1 -0
  106. package/src/SliceUI/input/Input.tsx +573 -0
  107. package/src/SliceUI/input/ToDo.md +99 -0
  108. package/src/SliceUI/input/Token.ts +372 -0
  109. package/src/SliceUI/input/Type.ts +109 -0
  110. package/src/SliceUI/input/components/InputPortal.tsx +211 -0
  111. package/src/SliceUI/input/components/NativeBottomSheet.tsx +296 -0
  112. package/src/SliceUI/input/components/SelectChip.tsx +185 -0
  113. package/src/SliceUI/input/components/SelectList.tsx +173 -0
  114. package/src/SliceUI/input/components/SelectListItem.tsx +377 -0
  115. package/src/SliceUI/input/components/SelectScrollbarStyle.ts +44 -0
  116. package/src/SliceUI/input/hooks/useCustomScrollbar.ts +17 -0
  117. package/src/SliceUI/input/hooks/useInputState.ts +41 -0
  118. package/src/SliceUI/input/hooks/useLabelAnimation.ts +132 -0
  119. package/src/SliceUI/input/hooks/useOutsideClick.ts +38 -0
  120. package/src/SliceUI/input/hooks/useSelectLogic.ts +338 -0
  121. package/src/SliceUI/input/utils/inputUtils.ts +120 -0
  122. package/src/SliceUI/input/utils/selectUtils.ts +85 -0
  123. package/src/SliceUI/input/utils/styleUtils.ts +50 -0
  124. package/src/SliceUI/input/variants/CurrencyInput/CurrencyInput.tsx +16 -0
  125. package/src/SliceUI/input/variants/CurrencyInput/NativeCurrencyInput.tsx +181 -0
  126. package/src/SliceUI/input/variants/CurrencyInput/WebCurrencyInput.tsx +163 -0
  127. package/src/SliceUI/input/variants/CurrencyInput/types.ts +17 -0
  128. package/src/SliceUI/input/variants/PhoneInput/NativePhoneInput.tsx +189 -0
  129. package/src/SliceUI/input/variants/PhoneInput/PhoneInput.tsx +16 -0
  130. package/src/SliceUI/input/variants/PhoneInput/WebPhoneInput.tsx +291 -0
  131. package/src/SliceUI/input/variants/PhoneInput/types.ts +22 -0
  132. package/src/SliceUI/input/variants/SelectInput/SelectInput.tsx +407 -0
  133. package/src/SliceUI/input/variants/SelectInput/types.ts +34 -0
  134. package/src/SliceUI/input/variants/TextInput.tsx +68 -0
  135. package/src/SliceUI/layout/Box.tsx +38 -0
  136. package/src/SliceUI/layout/Center.tsx +38 -0
  137. package/src/SliceUI/layout/Divider.tsx +37 -0
  138. package/src/SliceUI/layout/Grid.tsx +75 -0
  139. package/src/SliceUI/layout/PageContainer.tsx +60 -0
  140. package/src/SliceUI/layout/ScrollContainer.tsx +72 -0
  141. package/src/SliceUI/layout/Spacer.tsx +54 -0
  142. package/src/SliceUI/layout/Stack.tsx +97 -0
  143. package/src/SliceUI/layout/StickyHeader.tsx +71 -0
  144. package/src/SliceUI/radio/RadioButton.tsx +130 -0
  145. package/src/SliceUI/radio/Token.ts +197 -0
  146. package/src/SliceUI/radio/Type.ts +35 -0
  147. package/src/SliceUI/react-native.config.js +3 -0
  148. package/src/SliceUI/responsive/Type.ts +7 -0
  149. package/src/SliceUI/responsive/helper.ts +53 -0
  150. package/src/SliceUI/switch/Switch.tsx +119 -0
  151. package/src/SliceUI/switch/Token.ts +205 -0
  152. package/src/SliceUI/switch/Type.ts +26 -0
  153. package/src/SliceUI/tab/TabItem.tsx +204 -0
  154. package/src/SliceUI/tab/Tabs.tsx +110 -0
  155. package/src/SliceUI/tab/Token.ts +282 -0
  156. package/src/SliceUI/tab/Type.ts +66 -0
  157. package/src/SliceUI/tab/helper.ts +53 -0
  158. package/src/SliceUI/table/Table.tsx +388 -0
  159. package/src/SliceUI/table/TableCell.tsx +158 -0
  160. package/src/SliceUI/table/TableFooter.tsx +353 -0
  161. package/src/SliceUI/table/TableHeader.tsx +247 -0
  162. package/src/SliceUI/table/TableRow.tsx +218 -0
  163. package/src/SliceUI/table/Token.ts +252 -0
  164. package/src/SliceUI/table/Type.ts +213 -0
  165. package/src/SliceUI/table/helper.ts +376 -0
  166. package/src/SliceUI/table/index.ts +53 -0
  167. package/src/SliceUI/theme/dummyColors.tsx +7 -0
  168. package/src/SliceUI/theme/theme.ts +107 -0
  169. package/src/SliceUI/typography/BaseTypographyToken.ts +62 -0
  170. package/src/SliceUI/typography/FoundationToken.ts +48 -0
  171. package/src/SliceUI/typography/Token.ts +228 -0
  172. package/src/SliceUI/typography/Type.ts +20 -0
  173. package/src/SliceUI/typography/Typography.tsx +99 -0
  174. package/src/SliceUI/values/BorderRadius.ts +17 -0
  175. package/src/SliceUI/values/BorderWidth.ts +7 -0
  176. package/src/SliceUI/values/Dimension.ts +35 -0
  177. package/src/SliceUI/values/IconSizes.ts +13 -0
  178. package/src/SliceUI/values/Spacing.ts +22 -0
  179. package/src/declarations.d.ts +8 -0
  180. package/src/index.tsx +119 -0
  181. package/src/stories/Colors.mdx +1418 -0
  182. package/src/stories/Dimensions.mdx +60 -0
  183. package/src/stories/GetStarted.mdx +90 -0
  184. package/src/stories/Introduction.mdx +136 -0
  185. package/src/stories/Shape.mdx +126 -0
  186. package/src/stories/Spacing.mdx +104 -0
  187. package/src/stories/Typography.mdx +454 -0
  188. package/src/stories/Utils.mdx +277 -0
  189. package/src/stories/story-components/AddIcon.js +13 -0
  190. package/src/stories/story-components/RectangleWithBox.jsx +51 -0
  191. package/src/stories/story-components/RoundedRectangle.jsx +18 -0
  192. package/src/stories/story-components/RoundedWithWhiteInside.jsx +33 -0
  193. package/src/stories/story-components/WhiteRoundedRectangle.jsx +107 -0
  194. package/src/stories/story-components/svgPaths.js +126 -0
@@ -0,0 +1,243 @@
1
+ import React, {useState, useMemo, useCallback, type ReactNode} from 'react';
2
+ import {
3
+ Pressable,
4
+ StyleSheet,
5
+ Platform,
6
+ type ViewStyle,
7
+ type TextStyle,
8
+ } from 'react-native';
9
+ import {useSliceTheme} from '../contextProvider/context';
10
+ // import {useGetColors} from '../theme/dummyColors';
11
+ import {getBackgroundColor, getBorderColor, getTextColor} from './helper';
12
+ import {resolveVariant, scaleFont} from '../responsive/helper';
13
+ import type {SizeType, VariantsType} from './Type';
14
+ import type {BUTTON_COLOR_TOKENS} from './Token';
15
+ import type {ExtendedTheme} from '../colors/Type';
16
+ import Typography from '../typography/Typography';
17
+
18
+ interface ButtonProps {
19
+ children: string | string[];
20
+ onPress?: () => void;
21
+ overridedTheme?: any;
22
+ variant?: ButtonVariantType;
23
+ size?: string;
24
+ disabled?: boolean;
25
+ rounded?: boolean;
26
+ buttonStyle?: ViewStyle;
27
+ textStyle?: TextStyle;
28
+ showPrefixIcon?: boolean;
29
+ showSuffixIcon?: boolean;
30
+ prefixIcon?: React.ReactNode;
31
+ suffixIcon?: React.ReactNode;
32
+ }
33
+
34
+ export const BUTTON_VARIANTS = {
35
+ PRIMARY: 'primary',
36
+ PRIMARY_OUTLINE: 'primaryOutline',
37
+ OUTLINED: 'outlined',
38
+ GHOST: 'ghost',
39
+ } as const;
40
+
41
+ export type ButtonVariantType =
42
+ (typeof BUTTON_VARIANTS)[keyof typeof BUTTON_VARIANTS];
43
+
44
+ const isWeb = Platform.OS === 'web';
45
+
46
+ const Button: React.FC<ButtonProps> = ({
47
+ children,
48
+ onPress,
49
+ variant = BUTTON_VARIANTS.PRIMARY,
50
+ size = 'medium',
51
+ disabled = false,
52
+ rounded = false,
53
+ showPrefixIcon = false,
54
+ showSuffixIcon = false,
55
+ prefixIcon,
56
+ suffixIcon,
57
+ buttonStyle,
58
+ textStyle,
59
+ }) => {
60
+ const {theme, deviceBreakpoint} = useSliceTheme();
61
+
62
+ const [isHovered, setIsHovered] = useState(false);
63
+
64
+ const responsiveSize = useMemo(
65
+ () => resolveVariant(size, deviceBreakpoint),
66
+ [size, deviceBreakpoint],
67
+ );
68
+
69
+ const buttonTheme = useMemo(() => {
70
+ const buttonType =
71
+ variant === BUTTON_VARIANTS.PRIMARY ? 'solid' : 'outline';
72
+ const styleKey = rounded ? `${buttonType}Rounded` : buttonType;
73
+ const buttonStyles = theme.buttonStyles || {};
74
+ const allowedSizes = ['small', 'medium', 'large', 'xLarge', 'xxLarge'];
75
+ const sizeKey = allowedSizes.includes(responsiveSize)
76
+ ? responsiveSize
77
+ : 'medium';
78
+ return (
79
+ buttonStyles[sizeKey as keyof typeof buttonStyles]?.[
80
+ styleKey as VariantsType
81
+ ] || {}
82
+ );
83
+ }, [variant, responsiveSize, rounded, theme]);
84
+
85
+ const textTheme = useMemo(() => {
86
+ const allowedSizes = ['small', 'medium', 'large', 'xLarge', 'xxLarge'];
87
+ const sizeKey = allowedSizes.includes(responsiveSize)
88
+ ? responsiveSize
89
+ : 'medium';
90
+ return (
91
+ theme.buttonTextStyles[sizeKey as keyof typeof theme.buttonTextStyles] ||
92
+ {}
93
+ );
94
+ }, [responsiveSize, theme]);
95
+
96
+ const defaultBgColor = useMemo(
97
+ () =>
98
+ getBackgroundColor(
99
+ variant as keyof typeof BUTTON_COLOR_TOKENS,
100
+ 'default',
101
+ theme as ExtendedTheme,
102
+ ),
103
+ [variant, theme],
104
+ );
105
+
106
+ const hoverBgColor = useMemo(
107
+ () =>
108
+ getBackgroundColor(
109
+ variant as keyof typeof BUTTON_COLOR_TOKENS,
110
+ 'hover',
111
+ theme as ExtendedTheme,
112
+ ),
113
+ [variant, theme],
114
+ );
115
+
116
+ const pressedBgColor = useMemo(
117
+ () =>
118
+ getBackgroundColor(
119
+ variant as keyof typeof BUTTON_COLOR_TOKENS,
120
+ 'pressed',
121
+ theme as ExtendedTheme,
122
+ ),
123
+ [variant, theme],
124
+ );
125
+
126
+ const borderColor = useMemo(
127
+ () =>
128
+ getBorderColor(
129
+ variant as keyof typeof BUTTON_COLOR_TOKENS,
130
+ theme as ExtendedTheme,
131
+ ),
132
+ [variant, theme],
133
+ );
134
+
135
+ const textColor = useMemo(
136
+ () =>
137
+ getTextColor(
138
+ variant as keyof typeof BUTTON_COLOR_TOKENS,
139
+ theme as ExtendedTheme,
140
+ ),
141
+ [variant, theme],
142
+ );
143
+
144
+ const opacity = useMemo(() => (disabled ? 0.3 : 1), [disabled]);
145
+
146
+ const iconStyleMemo = useMemo(() => {
147
+ const allowedSizes = ['small', 'medium', 'large', 'xLarge', 'xxLarge'];
148
+ const sizeKey = allowedSizes.includes(responsiveSize)
149
+ ? responsiveSize
150
+ : 'medium';
151
+ const iconStyle = theme.buttonIconStyles[sizeKey as SizeType];
152
+
153
+ return {
154
+ size: scaleFont(iconStyle?.size || 16),
155
+ color: textColor,
156
+ };
157
+ }, [responsiveSize, textColor, theme.buttonIconStyles]);
158
+
159
+ const applyIconStyle = useCallback(
160
+ (icon: ReactNode) =>
161
+ icon
162
+ ? React.cloneElement(icon as React.ReactElement, iconStyleMemo)
163
+ : null,
164
+ [iconStyleMemo],
165
+ );
166
+
167
+ const combinedButtonStyle = useMemo(
168
+ () =>
169
+ StyleSheet.flatten([
170
+ styles.baseButton,
171
+ buttonTheme,
172
+ {
173
+ backgroundColor: isHovered ? hoverBgColor : defaultBgColor,
174
+ borderColor,
175
+ opacity,
176
+ },
177
+ buttonStyle,
178
+ ]),
179
+ [
180
+ buttonTheme,
181
+ isHovered,
182
+ hoverBgColor,
183
+ defaultBgColor,
184
+ borderColor,
185
+ opacity,
186
+ buttonStyle,
187
+ ],
188
+ );
189
+
190
+ const pressedButtonStyle = useMemo(
191
+ () =>
192
+ StyleSheet.flatten([
193
+ combinedButtonStyle,
194
+ {backgroundColor: pressedBgColor},
195
+ ]),
196
+ [combinedButtonStyle, pressedBgColor],
197
+ );
198
+
199
+ const combinedTextStyle = useMemo(
200
+ () =>
201
+ StyleSheet.flatten([
202
+ styles.baseText,
203
+ textTheme,
204
+ {fontFamily: Platform.OS === 'web' ? 'Lato' : ''},
205
+ {color: textColor, fontSize: scaleFont(textTheme.fontSize)},
206
+ textStyle,
207
+ ]) as TextStyle,
208
+ [textTheme, textColor, textStyle],
209
+ );
210
+
211
+ return (
212
+ <Pressable
213
+ onPress={onPress}
214
+ disabled={disabled}
215
+ style={({pressed}) =>
216
+ pressed ? pressedButtonStyle : combinedButtonStyle
217
+ }
218
+ {...(isWeb && {
219
+ onMouseEnter: () => setIsHovered(true),
220
+ onMouseLeave: () => setIsHovered(false),
221
+ })}>
222
+ {showPrefixIcon && prefixIcon && applyIconStyle(prefixIcon)}
223
+ <Typography variant="body1Bold" style={combinedTextStyle}>
224
+ {children}
225
+ </Typography>
226
+ {showSuffixIcon && suffixIcon && applyIconStyle(suffixIcon)}
227
+ </Pressable>
228
+ );
229
+ };
230
+
231
+ const styles = StyleSheet.create({
232
+ baseButton: {
233
+ alignItems: 'center',
234
+ justifyContent: 'center',
235
+ flexDirection: 'row',
236
+ minWidth: 150,
237
+ },
238
+ baseText: {
239
+ textAlign: 'center',
240
+ },
241
+ });
242
+
243
+ export default Button;
@@ -0,0 +1,138 @@
1
+ import {spacing} from '../values/Spacing';
2
+ import {borderRadius} from '../values/BorderRadius';
3
+ import type {
4
+ ButtonIconSizeType,
5
+ ButtonSizeType,
6
+ ButtonTextSizeType,
7
+ } from './Type';
8
+ import {TYPOGRAPHY_STYLES} from '../typography/Token';
9
+ import type {TextStyle, ViewStyle} from 'react-native';
10
+ import {ICON_SIZES} from '../icon/Token';
11
+ import type {ExtendedTheme} from '../colors/Type';
12
+
13
+ // Variant styles (shared across sizes)
14
+ const variantStyles = {
15
+ solid: {borderRadius: borderRadius.borderRadius40},
16
+ solidRounded: {borderRadius: borderRadius.borderRadiusFull},
17
+ outline: {borderRadius: borderRadius.borderRadius40, borderWidth: 1},
18
+ outlineRounded: {
19
+ borderRadius: borderRadius.borderRadiusFull,
20
+ borderWidth: 1,
21
+ },
22
+ } as const;
23
+
24
+ // Size-specific padding
25
+ const sizePaddings = {
26
+ small: spacing.space150,
27
+ medium: spacing.space300,
28
+ large: spacing.space400,
29
+ xLarge: spacing.space500,
30
+ xxLarge: spacing.space600,
31
+ } as const;
32
+
33
+ // Helper function to create styles for a given size
34
+ const createStylesForSize = (
35
+ paddingVertical: ViewStyle['paddingVertical'],
36
+ ) => ({
37
+ solid: {...variantStyles.solid, paddingVertical},
38
+ solidRounded: {
39
+ ...variantStyles.solidRounded,
40
+ paddingVertical,
41
+ },
42
+ outline: {
43
+ ...variantStyles.outline,
44
+ paddingVertical,
45
+ },
46
+ outlineRounded: {
47
+ ...variantStyles.outlineRounded,
48
+ paddingVertical,
49
+ },
50
+ });
51
+
52
+ // Export the button styles
53
+ export const BUTTON_STYLE: ButtonSizeType = {
54
+ small: createStylesForSize(sizePaddings.small),
55
+ medium: createStylesForSize(sizePaddings.medium),
56
+ large: createStylesForSize(sizePaddings.large),
57
+ xLarge: createStylesForSize(sizePaddings.xLarge),
58
+ xxLarge: createStylesForSize(sizePaddings.xxLarge),
59
+ };
60
+
61
+ export function textViewWrapperStyle(
62
+ textStyle: TextStyle,
63
+ marginHorizontal: TextStyle['marginHorizontal'] = 0,
64
+ ): TextStyle {
65
+ return {...textStyle, marginHorizontal};
66
+ }
67
+
68
+ export const BUTTON_TXT_STYLE: ButtonTextSizeType = {
69
+ small: textViewWrapperStyle(
70
+ TYPOGRAPHY_STYLES.body2Bold as TextStyle,
71
+ spacing.space100,
72
+ ),
73
+ medium: textViewWrapperStyle(
74
+ TYPOGRAPHY_STYLES.heading3Medium as TextStyle,
75
+ spacing.space100,
76
+ ),
77
+ large: textViewWrapperStyle(
78
+ TYPOGRAPHY_STYLES.heading5Medium as TextStyle,
79
+ spacing.space100,
80
+ ),
81
+ xLarge: textViewWrapperStyle(
82
+ TYPOGRAPHY_STYLES.heading4Medium as TextStyle,
83
+ spacing.space100,
84
+ ),
85
+ xxLarge: textViewWrapperStyle(
86
+ TYPOGRAPHY_STYLES.heading5Bold as TextStyle,
87
+ spacing.space100,
88
+ ),
89
+ };
90
+
91
+ export const BUTTON_ICON_STYLE: ButtonIconSizeType = {
92
+ large: ICON_SIZES.large,
93
+ medium: ICON_SIZES.medium,
94
+ small: ICON_SIZES.small,
95
+ xLarge: ICON_SIZES.xLarge,
96
+ xxLarge: ICON_SIZES.xxLarge,
97
+ };
98
+
99
+ export const ROUNDED_BORDER_RADIUS = borderRadius.borderRadiusFull;
100
+
101
+ export const BUTTON_COLOR_TOKENS = {
102
+ primary: {
103
+ background: {
104
+ default: (theme: ExtendedTheme) => theme.colors.colorBackgroundAccent,
105
+ pressed: (theme: ExtendedTheme) => theme.colors.colorStateAccentPressed1,
106
+ hover: (theme: ExtendedTheme) => theme.colors.colorStateAccentHover1,
107
+ },
108
+ border: () => 'transparent',
109
+ text: (theme: ExtendedTheme) => theme.colors.colorForegroundInvariable,
110
+ },
111
+ primaryOutline: {
112
+ background: {
113
+ default: () => 'transparent',
114
+ pressed: (theme: ExtendedTheme) => theme.colors.colorStateAccentPressed2,
115
+ hover: (theme: ExtendedTheme) => theme.colors.colorStateAccentHover2,
116
+ },
117
+ border: (theme: ExtendedTheme) => theme.colors.colorBorderAccent,
118
+ text: (theme: ExtendedTheme) => theme.colors.colorForegroundAccent,
119
+ },
120
+ outlined: {
121
+ background: {
122
+ default: () => 'transparent',
123
+ pressed: (theme: ExtendedTheme) => theme.colors.colorStatePrimaryPressed,
124
+ hover: (theme: ExtendedTheme) => theme.colors.colorStatePrimaryHover,
125
+ },
126
+ border: (theme: ExtendedTheme) => theme.colors.colorBorderSubtle,
127
+ text: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary,
128
+ },
129
+ ghost: {
130
+ background: {
131
+ default: () => 'transparent',
132
+ pressed: (theme: ExtendedTheme) => theme.colors.colorStatePrimaryPressed,
133
+ hover: (theme: ExtendedTheme) => theme.colors.colorStatePrimaryHover,
134
+ },
135
+ border: () => 'transparent',
136
+ text: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary,
137
+ },
138
+ } as const;
@@ -0,0 +1,34 @@
1
+ // @ts-ignore
2
+ import type {TextStyle, ViewStyle} from 'react-native';
3
+
4
+ export type SizeType = 'small' | 'medium' | 'large' | 'xLarge' | 'xxLarge';
5
+
6
+ export type VariantsType =
7
+ | 'solid'
8
+ | 'outline'
9
+ | 'solidRounded'
10
+ | 'outlineRounded';
11
+
12
+ export type ButtonSizeType = {
13
+ [key in SizeType]: ButtonVariantType;
14
+ };
15
+
16
+ export type ButtonVariantType = {
17
+ [key in VariantsType]: ViewStyle;
18
+ };
19
+
20
+ export type ButtonVariants = {
21
+ [key in SizeType]: TextStyle;
22
+ };
23
+
24
+ export type ButtonTextSizeType = {
25
+ [key in SizeType]: TextStyle;
26
+ };
27
+
28
+ export type ButtonIconSizeType = {
29
+ [key in SizeType]: any;
30
+ };
31
+
32
+ export type ButtonState = 'default' | 'pressed' | 'hover' | 'disabled';
33
+
34
+ export type ButtonVariant = 'primary' | 'primaryOutline' | 'outlined';
@@ -0,0 +1,125 @@
1
+ import type { ExtendedTheme } from '../colors/Type';
2
+ import { BUTTON_COLOR_TOKENS } from './Token';
3
+ import type { ButtonState } from './Type';
4
+
5
+ // export const getBackgroundColor = (
6
+ // buttonType: string,
7
+ // state: string,
8
+ // theme: ExtendedTheme
9
+ // ) => {
10
+ // switch (buttonType) {
11
+ // case 'primary':
12
+ // return getPrimaryBackgroundColor(state, theme);
13
+ // case 'primaryOutline':
14
+ // return getPrimaryOutlineBackgroundColor(state, theme);
15
+ // case 'outlined':
16
+ // return getOutlinedBackgroundColor(state, theme);
17
+ // default:
18
+ // return getPrimaryBackgroundColor(state, theme);
19
+ // }
20
+ // };
21
+ //
22
+ // export const getBorderColor = (
23
+ // buttonType: string,
24
+ // theme: ExtendedTheme
25
+ // ) => {
26
+ // switch (buttonType) {
27
+ // case 'primary':
28
+ // return 'transparent';
29
+ // case 'primaryOutline':
30
+ // return theme.colors.colorAccentPrimary;
31
+ // case 'outlined':
32
+ // return theme.colors.colorBorderSubtle;
33
+ // default:
34
+ // return theme.colors.colorAccentPrimary;
35
+ // }
36
+ // };
37
+ //
38
+ // export const getTextColor = (
39
+ // buttonType: string,
40
+ // theme: ExtendedTheme
41
+ // ) => {
42
+ // switch (buttonType) {
43
+ // case 'primary':
44
+ // return theme.colors.colorContrastWhite;
45
+ // case 'primaryOutline':
46
+ // return theme.colors.colorAccentPrimary;
47
+ // case 'outlined':
48
+ // return theme.colors.colorForegroundSecondary;
49
+ // default:
50
+ // return theme.colors.colorContrastWhite;
51
+ // }
52
+ // };
53
+ //
54
+ // const getPrimaryBackgroundColor = (state: string, theme: ExtendedTheme) => {
55
+ // switch (state) {
56
+ // case 'default':
57
+ // return theme.colors.colorAccentPrimary;
58
+ // case 'pressed':
59
+ // return theme.colors.colorStateAccentCOPressed1;
60
+ // case 'hover':
61
+ // return theme.colors.colorStateAccentCOHover1;
62
+ // default:
63
+ // return theme.colors.colorAccentPrimary;
64
+ // }
65
+ // };
66
+ //
67
+ // const getPrimaryOutlineBackgroundColor = (
68
+ // state: string,
69
+ // theme: ExtendedTheme
70
+ // ) => {
71
+ // switch (state) {
72
+ // case 'default':
73
+ // return 'transparent';
74
+ // case 'pressed':
75
+ // return theme.colors.colorStateAccentCOPressed2;
76
+ // case 'hover':
77
+ // return theme.colors.colorStateAccentCOHover2;
78
+ // default:
79
+ // return theme.colors.colorAccentPrimary;
80
+ // }
81
+ // };
82
+ //
83
+ // const getOutlinedBackgroundColor = (state: string, theme: ExtendedTheme) => {
84
+ // switch (state) {
85
+ // case 'default':
86
+ // return 'transparent';
87
+ // case 'pressed':
88
+ // return theme.colors.colorStatePrimaryPressed;
89
+ // case 'hover':
90
+ // return theme.colors.colorStatePrimaryHover;
91
+ // default:
92
+ // return theme.colors.colorAccentPrimary;
93
+ // }
94
+ // };
95
+
96
+ export const getBackgroundColor = (
97
+ buttonType: keyof typeof BUTTON_COLOR_TOKENS,
98
+ state: ButtonState,
99
+ theme: ExtendedTheme
100
+ ) => {
101
+ const variant =
102
+ BUTTON_COLOR_TOKENS[buttonType] || BUTTON_COLOR_TOKENS.primary;
103
+ const bg =
104
+ variant.background[state as keyof typeof variant.background] ||
105
+ variant.background.default;
106
+ return bg(theme);
107
+ };
108
+
109
+ export const getBorderColor = (
110
+ buttonType: keyof typeof BUTTON_COLOR_TOKENS,
111
+ theme: ExtendedTheme
112
+ ) => {
113
+ const variant =
114
+ BUTTON_COLOR_TOKENS[buttonType] || BUTTON_COLOR_TOKENS.primary;
115
+ return variant.border(theme);
116
+ };
117
+
118
+ export const getTextColor = (
119
+ buttonType: keyof typeof BUTTON_COLOR_TOKENS,
120
+ theme: ExtendedTheme
121
+ ) => {
122
+ const variant =
123
+ BUTTON_COLOR_TOKENS[buttonType] || BUTTON_COLOR_TOKENS.primary;
124
+ return variant.text(theme);
125
+ };
@@ -0,0 +1,176 @@
1
+ import React from 'react';
2
+ import {View, Pressable, StyleSheet} from 'react-native';
3
+ import {useSliceTheme} from '../contextProvider/context';
4
+ import type {ViewStyle, TextStyle} from 'react-native';
5
+ import Typography from '../typography/Typography';
6
+ import IconMoon from '../IconMoon';
7
+ import FONT_ICON from '../assets/resources/fonts/FontIcon.json';
8
+ import {spacing} from '../values/Spacing';
9
+
10
+ export type CheckboxSize = 'medium' | 'large';
11
+
12
+ export interface CheckboxProps {
13
+ checked: boolean;
14
+ onChange: (checked: boolean) => void;
15
+ size?: CheckboxSize;
16
+ disabled?: boolean;
17
+ label?: string;
18
+ supportingText?: string;
19
+ style?: ViewStyle;
20
+ labelStyle?: TextStyle;
21
+ supportingTextStyle?: TextStyle;
22
+ id?: string;
23
+ labelFontSize?: number;
24
+ labelFontWeight?: TextStyle['fontWeight'];
25
+ labelColor?: string;
26
+ supportingTextFontSize?: number;
27
+ supportingTextColor?: string;
28
+ supportingTextMarginTop?: number;
29
+ }
30
+
31
+ const Checkbox: React.FC<CheckboxProps> = ({
32
+ checked = false,
33
+ onChange,
34
+ size = 'medium',
35
+ disabled = false,
36
+ label,
37
+ supportingText,
38
+ style,
39
+ labelStyle,
40
+ supportingTextStyle,
41
+ id,
42
+ labelFontSize,
43
+ labelFontWeight,
44
+ labelColor,
45
+ supportingTextFontSize,
46
+ supportingTextColor,
47
+ supportingTextMarginTop,
48
+ }) => {
49
+ const {theme} = useSliceTheme();
50
+ const {colors, dimensions} = theme;
51
+ const sizes = {
52
+ medium: dimensions.dimension12, // 16
53
+ large: dimensions.dimension16,
54
+ // 24
55
+ };
56
+ const boxSize = sizes[size];
57
+ const borderColor = disabled
58
+ ? colors.colorBorderSubtle
59
+ : checked
60
+ ? colors.colorBorderAccent
61
+ : colors.colorBorderMedium;
62
+ const backgroundColor = disabled
63
+ ? colors.colorForegroundLighter
64
+ : checked
65
+ ? colors.colorBackgroundAccent
66
+ : colors.colorForegroundLighter;
67
+ const boxBorderRadius = boxSize / 4; // perfect square with large but not circular corners
68
+ const checkmarkColor = colors.colorForegroundInvariable;
69
+
70
+ return (
71
+ <Pressable
72
+ onPress={() => !disabled && onChange(!checked)}
73
+ accessibilityRole="checkbox"
74
+ accessibilityState={{checked, disabled}}
75
+ accessibilityLabel={label}
76
+ disabled={disabled}
77
+ style={[styles.row, style]}
78
+ testID={id}>
79
+ <View
80
+ style={[
81
+ styles.box,
82
+ {
83
+ alignItems: 'center',
84
+ justifyContent: 'center',
85
+ },
86
+ ]}>
87
+ <IconMoon
88
+ icon={
89
+ checked ? FONT_ICON.CHECKBOX_CHECKED : FONT_ICON.CHECKBOX_UNCHECKED
90
+ }
91
+ size={boxSize}
92
+ color={
93
+ disabled
94
+ ? colors.colorStateAccentDisabled
95
+ : checked
96
+ ? colors.colorBackgroundAccent
97
+ : backgroundColor
98
+ }
99
+ />
100
+ </View>
101
+
102
+ {label && (
103
+ <View
104
+ style={{
105
+ flex: 1,
106
+ marginLeft: spacing.space100,
107
+ flexDirection: 'column',
108
+ height: boxSize,
109
+ justifyContent: supportingText ? 'flex-start' : 'center',
110
+ }}>
111
+ <Typography
112
+ variant={
113
+ size === 'medium'
114
+ ? checked
115
+ ? 'body1Bold'
116
+ : 'body1Medium'
117
+ : checked
118
+ ? 'heading5Bold'
119
+ : 'heading5Medium'
120
+ }
121
+ style={StyleSheet.flatten([
122
+ {
123
+ color:
124
+ labelColor ||
125
+ (disabled
126
+ ? colors.colorStatePrimaryDisabled
127
+ : colors.colorForegroundPrimary),
128
+ },
129
+ labelStyle,
130
+ ])}>
131
+ {label}
132
+ </Typography>
133
+ {supportingText && (
134
+ <Typography
135
+ variant="body2Regular"
136
+ style={StyleSheet.flatten([
137
+ {
138
+ color: supportingTextColor || colors.colorForegroundSecondary,
139
+ fontSize:
140
+ supportingTextFontSize || theme.dimensions.dimension06, // smaller
141
+ marginTop:
142
+ supportingTextMarginTop || theme.dimensions.dimension01,
143
+ },
144
+ supportingTextStyle,
145
+ ])}>
146
+ {supportingText}
147
+ </Typography>
148
+ )}
149
+ </View>
150
+ )}
151
+ </Pressable>
152
+ );
153
+ };
154
+
155
+ const styles = StyleSheet.create({
156
+ row: {
157
+ flexDirection: 'row',
158
+ alignItems: 'center',
159
+ },
160
+ box: {
161
+ marginRight: spacing.space100,
162
+ },
163
+ labelContainer: {
164
+ flexDirection: 'column',
165
+ justifyContent: 'center',
166
+ },
167
+ label: {
168
+ fontSize: 16,
169
+ fontWeight: '500',
170
+ },
171
+ supportingText: {
172
+ fontSize: 12,
173
+ },
174
+ });
175
+
176
+ export default Checkbox;