@momo-kits/chip 0.153.2-beta.2 → 0.154.1-beta.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.
- package/index.tsx +47 -13
- package/package.json +1 -1
- package/styles.ts +3 -24
package/index.tsx
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import React, {FC, useContext, useMemo} from 'react';
|
|
1
|
+
import React, { FC, useContext, useMemo } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ApplicationContext,
|
|
4
4
|
Colors,
|
|
5
5
|
Icon,
|
|
6
6
|
MiniAppContext,
|
|
7
|
+
Radius,
|
|
7
8
|
ScreenContext,
|
|
8
9
|
Spacing,
|
|
9
10
|
Text,
|
|
10
11
|
Typography,
|
|
12
|
+
useScaleSize,
|
|
11
13
|
} from '@momo-kits/foundation';
|
|
12
|
-
import {TouchableOpacity, View} from 'react-native';
|
|
14
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
13
15
|
import styles from './styles';
|
|
14
|
-
import {ChipProps} from './types';
|
|
16
|
+
import { ChipProps } from './types';
|
|
15
17
|
|
|
16
18
|
const Chip: FC<ChipProps> = ({
|
|
17
19
|
label = 'Label',
|
|
@@ -28,7 +30,13 @@ const Chip: FC<ChipProps> = ({
|
|
|
28
30
|
accessibilityLabel,
|
|
29
31
|
accessibilityState,
|
|
30
32
|
}) => {
|
|
31
|
-
const {theme} = useContext(ApplicationContext);
|
|
33
|
+
const { theme } = useContext(ApplicationContext);
|
|
34
|
+
const scaledRadiusL = useScaleSize(Radius.L);
|
|
35
|
+
const scaledPaddingH = useScaleSize(Spacing.S);
|
|
36
|
+
const scaledHeight32 = useScaleSize(32);
|
|
37
|
+
const scaledHeight24 = useScaleSize(24);
|
|
38
|
+
const scaledSize16 = useScaleSize(16);
|
|
39
|
+
const scaledMargin = useScaleSize(Spacing.XS);
|
|
32
40
|
|
|
33
41
|
const app = useContext<any>(MiniAppContext);
|
|
34
42
|
const screen = useContext<any>(ScreenContext);
|
|
@@ -55,10 +63,24 @@ const Chip: FC<ChipProps> = ({
|
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
let typo: Typography = 'label_default_medium';
|
|
58
|
-
let chipStyle =
|
|
66
|
+
let chipStyle = [
|
|
67
|
+
styles.chip,
|
|
68
|
+
{
|
|
69
|
+
borderRadius: scaledRadiusL,
|
|
70
|
+
paddingHorizontal: scaledPaddingH,
|
|
71
|
+
height: scaledHeight32,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
59
74
|
let iconSize = 20;
|
|
60
75
|
if (size === 'small') {
|
|
61
|
-
chipStyle =
|
|
76
|
+
chipStyle = [
|
|
77
|
+
styles.chip,
|
|
78
|
+
{
|
|
79
|
+
borderRadius: scaledRadiusL,
|
|
80
|
+
paddingHorizontal: scaledPaddingH,
|
|
81
|
+
height: scaledHeight24,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
62
84
|
iconSize = 16;
|
|
63
85
|
typo = 'label_s_medium';
|
|
64
86
|
}
|
|
@@ -68,6 +90,7 @@ const Chip: FC<ChipProps> = ({
|
|
|
68
90
|
<View
|
|
69
91
|
style={[
|
|
70
92
|
styles.chipOverlay,
|
|
93
|
+
{ borderRadius: scaledRadiusL },
|
|
71
94
|
{
|
|
72
95
|
borderColor: theme.colors.secondary,
|
|
73
96
|
},
|
|
@@ -86,17 +109,22 @@ const Chip: FC<ChipProps> = ({
|
|
|
86
109
|
{
|
|
87
110
|
backgroundColor: bgColor,
|
|
88
111
|
maxWidth: '100%',
|
|
89
|
-
flexShrink: 1
|
|
112
|
+
flexShrink: 1,
|
|
90
113
|
},
|
|
91
114
|
]}
|
|
92
115
|
accessibilityLabel={componentId + '|touch'}
|
|
93
|
-
accessibilityState={{checked: selected, ...accessibilityState}}
|
|
116
|
+
accessibilityState={{ checked: selected, ...accessibilityState }}
|
|
117
|
+
>
|
|
94
118
|
{!!iconLeft && (
|
|
95
119
|
<Icon
|
|
96
120
|
source={iconLeft}
|
|
97
121
|
color={iconLeftColorSelected}
|
|
98
122
|
size={iconSize}
|
|
99
|
-
style={{
|
|
123
|
+
style={{
|
|
124
|
+
width: scaledSize16,
|
|
125
|
+
height: scaledSize16,
|
|
126
|
+
marginRight: label ? Spacing.XS : scaledMargin,
|
|
127
|
+
}}
|
|
100
128
|
/>
|
|
101
129
|
)}
|
|
102
130
|
{label && (
|
|
@@ -107,7 +135,8 @@ const Chip: FC<ChipProps> = ({
|
|
|
107
135
|
style={{
|
|
108
136
|
flexShrink: 1,
|
|
109
137
|
}}
|
|
110
|
-
accessibilityLabel={componentId + '|text'}
|
|
138
|
+
accessibilityLabel={componentId + '|text'}
|
|
139
|
+
>
|
|
111
140
|
{label}
|
|
112
141
|
</Text>
|
|
113
142
|
)}
|
|
@@ -116,7 +145,12 @@ const Chip: FC<ChipProps> = ({
|
|
|
116
145
|
source={iconRight}
|
|
117
146
|
color={iconRightColorSelected}
|
|
118
147
|
size={iconSize}
|
|
119
|
-
style={
|
|
148
|
+
style={[
|
|
149
|
+
styles.icon,
|
|
150
|
+
{
|
|
151
|
+
marginLeft: scaledMargin,
|
|
152
|
+
},
|
|
153
|
+
]}
|
|
120
154
|
accessibilityLabel={componentId + '|icon'}
|
|
121
155
|
/>
|
|
122
156
|
)}
|
|
@@ -126,5 +160,5 @@ const Chip: FC<ChipProps> = ({
|
|
|
126
160
|
);
|
|
127
161
|
};
|
|
128
162
|
|
|
129
|
-
export {Chip};
|
|
130
|
-
export type {ChipProps};
|
|
163
|
+
export { Chip };
|
|
164
|
+
export type { ChipProps };
|
package/package.json
CHANGED
package/styles.ts
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
import {StyleSheet} from 'react-native';
|
|
2
|
-
import {Radius, scaleSize, Spacing} from '@momo-kits/foundation';
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
3
2
|
|
|
4
3
|
export default StyleSheet.create({
|
|
4
|
+
wrapper: { flexDirection: 'row' },
|
|
5
5
|
chip: {
|
|
6
|
-
borderRadius: scaleSize(Radius.L),
|
|
7
|
-
paddingHorizontal: scaleSize(Spacing.S),
|
|
8
|
-
height: scaleSize(32),
|
|
9
6
|
justifyContent: 'center',
|
|
10
7
|
alignItems: 'center',
|
|
11
8
|
flexDirection: 'row',
|
|
12
9
|
},
|
|
13
|
-
smallChip: {
|
|
14
|
-
borderRadius: scaleSize(Radius.L),
|
|
15
|
-
paddingHorizontal: scaleSize(Spacing.S),
|
|
16
|
-
height: scaleSize(24),
|
|
17
|
-
justifyContent: 'center',
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
flexDirection: 'row',
|
|
20
|
-
},
|
|
21
|
-
|
|
22
10
|
chipOverlay: {
|
|
23
11
|
position: 'absolute',
|
|
24
12
|
top: 0,
|
|
@@ -27,15 +15,6 @@ export default StyleSheet.create({
|
|
|
27
15
|
right: 0,
|
|
28
16
|
zIndex: -1,
|
|
29
17
|
borderWidth: 2,
|
|
30
|
-
borderRadius: scaleSize(Radius.L),
|
|
31
|
-
},
|
|
32
|
-
imageSmall: {
|
|
33
|
-
width: scaleSize(16),
|
|
34
|
-
height: scaleSize(16),
|
|
35
|
-
marginRight: scaleSize(Spacing.XS),
|
|
36
|
-
},
|
|
37
|
-
icon: {
|
|
38
|
-
marginLeft: scaleSize(Spacing.XS),
|
|
39
18
|
},
|
|
40
|
-
|
|
19
|
+
icon: {},
|
|
41
20
|
});
|