cpk-ui 0.0.1

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 (69) hide show
  1. package/README.md +27 -0
  2. package/components/modals/AlertDialog/AlertDialog.js +80 -0
  3. package/components/modals/AlertDialog/AlertDialog.stories.tsx +80 -0
  4. package/components/modals/AlertDialog/AlertDialog.tsx +194 -0
  5. package/components/modals/Snackbar/Snackbar.js +94 -0
  6. package/components/modals/Snackbar/Snackbar.stories.tsx +98 -0
  7. package/components/modals/Snackbar/Snackbar.tsx +174 -0
  8. package/components/modals/Snackbar/const.js +5 -0
  9. package/components/modals/Snackbar/const.ts +4 -0
  10. package/components/uis/Accordion/Accordion.js +11 -0
  11. package/components/uis/Accordion/Accordion.stories.tsx +38 -0
  12. package/components/uis/Accordion/Accordion.test.tsx +128 -0
  13. package/components/uis/Accordion/Accordion.tsx +58 -0
  14. package/components/uis/Accordion/AccordionItem.js +102 -0
  15. package/components/uis/Accordion/AccordionItem.tsx +213 -0
  16. package/components/uis/Button/Button.js +161 -0
  17. package/components/uis/Button/Button.stories.tsx +81 -0
  18. package/components/uis/Button/Button.test.tsx +560 -0
  19. package/components/uis/Button/Button.tsx +335 -0
  20. package/components/uis/Checkbox/Checkbox.js +70 -0
  21. package/components/uis/Checkbox/Checkbox.stories.tsx +46 -0
  22. package/components/uis/Checkbox/Checkbox.test.tsx +139 -0
  23. package/components/uis/Checkbox/Checkbox.tsx +150 -0
  24. package/components/uis/Icon/Icon.js +3780 -0
  25. package/components/uis/Icon/Icon.stories.tsx +45 -0
  26. package/components/uis/Icon/Icon.test.tsx +19 -0
  27. package/components/uis/Icon/Icon.tsx +3800 -0
  28. package/components/uis/Icon/Pretendard-Bold.otf +0 -0
  29. package/components/uis/Icon/Pretendard-Regular.otf +0 -0
  30. package/components/uis/Icon/Pretendard-Thin.otf +0 -0
  31. package/components/uis/Icon/cpk.ttf +0 -0
  32. package/components/uis/Icon/selection.json +1 -0
  33. package/components/uis/IconButton/IconButton.js +120 -0
  34. package/components/uis/IconButton/IconButton.test.tsx +165 -0
  35. package/components/uis/IconButton/IconButton.tsx +252 -0
  36. package/components/uis/LoadingIndicator/LoadingIndicator.js +24 -0
  37. package/components/uis/LoadingIndicator/LoadingIndicator.tsx +79 -0
  38. package/components/uis/Rating/Rating.js +53 -0
  39. package/components/uis/Rating/Rating.test.tsx +72 -0
  40. package/components/uis/Rating/Rating.tsx +155 -0
  41. package/components/uis/StatusbarBrightness/StatusBarBrightness.js +13 -0
  42. package/components/uis/StatusbarBrightness/StatusBarBrightness.test.tsx +41 -0
  43. package/components/uis/StatusbarBrightness/StatusBarBrightness.tsx +17 -0
  44. package/components/uis/Styled/StyledComponents.js +130 -0
  45. package/components/uis/Styled/StyledComponents.tsx +200 -0
  46. package/components/uis/SwitchToggle/SwitchToggle.js +126 -0
  47. package/components/uis/SwitchToggle/SwitchToggle.test.tsx +70 -0
  48. package/components/uis/SwitchToggle/SwitchToggle.tsx +224 -0
  49. package/components/uis/Typography/Typography.js +90 -0
  50. package/components/uis/Typography/Typography.test.tsx +58 -0
  51. package/components/uis/Typography/Typography.tsx +132 -0
  52. package/hooks/useDebouncedColorScheme.js +21 -0
  53. package/hooks/useDebouncedColorScheme.tsx +30 -0
  54. package/index.js +16 -0
  55. package/index.tsx +18 -0
  56. package/package.json +35 -0
  57. package/providers/ThemeProvider.js +106 -0
  58. package/providers/ThemeProvider.tsx +180 -0
  59. package/providers/index.js +62 -0
  60. package/providers/index.tsx +125 -0
  61. package/react-native.config.cjs +5 -0
  62. package/utils/colors.js +124 -0
  63. package/utils/colors.ts +127 -0
  64. package/utils/createCtx.js +15 -0
  65. package/utils/createCtx.tsx +26 -0
  66. package/utils/guards.js +44 -0
  67. package/utils/guards.ts +93 -0
  68. package/utils/theme.js +5 -0
  69. package/utils/theme.ts +33 -0
