cpk-ui 0.1.13 → 0.1.14
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/README.md
CHANGED
|
@@ -28,7 +28,7 @@ Check out [ui.crossplatformkorea.com](https://ui.crossplatformkorea.com)
|
|
|
28
28
|
#### For Expo
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
|
-
expo install cpk-ui @emotion/react @emotion/native @expo/vector-icons react-native-gesture-handler react-native-svg expo-screen-orientation @expo/match-media
|
|
31
|
+
expo install cpk-ui @emotion/react @emotion/native @expo/vector-icons react-native-gesture-handler react-native-svg expo-screen-orientation @expo/match-media expo-haptics
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
#### For React Native CLI
|
|
@@ -7,6 +7,7 @@ import { useTheme } from '../../../providers/ThemeProvider';
|
|
|
7
7
|
import { cloneElemWithDefaultColors } from '../../../utils/guards';
|
|
8
8
|
import { LoadingIndicator } from '../LoadingIndicator/LoadingIndicator';
|
|
9
9
|
import { Typography } from '../Typography/Typography';
|
|
10
|
+
import Haptics from 'expo-haptics';
|
|
10
11
|
const ButtonContainer = styled.View `
|
|
11
12
|
align-self: stretch;
|
|
12
13
|
flex-direction: row;
|
|
@@ -98,7 +99,7 @@ const useButtonState = ({ disabled, onPress, loading, }) => {
|
|
|
98
99
|
isLoading: loading,
|
|
99
100
|
};
|
|
100
101
|
};
|
|
101
|
-
export function Button({ testID, type = 'solid', color = 'primary', size = 'medium', disabled, loading = false, loadingElement, text, startElement, endElement, style, styles, onPress, activeOpacity = 0.8, touchableHighlightProps, borderRadius = 4, loadingColor, hitSlop = { top: 8, bottom: 8, left: 8, right: 8 }, }) {
|
|
102
|
+
export function Button({ testID, type = 'solid', color = 'primary', size = 'medium', disabled, loading = false, loadingElement, text, startElement, endElement, style, styles, onPress, activeOpacity = 0.8, touchableHighlightProps, borderRadius = 4, loadingColor, hitSlop = { top: 8, bottom: 8, left: 8, right: 8 }, hapticFeedback, }) {
|
|
102
103
|
const ref = useRef(null);
|
|
103
104
|
const hovered = useHover(ref);
|
|
104
105
|
const { theme } = useTheme();
|
|
@@ -156,7 +157,12 @@ export function Button({ testID, type = 'solid', color = 'primary', size = 'medi
|
|
|
156
157
|
backgroundColor: viewStyle?.backgroundColor,
|
|
157
158
|
color: textStyle?.color,
|
|
158
159
|
})] }));
|
|
159
|
-
return (_jsx(TouchableHighlight, { activeOpacity: activeOpacity, delayPressIn: 30, disabled: innerDisabled || loading || !onPress, hitSlop: hitSlop, onPress:
|
|
160
|
+
return (_jsx(TouchableHighlight, { activeOpacity: activeOpacity, delayPressIn: 30, disabled: innerDisabled || loading || !onPress, hitSlop: hitSlop, onPress: (e) => {
|
|
161
|
+
onPress?.(e);
|
|
162
|
+
if (hapticFeedback) {
|
|
163
|
+
Haptics.impactAsync(hapticFeedback);
|
|
164
|
+
}
|
|
165
|
+
}, ref: Platform.select({
|
|
160
166
|
web: ref,
|
|
161
167
|
default: undefined,
|
|
162
168
|
}), style: [
|
|
@@ -15,6 +15,7 @@ import {cloneElemWithDefaultColors} from '../../../utils/guards';
|
|
|
15
15
|
import type {CpkTheme} from '../../../utils/theme';
|
|
16
16
|
import {LoadingIndicator} from '../LoadingIndicator/LoadingIndicator';
|
|
17
17
|
import {Typography} from '../Typography/Typography';
|
|
18
|
+
import Haptics from 'expo-haptics';
|
|
18
19
|
|
|
19
20
|
export type ButtonType = 'text' | 'solid' | 'outlined';
|
|
20
21
|
export type ButtonColorType =
|
|
@@ -49,6 +50,7 @@ export type Props = {
|
|
|
49
50
|
'onPress' | 'activeOpacity' | 'style'
|
|
50
51
|
>;
|
|
51
52
|
hitSlop?: null | Insets | number | undefined;
|
|
53
|
+
hapticFeedback?: Haptics.ImpactFeedbackStyle;
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
type Styles = {
|
|
@@ -215,6 +217,7 @@ export function Button({
|
|
|
215
217
|
borderRadius = 4,
|
|
216
218
|
loadingColor,
|
|
217
219
|
hitSlop = {top: 8, bottom: 8, left: 8, right: 8},
|
|
220
|
+
hapticFeedback,
|
|
218
221
|
}: Props): JSX.Element {
|
|
219
222
|
const ref = useRef<React.ElementRef<typeof TouchableHighlight>>(null);
|
|
220
223
|
const hovered = useHover(ref);
|
|
@@ -323,7 +326,13 @@ export function Button({
|
|
|
323
326
|
delayPressIn={30}
|
|
324
327
|
disabled={innerDisabled || loading || !onPress}
|
|
325
328
|
hitSlop={hitSlop}
|
|
326
|
-
onPress={
|
|
329
|
+
onPress={(e) => {
|
|
330
|
+
onPress?.(e);
|
|
331
|
+
|
|
332
|
+
if (hapticFeedback) {
|
|
333
|
+
Haptics.impactAsync(hapticFeedback);
|
|
334
|
+
}
|
|
335
|
+
}}
|
|
327
336
|
ref={Platform.select({
|
|
328
337
|
web: ref,
|
|
329
338
|
default: undefined,
|
|
@@ -7,6 +7,7 @@ import { Icon } from '../Icon/Icon';
|
|
|
7
7
|
import { LoadingIndicator } from '../LoadingIndicator/LoadingIndicator';
|
|
8
8
|
import { getTheme } from '../../../utils/theme';
|
|
9
9
|
import { useTheme } from '../../../providers/ThemeProvider';
|
|
10
|
+
import Haptics from 'expo-haptics';
|
|
10
11
|
export const ButtonStyles = ({ theme, type = 'solid', color = 'primary', loading, disabled, }) => {
|
|
11
12
|
theme = getTheme(theme);
|
|
12
13
|
let backgroundColor = theme.button[color].bg;
|
|
@@ -33,7 +34,7 @@ export const ButtonStyles = ({ theme, type = 'solid', color = 'primary', loading
|
|
|
33
34
|
disabledTextColor: theme.button.disabled.text,
|
|
34
35
|
};
|
|
35
36
|
};
|
|
36
|
-
export function IconButton({ testID, type = 'solid', color = 'primary', size = 'medium', disabled, loading = false, loadingElement, icon, iconElement, style, styles, onPress, activeOpacity = 0.95, touchableHighlightProps, }) {
|
|
37
|
+
export function IconButton({ testID, type = 'solid', color = 'primary', size = 'medium', disabled, loading = false, loadingElement, icon, iconElement, style, styles, onPress, activeOpacity = 0.95, touchableHighlightProps, hapticFeedback, }) {
|
|
37
38
|
const ref = useRef(null);
|
|
38
39
|
const hovered = useHover(ref);
|
|
39
40
|
const { theme } = useTheme();
|
|
@@ -92,7 +93,12 @@ export function IconButton({ testID, type = 'solid', color = 'primary', size = '
|
|
|
92
93
|
border-radius: ${borderRadiusStr};
|
|
93
94
|
`,
|
|
94
95
|
style,
|
|
95
|
-
], children: _jsx(TouchableHighlight, { activeOpacity: activeOpacity, delayPressIn: 50, disabled: disabled || loading, onPress:
|
|
96
|
+
], children: _jsx(TouchableHighlight, { activeOpacity: activeOpacity, delayPressIn: 50, disabled: disabled || loading, onPress: (e) => {
|
|
97
|
+
onPress?.(e);
|
|
98
|
+
if (hapticFeedback) {
|
|
99
|
+
Haptics.impactAsync(hapticFeedback);
|
|
100
|
+
}
|
|
101
|
+
}, ref: Platform.select({
|
|
96
102
|
web: ref,
|
|
97
103
|
default: undefined,
|
|
98
104
|
}), style: css `
|
|
@@ -9,6 +9,7 @@ import {Icon} from '../Icon/Icon';
|
|
|
9
9
|
import {LoadingIndicator} from '../LoadingIndicator/LoadingIndicator';
|
|
10
10
|
import {CpkTheme, getTheme} from '../../../utils/theme';
|
|
11
11
|
import {useTheme} from '../../../providers/ThemeProvider';
|
|
12
|
+
import Haptics from 'expo-haptics';
|
|
12
13
|
|
|
13
14
|
type Styles = {
|
|
14
15
|
container?: StyleProp<ViewStyle>;
|
|
@@ -99,6 +100,7 @@ export type IconButtonProps = {
|
|
|
99
100
|
onPress?: TouchableHighlightProps['onPress'];
|
|
100
101
|
activeOpacity?: number;
|
|
101
102
|
touchableHighlightProps?: Omit<TouchableHighlightProps, 'onPress' | 'style'>;
|
|
103
|
+
hapticFeedback?: Haptics.ImpactFeedbackStyle;
|
|
102
104
|
};
|
|
103
105
|
|
|
104
106
|
export function IconButton({
|
|
@@ -116,6 +118,7 @@ export function IconButton({
|
|
|
116
118
|
onPress,
|
|
117
119
|
activeOpacity = 0.95,
|
|
118
120
|
touchableHighlightProps,
|
|
121
|
+
hapticFeedback,
|
|
119
122
|
}: IconButtonProps): JSX.Element {
|
|
120
123
|
const ref = useRef<React.ElementRef<typeof TouchableHighlight>>(null);
|
|
121
124
|
const hovered = useHover(ref);
|
|
@@ -196,7 +199,13 @@ export function IconButton({
|
|
|
196
199
|
activeOpacity={activeOpacity}
|
|
197
200
|
delayPressIn={50}
|
|
198
201
|
disabled={disabled || loading}
|
|
199
|
-
onPress={
|
|
202
|
+
onPress={(e) => {
|
|
203
|
+
onPress?.(e);
|
|
204
|
+
|
|
205
|
+
if (hapticFeedback) {
|
|
206
|
+
Haptics.impactAsync(hapticFeedback);
|
|
207
|
+
}
|
|
208
|
+
}}
|
|
200
209
|
ref={Platform.select({
|
|
201
210
|
web: ref,
|
|
202
211
|
default: undefined,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cpk-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"main": "index",
|
|
5
5
|
"react-native": "index",
|
|
6
6
|
"module": "index",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"react": ">=16.9",
|
|
23
23
|
"react-native": ">=0.58",
|
|
24
24
|
"react-native-gesture-handler": "*",
|
|
25
|
-
"@expo/vector-icons": "*"
|
|
25
|
+
"@expo/vector-icons": "*",
|
|
26
|
+
"expo-haptics": "*"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"hyochan-welcome": "^1.0.1",
|