@momo-kits/chip 0.0.62-alpha.17
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.js +100 -0
- package/package.json +17 -0
- package/publish.sh +29 -0
package/index.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { StyleSheet, View, Animated } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
Colors,
|
|
5
|
+
Image,
|
|
6
|
+
Radius,
|
|
7
|
+
Spacing,
|
|
8
|
+
Text,
|
|
9
|
+
TouchableOpacity,
|
|
10
|
+
} from '@momo-kits/core-v2';
|
|
11
|
+
import { Easing } from 'react-native-reanimated';
|
|
12
|
+
|
|
13
|
+
const textSize = {
|
|
14
|
+
medium: {
|
|
15
|
+
fontSize: 14,
|
|
16
|
+
lineHeight: 20,
|
|
17
|
+
},
|
|
18
|
+
small: {
|
|
19
|
+
fontSize: 12,
|
|
20
|
+
lineHeight: 16,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const imageSize = {
|
|
25
|
+
medium: {
|
|
26
|
+
width: 20,
|
|
27
|
+
height: 20,
|
|
28
|
+
borderRadius: Radius.XS,
|
|
29
|
+
marginRight: Spacing.XS,
|
|
30
|
+
},
|
|
31
|
+
small: {
|
|
32
|
+
width: 16,
|
|
33
|
+
height: 16,
|
|
34
|
+
borderRadius: Radius.XS,
|
|
35
|
+
marginRight: Spacing.XS,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const Chip = (props) => {
|
|
39
|
+
const { image, icon, title, size, onPress, active, style, onIconPress } =
|
|
40
|
+
props;
|
|
41
|
+
|
|
42
|
+
const mapTextSize = textSize[size] || textSize.medium;
|
|
43
|
+
const mapImageSize = imageSize[size] || imageSize.medium;
|
|
44
|
+
|
|
45
|
+
const selectedStyle = {
|
|
46
|
+
backgroundColor: Colors.pink_10,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<TouchableOpacity
|
|
51
|
+
style={[{ alignSelf: 'baseline' }, style]}
|
|
52
|
+
onPress={() => onPress?.(!active)}>
|
|
53
|
+
<View style={[styles.container, active && selectedStyle]}>
|
|
54
|
+
{image && <Image source={image} style={[mapImageSize]} />}
|
|
55
|
+
<Text.Label2 style={[mapTextSize]}>{title}</Text.Label2>
|
|
56
|
+
{icon && (
|
|
57
|
+
<TouchableOpacity
|
|
58
|
+
onPress={onIconPress}
|
|
59
|
+
disabled={!onIconPress}
|
|
60
|
+
style={styles.iconContainer}>
|
|
61
|
+
<Image source={icon} style={styles.icon} />
|
|
62
|
+
</TouchableOpacity>
|
|
63
|
+
)}
|
|
64
|
+
</View>
|
|
65
|
+
{active && <View style={styles.background} />}
|
|
66
|
+
</TouchableOpacity>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const styles = StyleSheet.create({
|
|
71
|
+
container: {
|
|
72
|
+
borderRadius: Radius.L,
|
|
73
|
+
flexDirection: 'row',
|
|
74
|
+
paddingVertical: Spacing.XXS + Spacing.XS,
|
|
75
|
+
paddingHorizontal: Spacing.S,
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
backgroundColor: Colors.black_04,
|
|
79
|
+
},
|
|
80
|
+
icon: {
|
|
81
|
+
width: 16,
|
|
82
|
+
height: 16,
|
|
83
|
+
tintColor: Colors.black_17,
|
|
84
|
+
},
|
|
85
|
+
background: {
|
|
86
|
+
position: 'absolute',
|
|
87
|
+
top: 0,
|
|
88
|
+
right: 0,
|
|
89
|
+
bottom: 0,
|
|
90
|
+
left: 0,
|
|
91
|
+
borderRadius: Radius.L,
|
|
92
|
+
borderWidth: 2,
|
|
93
|
+
borderColor: Colors.pink_03,
|
|
94
|
+
},
|
|
95
|
+
iconContainer: {
|
|
96
|
+
marginLeft: Spacing.XS,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export default Chip;
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@momo-kits/chip",
|
|
3
|
+
"version": "0.0.62-alpha.17",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"prop-types": "^15.7.2",
|
|
8
|
+
"react": "16.9.0"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"react": "16.9.0",
|
|
12
|
+
"react-native": ">=0.55",
|
|
13
|
+
"@momo-kits/core-v2": ">=0.0.4-beta"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {},
|
|
16
|
+
"license": "MoMo"
|
|
17
|
+
}
|
package/publish.sh
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
rm -rf dist
|
|
3
|
+
mkdir dist
|
|
4
|
+
|
|
5
|
+
cp . ./dist
|
|
6
|
+
|
|
7
|
+
# GET VERSION from mck_package.json
|
|
8
|
+
VERSIONSTRING=( v$(jq .version package.json) )
|
|
9
|
+
VERSION=(${VERSIONSTRING//[\"]/})
|
|
10
|
+
echo VERSION: $VERSION
|
|
11
|
+
|
|
12
|
+
rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
|
|
13
|
+
|
|
14
|
+
# #babel component to dist
|
|
15
|
+
#babel ./dist -d dist --copy-files
|
|
16
|
+
|
|
17
|
+
#copy option
|
|
18
|
+
#cp -r ./src/ dist
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
#npm login
|
|
22
|
+
#publish dist to npm
|
|
23
|
+
cd dist
|
|
24
|
+
npm publish --tag beta --access=public
|
|
25
|
+
cd ..
|
|
26
|
+
rm -rf dist
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/chip new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/chip"}'
|