@@ -0,0 +1,150 @@
1
+ import React, {useEffect, useRef} from 'react';
2
+ import type {StyleProp, ViewStyle} from 'react-native';
3
+ import {Animated, Platform, View} from 'react-native';
4
+ import styled, {css} from '@emotion/native';
5
+
6
+ import {Icon} from '../Icon/Icon';
7
+ import {
8
+ CheckboxWrapper,
9
+ CheckboxWrapperOutlined,
10
+ } from '../Styled/StyledComponents';
11
+ import {useTheme} from '../../../providers/ThemeProvider';
12
+
13
+ type Styles = {
14
+ container?: StyleProp<ViewStyle>;
15
+ checkbox?: StyleProp<ViewStyle>;
16
+ check?: ViewStyle;
17
+ };
18
+
19
+ export type CheckboxColor =
20
+ | 'primary'
21
+ | 'secondary'
22
+ | 'success'
23
+ | 'danger'
24
+ | 'warning'
25
+ | 'info';
26
+
27
+ export interface CheckboxProps {
28
+ onPress?: () => void;
29
+ style?: StyleProp<ViewStyle>;
30
+ styles?: Styles;
31
+ color?: CheckboxColor;
32
+ disabled?: boolean;
33
+ checked?: boolean;
34
+ endElement?: JSX.Element;
35
+ startElement?: JSX.Element;
36
+ }
37
+
38
+ const Container = styled.TouchableOpacity`
39
+ flex-direction: row;
40
+ align-items: center;
41
+ `;
42
+
43
+ const StyledCheckboxOutlined = styled(CheckboxWrapperOutlined)`
44
+ width: 20px;
45
+ height: 20px;
46
+ border-width: 1px;
47
+ margin: 0 6px;
48
+
49
+ justify-content: center;
50
+ align-items: center;
51
+ `;
52
+
53
+ const StyledCheckbox = styled(CheckboxWrapper)`
54
+ width: 20px;
55
+ height: 20px;
56
+ margin: 0 6px;
57
+
58
+ justify-content: center;
59
+ align-items: center;
60
+ `;
61
+
62
+ const StyledCheck = styled(Icon)<{checked?: boolean}>`
63
+ font-weight: bold;
64
+ color: ${({theme, checked}) => (checked ? theme.bg.basic : 'transparent')};
65
+ `;
66
+
67
+ export function Checkbox({
68
+ style,
69
+ styles,
70
+ endElement,
71
+ startElement,
72
+ color = 'primary',
73
+ disabled = false,
74
+ checked = false,
75
+ onPress,
76
+ }: CheckboxProps): JSX.Element {
77
+ const animatedValue = new Animated.Value(0);
78
+ const fadeAnim = useRef(animatedValue).current;
79
+ const scaleAnim = useRef(animatedValue).current;
80
+ const {theme} = useTheme();
81
+
82
+ useEffect(() => {
83
+ Animated.sequence([
84
+ Animated.spring(fadeAnim, {
85
+ toValue: !checked ? 0 : 1,
86
+ useNativeDriver: Platform.select({
87
+ web: false,
88
+ default: true,
89
+ }),
90
+ }),
91
+ Animated.spring(scaleAnim, {
92
+ toValue: !checked ? 0 : 1,
93
+ useNativeDriver: Platform.select({
94
+ web: false,
95
+ default: true,
96
+ }),
97
+ }),
98
+ ]).start();
99
+ }, [fadeAnim, scaleAnim, checked]);
100
+
101
+ return (
102
+ <Container
103
+ activeOpacity={0.9}
104
+ disabled={disabled}
105
+ onPress={onPress}
106
+ style={style}
107
+ >
108
+ <View
109
+ style={[
110
+ css`
111
+ flex: 1;
112
+ padding: 6px 0;
113
+
114
+ flex-direction: row;
115
+ column-gap: 2px;
116
+ align-items: center;
117
+ `,
118
+ styles?.container,
119
+ ]}
120
+ >
121
+ {startElement}
122
+ <StyledCheckboxOutlined
123
+ checked={checked}
124
+ disabled={disabled}
125
+ style={styles?.checkbox}
126
+ testID="cpk-ui-checkbox"
127
+ type={color}
128
+ >
129
+ <StyledCheckbox
130
+ checked={checked}
131
+ disabled={disabled}
132
+ style={[
133
+ styles?.checkbox,
134
+ {opacity: fadeAnim, transform: [{scale: scaleAnim}]},
135
+ ]}
136
+ type={color}
137
+ >
138
+ <StyledCheck
139
+ checked={checked}
140
+ name="Check"
141
+ style={styles?.check}
142
+ theme={theme}
143
+ />
144
+ </StyledCheckbox>
145
+ </StyledCheckboxOutlined>
146
+ {endElement}
147
+ </View>
148
+ </Container>
149
+ );
150
+ }