@momo-kits/badge 0.0.46-beta.52

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 (3) hide show
  1. package/index.js +75 -0
  2. package/package.json +16 -0
  3. package/publish.sh +29 -0
package/index.js ADDED
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import { Colors, Spacing, Text, Radius } from '@momo-kits/core';
4
+
5
+ const Badge = ({ type, value, style, textStyle, containerWidth }) => {
6
+ const getStyle = (type) => {
7
+ switch (type) {
8
+ case 'badge':
9
+ return [
10
+ styles.container,
11
+ {
12
+ minWidth: 16,
13
+ height: 16,
14
+ left: containerWidth ? containerWidth - 12 : null,
15
+ },
16
+ ];
17
+ case 'dot':
18
+ return styles.dot;
19
+ case 'dot-small':
20
+ return styles.dotSmall;
21
+ }
22
+ };
23
+
24
+ return (
25
+ <View style={[getStyle(type), style]}>
26
+ {type === 'badge' && (
27
+ <Text
28
+ weight="medium"
29
+ style={[{ fontSize: 10, color: Colors.white }, textStyle]}>
30
+ {value > 99 ? '99+' : value}
31
+ </Text>
32
+ )}
33
+ </View>
34
+ );
35
+ };
36
+
37
+ const styles = StyleSheet.create({
38
+ container: {
39
+ paddingHorizontal: Spacing.XS,
40
+ backgroundColor: Colors.error,
41
+ borderRadius: Radius.M,
42
+ justifyContent: 'center',
43
+ alignItems: 'center',
44
+ position: 'absolute',
45
+ top: -4,
46
+ },
47
+ dot: {
48
+ width: 16,
49
+ height: 16,
50
+ borderWidth: 1,
51
+ borderColor: Colors.white,
52
+ backgroundColor: Colors.error,
53
+ borderRadius: 8,
54
+ position: 'absolute',
55
+ right: -8,
56
+ top: -8,
57
+ },
58
+ dotSmall: {
59
+ width: 10,
60
+ height: 10,
61
+ borderWidth: 1,
62
+ borderColor: Colors.white,
63
+ backgroundColor: Colors.error,
64
+ borderRadius: 5,
65
+ position: 'absolute',
66
+ right: -5,
67
+ top: -5,
68
+ },
69
+ });
70
+
71
+ Badge.defaultProps = {
72
+ type: 'badge',
73
+ };
74
+
75
+ export default Badge;
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@momo-kits/badge",
3
+ "version": "0.0.46-beta.52",
4
+ "private": false,
5
+ "main": "index.js",
6
+ "dependencies": {},
7
+ "peerDependencies": {
8
+ "react-native": ">=0.55",
9
+ "prop-types": "^15.7.2",
10
+ "react": "16.9.0",
11
+ "@momo-kits/core": ">=0.0.5-beta",
12
+ "lodash": "^4.17.15"
13
+ },
14
+ "devDependencies": {},
15
+ "license": "MoMo"
16
+ }
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' --exclude 'web.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/avatar new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/avatar"}'