@momo-kits/badge 0.75.1-beta.2 → 0.75.1-beta.6
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/Badge.tsx +35 -0
- package/BadgeDot.tsx +11 -0
- package/BadgeRibbon.tsx +141 -0
- package/index.tsx +7 -0
- package/package.json +2 -2
- package/styles.ts +58 -0
- package/types.ts +19 -0
- package/Badge.js +0 -101
- package/RibbonRadius.js +0 -112
- package/RibbonSkew.js +0 -111
- package/index.js +0 -5
- /package/{Shape.js → Shape.tsx} +0 -0
package/Badge.tsx
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import {ApplicationContext, Colors, Text} from '@momo-kits/foundation';
|
|
4
|
+
import {BadgeProps, BadgeType} from './types';
|
|
5
|
+
import styles from './styles';
|
|
6
|
+
|
|
7
|
+
const Badge: FC<BadgeProps> = ({label = 'Label', style}) => {
|
|
8
|
+
const {theme} = useContext(ApplicationContext);
|
|
9
|
+
|
|
10
|
+
const isNumber = () => {
|
|
11
|
+
const numberRegex = /^\d+$/;
|
|
12
|
+
return numberRegex.test(String(label));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const formatTitle = () => {
|
|
16
|
+
if (isNumber() && Number(label) > 99) {
|
|
17
|
+
return '99+';
|
|
18
|
+
}
|
|
19
|
+
return label.toString();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const backgroundColor = isNumber()
|
|
23
|
+
? theme.colors.error.primary
|
|
24
|
+
: theme.colors.warning.primary;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<View style={[style, styles.badge, {backgroundColor}]}>
|
|
28
|
+
<Text color={Colors.black_01} typography={'action_xxs'}>
|
|
29
|
+
{formatTitle()}
|
|
30
|
+
</Text>
|
|
31
|
+
</View>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default Badge;
|
package/BadgeDot.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import {BadgeDotProps} from './types';
|
|
4
|
+
import styles from './styles';
|
|
5
|
+
|
|
6
|
+
const BadgeDot: FC<BadgeDotProps> = ({size = 'large', style}) => {
|
|
7
|
+
const dotStyle = size === 'small' ? styles.dotSmall : styles.dot;
|
|
8
|
+
return <View style={[style, dotStyle]} />;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default BadgeDot;
|
package/BadgeRibbon.tsx
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import {DownTail, Skew, UpTail} from './Shape';
|
|
4
|
+
import styles from './styles';
|
|
5
|
+
import {BadgeRibbonProps} from './types';
|
|
6
|
+
import {ApplicationContext, Colors, Text} from '@momo-kits/foundation';
|
|
7
|
+
|
|
8
|
+
const BadgeRibbon: FC<BadgeRibbonProps> = ({
|
|
9
|
+
position = 'top_right',
|
|
10
|
+
label = 'Label',
|
|
11
|
+
isRound = false,
|
|
12
|
+
}) => {
|
|
13
|
+
const {theme} = useContext(ApplicationContext);
|
|
14
|
+
let ribbonRotate = '0deg';
|
|
15
|
+
let textRotate = '0deg';
|
|
16
|
+
let ribbonTail = <DownTail />;
|
|
17
|
+
let textMargin = 0;
|
|
18
|
+
let skewMargin = 0;
|
|
19
|
+
|
|
20
|
+
if (position === 'top_right' || position === 'bottom_right') {
|
|
21
|
+
ribbonRotate = '180deg';
|
|
22
|
+
textRotate = '180deg';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (position === 'bottom_left' || position === 'top_right') {
|
|
26
|
+
textMargin = 4;
|
|
27
|
+
ribbonTail = <UpTail />;
|
|
28
|
+
skewMargin = 4;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const getPosition = () => {
|
|
32
|
+
switch (position) {
|
|
33
|
+
case 'top_left':
|
|
34
|
+
return {
|
|
35
|
+
top: -4,
|
|
36
|
+
left: -2,
|
|
37
|
+
};
|
|
38
|
+
case 'bottom_left':
|
|
39
|
+
return {
|
|
40
|
+
bottom: -4,
|
|
41
|
+
left: -2,
|
|
42
|
+
};
|
|
43
|
+
case 'top_right':
|
|
44
|
+
return {
|
|
45
|
+
top: -4,
|
|
46
|
+
right: -2,
|
|
47
|
+
};
|
|
48
|
+
case 'bottom_right':
|
|
49
|
+
return {
|
|
50
|
+
bottom: -4,
|
|
51
|
+
right: -2,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const renderRoundContent = () => {
|
|
57
|
+
return (
|
|
58
|
+
<View
|
|
59
|
+
style={[
|
|
60
|
+
styles.ribbonContent,
|
|
61
|
+
{
|
|
62
|
+
backgroundColor: theme.colors.warning.primary,
|
|
63
|
+
marginTop: textMargin,
|
|
64
|
+
},
|
|
65
|
+
]}>
|
|
66
|
+
<Text
|
|
67
|
+
style={[
|
|
68
|
+
styles.ribbonLabel,
|
|
69
|
+
{
|
|
70
|
+
transform: [
|
|
71
|
+
{
|
|
72
|
+
rotate: textRotate,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
]}
|
|
77
|
+
color={Colors.black_01}
|
|
78
|
+
typography={'label_xs'}>
|
|
79
|
+
{label}
|
|
80
|
+
</Text>
|
|
81
|
+
</View>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const renderSkewContent = () => {
|
|
86
|
+
return (
|
|
87
|
+
<View
|
|
88
|
+
style={{
|
|
89
|
+
flexDirection: 'row',
|
|
90
|
+
marginTop: skewMargin,
|
|
91
|
+
}}>
|
|
92
|
+
<View
|
|
93
|
+
style={[
|
|
94
|
+
styles.ribbonSkewContent,
|
|
95
|
+
{
|
|
96
|
+
backgroundColor: theme.colors.warning.primary,
|
|
97
|
+
},
|
|
98
|
+
]}>
|
|
99
|
+
<Text
|
|
100
|
+
style={[
|
|
101
|
+
styles.ribbonLabel,
|
|
102
|
+
{
|
|
103
|
+
transform: [
|
|
104
|
+
{
|
|
105
|
+
rotate: textRotate,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
]}
|
|
110
|
+
color={Colors.black_01}
|
|
111
|
+
typography={'label_xs'}>
|
|
112
|
+
{label}
|
|
113
|
+
</Text>
|
|
114
|
+
</View>
|
|
115
|
+
<Skew />
|
|
116
|
+
</View>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const content = isRound ? renderRoundContent() : renderSkewContent();
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<View
|
|
124
|
+
style={[
|
|
125
|
+
styles.ribbon,
|
|
126
|
+
{
|
|
127
|
+
transform: [
|
|
128
|
+
{
|
|
129
|
+
rotate: ribbonRotate,
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
getPosition(),
|
|
134
|
+
]}>
|
|
135
|
+
{ribbonTail}
|
|
136
|
+
{content}
|
|
137
|
+
</View>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export default BadgeRibbon;
|
package/index.tsx
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Badge from './Badge';
|
|
2
|
+
import BadgeDot from './BadgeDot';
|
|
3
|
+
import BadgeRibbon from './BadgeRibbon';
|
|
4
|
+
import {BadgeProps, BadgeDotProps, BadgeRibbonProps} from './types';
|
|
5
|
+
|
|
6
|
+
export {Badge, BadgeRibbon, BadgeDot};
|
|
7
|
+
export type {BadgeProps, BadgeDotProps, BadgeRibbonProps};
|
package/package.json
CHANGED
package/styles.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {Colors, Radius, Spacing} from '@momo-kits/foundation';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
badge: {
|
|
6
|
+
paddingHorizontal: Spacing.XS,
|
|
7
|
+
borderRadius: Radius.M,
|
|
8
|
+
justifyContent: 'center',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
height: 16,
|
|
11
|
+
flexDirection: 'row',
|
|
12
|
+
borderWidth: 1,
|
|
13
|
+
borderColor: Colors.black_01,
|
|
14
|
+
alignSelf: 'baseline',
|
|
15
|
+
},
|
|
16
|
+
dot: {
|
|
17
|
+
width: 16,
|
|
18
|
+
height: 16,
|
|
19
|
+
borderWidth: 2,
|
|
20
|
+
borderColor: Colors.black_01,
|
|
21
|
+
backgroundColor: Colors.red_03,
|
|
22
|
+
borderRadius: 8,
|
|
23
|
+
},
|
|
24
|
+
dotSmall: {
|
|
25
|
+
width: 10,
|
|
26
|
+
height: 10,
|
|
27
|
+
borderWidth: 1,
|
|
28
|
+
borderColor: Colors.black_01,
|
|
29
|
+
backgroundColor: Colors.red_03,
|
|
30
|
+
borderRadius: 5,
|
|
31
|
+
},
|
|
32
|
+
ribbon: {
|
|
33
|
+
flexDirection: 'row',
|
|
34
|
+
height: 20,
|
|
35
|
+
},
|
|
36
|
+
ribbonContent: {
|
|
37
|
+
alignSelf: 'baseline',
|
|
38
|
+
height: 16,
|
|
39
|
+
justifyContent: 'center',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
borderBottomRightRadius: 12,
|
|
42
|
+
borderTopRightRadius: 12,
|
|
43
|
+
},
|
|
44
|
+
ribbonSkewContent: {
|
|
45
|
+
alignSelf: 'baseline',
|
|
46
|
+
height: 16,
|
|
47
|
+
justifyContent: 'center',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
},
|
|
50
|
+
ribbonLabel: {
|
|
51
|
+
fontSize: 10,
|
|
52
|
+
lineHeight: 14,
|
|
53
|
+
color: Colors.black_01,
|
|
54
|
+
minWidth: 20,
|
|
55
|
+
marginRight: 8,
|
|
56
|
+
fontWeight: 'bold',
|
|
57
|
+
},
|
|
58
|
+
});
|
package/types.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {ViewStyle} from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type BadgeType = 'badge' | 'badge_number' | 'dot' | 'dot_small';
|
|
4
|
+
|
|
5
|
+
export type BadgeProps = {
|
|
6
|
+
label?: string | number;
|
|
7
|
+
style?: ViewStyle | ViewStyle[];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type BadgeDotProps = {
|
|
11
|
+
size?: 'small' | 'large';
|
|
12
|
+
style?: ViewStyle | ViewStyle[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type BadgeRibbonProps = {
|
|
16
|
+
label: string;
|
|
17
|
+
position?: 'top_right' | 'top_left' | 'bottom_right' | 'bottom_left';
|
|
18
|
+
isRound?: boolean;
|
|
19
|
+
};
|
package/Badge.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {StyleSheet, View} from 'react-native';
|
|
3
|
-
import {Colors, Radius, Spacing, Text} from '@momo-kits/core-v2';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
|
|
6
|
-
const Badge = ({type, title, style}) => {
|
|
7
|
-
const isNumber = title => {
|
|
8
|
-
let parsedIntTitle = parseInt(title);
|
|
9
|
-
if (!isNaN(parsedIntTitle)) return true;
|
|
10
|
-
return false;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const getStyle = type => {
|
|
14
|
-
switch (type) {
|
|
15
|
-
case 'badge':
|
|
16
|
-
return [styles.container];
|
|
17
|
-
|
|
18
|
-
case 'dot':
|
|
19
|
-
return styles.dot;
|
|
20
|
-
case 'dot-small':
|
|
21
|
-
return styles.dotSmall;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const formatTitle = title => {
|
|
26
|
-
if (isNumber(title) && title > 99) {
|
|
27
|
-
return '99+';
|
|
28
|
-
}
|
|
29
|
-
return title;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const textBadgeStyle =
|
|
33
|
-
!isNumber(title) && type === 'badge' && styles.textBadge;
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<View style={style}>
|
|
37
|
-
<View style={[getStyle(type), textBadgeStyle]}>
|
|
38
|
-
{type === 'badge' && (
|
|
39
|
-
<Text.Action4 weight="medium" style={[styles.title]}>
|
|
40
|
-
{formatTitle(title)}
|
|
41
|
-
</Text.Action4>
|
|
42
|
-
)}
|
|
43
|
-
</View>
|
|
44
|
-
</View>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const styles = StyleSheet.create({
|
|
49
|
-
container: {
|
|
50
|
-
paddingHorizontal: Spacing.XS,
|
|
51
|
-
backgroundColor: Colors.red_03,
|
|
52
|
-
borderRadius: Radius.M,
|
|
53
|
-
justifyContent: 'center',
|
|
54
|
-
alignItems: 'center',
|
|
55
|
-
minWidth: 16,
|
|
56
|
-
height: 16,
|
|
57
|
-
flexDirection: 'row',
|
|
58
|
-
borderWidth: 1,
|
|
59
|
-
borderColor: Colors.black_01,
|
|
60
|
-
},
|
|
61
|
-
textBadge: {
|
|
62
|
-
backgroundColor: Colors.orange_03,
|
|
63
|
-
borderWidth: 1,
|
|
64
|
-
borderColor: Colors.black_01,
|
|
65
|
-
},
|
|
66
|
-
dot: {
|
|
67
|
-
width: 16,
|
|
68
|
-
height: 16,
|
|
69
|
-
borderWidth: 2,
|
|
70
|
-
borderColor: Colors.black_01,
|
|
71
|
-
backgroundColor: Colors.red_03,
|
|
72
|
-
borderRadius: 8,
|
|
73
|
-
},
|
|
74
|
-
dotSmall: {
|
|
75
|
-
width: 10,
|
|
76
|
-
height: 10,
|
|
77
|
-
borderWidth: 1,
|
|
78
|
-
borderColor: Colors.black_01,
|
|
79
|
-
backgroundColor: Colors.red_03,
|
|
80
|
-
borderRadius: 5,
|
|
81
|
-
},
|
|
82
|
-
title: {
|
|
83
|
-
fontSize: 10,
|
|
84
|
-
color: Colors.white,
|
|
85
|
-
lineHeight: 14,
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
Badge.propTypes = {
|
|
90
|
-
type: PropTypes.oneOf(['badge', 'dot', 'dot-small']),
|
|
91
|
-
title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
92
|
-
style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
93
|
-
textStyle: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
94
|
-
containerWidth: PropTypes.number,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
Badge.defaultProps = {
|
|
98
|
-
type: 'badge',
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export default Badge;
|
package/RibbonRadius.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { Colors, Text } from '@momo-kits/core-v2';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { StyleSheet, View } from 'react-native';
|
|
4
|
-
import { DownTail, UpTail } from './Shape';
|
|
5
|
-
|
|
6
|
-
const styles = StyleSheet.create({
|
|
7
|
-
container: {
|
|
8
|
-
flexDirection: 'row',
|
|
9
|
-
position: 'absolute',
|
|
10
|
-
|
|
11
|
-
height: 20,
|
|
12
|
-
},
|
|
13
|
-
content: {
|
|
14
|
-
backgroundColor: Colors.orange_03,
|
|
15
|
-
alignSelf: 'baseline',
|
|
16
|
-
height: 16,
|
|
17
|
-
justifyContent: 'center',
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
borderBottomRightRadius: 12,
|
|
20
|
-
borderTopRightRadius: 12,
|
|
21
|
-
},
|
|
22
|
-
contentText: {
|
|
23
|
-
fontSize: 10,
|
|
24
|
-
lineHeight: 14,
|
|
25
|
-
color: Colors.black_01,
|
|
26
|
-
minWidth: 20,
|
|
27
|
-
marginRight: 8,
|
|
28
|
-
fontWeight: 'bold',
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const RinbbonRadius = ({ title = 'Name', position = 'topLeft' }) => {
|
|
33
|
-
const getPosition = (position) => {
|
|
34
|
-
switch (position) {
|
|
35
|
-
case 'topLeft':
|
|
36
|
-
return {
|
|
37
|
-
top: -4,
|
|
38
|
-
left: -2,
|
|
39
|
-
};
|
|
40
|
-
case 'bottomLeft':
|
|
41
|
-
return {
|
|
42
|
-
bottom: -4,
|
|
43
|
-
left: -2,
|
|
44
|
-
};
|
|
45
|
-
case 'topRight':
|
|
46
|
-
return {
|
|
47
|
-
top: -4,
|
|
48
|
-
right: -2,
|
|
49
|
-
};
|
|
50
|
-
case 'bottomRight':
|
|
51
|
-
return {
|
|
52
|
-
bottom: -4,
|
|
53
|
-
right: -2,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<View
|
|
60
|
-
style={[
|
|
61
|
-
styles.container,
|
|
62
|
-
{
|
|
63
|
-
transform: [
|
|
64
|
-
{
|
|
65
|
-
rotate:
|
|
66
|
-
position === 'topRight' ||
|
|
67
|
-
position === 'bottomRight'
|
|
68
|
-
? '180deg'
|
|
69
|
-
: '0deg',
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
getPosition(position),
|
|
74
|
-
]}>
|
|
75
|
-
{position === 'bottomLeft' || position === 'topRight' ? (
|
|
76
|
-
<UpTail />
|
|
77
|
-
) : (
|
|
78
|
-
<DownTail />
|
|
79
|
-
)}
|
|
80
|
-
<View
|
|
81
|
-
style={[
|
|
82
|
-
styles.content,
|
|
83
|
-
{
|
|
84
|
-
marginTop:
|
|
85
|
-
position === 'bottomLeft' || position === 'topRight'
|
|
86
|
-
? 4
|
|
87
|
-
: 0,
|
|
88
|
-
},
|
|
89
|
-
]}>
|
|
90
|
-
<Text
|
|
91
|
-
style={[
|
|
92
|
-
styles.contentText,
|
|
93
|
-
{
|
|
94
|
-
transform: [
|
|
95
|
-
{
|
|
96
|
-
rotate:
|
|
97
|
-
position === 'topRight' ||
|
|
98
|
-
position === 'bottomRight'
|
|
99
|
-
? '180deg'
|
|
100
|
-
: '0deg',
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
},
|
|
104
|
-
]}>
|
|
105
|
-
{title}
|
|
106
|
-
</Text>
|
|
107
|
-
</View>
|
|
108
|
-
</View>
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export default RinbbonRadius;
|
package/RibbonSkew.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { Colors, Text } from '@momo-kits/core-v2';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { StyleSheet, View } from 'react-native';
|
|
4
|
-
import { DownTail, Skew, UpTail } from './Shape';
|
|
5
|
-
|
|
6
|
-
const styles = StyleSheet.create({
|
|
7
|
-
container: {
|
|
8
|
-
flexDirection: 'row',
|
|
9
|
-
position: 'absolute',
|
|
10
|
-
|
|
11
|
-
height: 20,
|
|
12
|
-
},
|
|
13
|
-
content: {
|
|
14
|
-
backgroundColor: Colors.orange_03,
|
|
15
|
-
alignSelf: 'baseline',
|
|
16
|
-
height: 16,
|
|
17
|
-
justifyContent: 'center',
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
},
|
|
20
|
-
contentText: {
|
|
21
|
-
fontSize: 10,
|
|
22
|
-
lineHeight: 14,
|
|
23
|
-
color: Colors.black_01,
|
|
24
|
-
minWidth: 20,
|
|
25
|
-
marginRight: 8,
|
|
26
|
-
fontWeight: 'bold',
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const RibbonSkew = ({ title = 'Name', position = 'topLeft' }) => {
|
|
31
|
-
const getPosition = (position) => {
|
|
32
|
-
switch (position) {
|
|
33
|
-
case 'topLeft':
|
|
34
|
-
return {
|
|
35
|
-
top: -4,
|
|
36
|
-
left: -2,
|
|
37
|
-
};
|
|
38
|
-
case 'bottomLeft':
|
|
39
|
-
return {
|
|
40
|
-
bottom: -4,
|
|
41
|
-
left: -2,
|
|
42
|
-
};
|
|
43
|
-
case 'topRight':
|
|
44
|
-
return {
|
|
45
|
-
top: -4,
|
|
46
|
-
right: -2,
|
|
47
|
-
};
|
|
48
|
-
case 'bottomRight':
|
|
49
|
-
return {
|
|
50
|
-
bottom: -4,
|
|
51
|
-
right: -2,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<View
|
|
58
|
-
style={[
|
|
59
|
-
styles.container,
|
|
60
|
-
{
|
|
61
|
-
transform: [
|
|
62
|
-
{
|
|
63
|
-
rotate:
|
|
64
|
-
position === 'topRight' ||
|
|
65
|
-
position === 'bottomRight'
|
|
66
|
-
? '180deg'
|
|
67
|
-
: '0deg',
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
|
-
getPosition(position),
|
|
72
|
-
]}>
|
|
73
|
-
{position === 'bottomLeft' || position === 'topRight' ? (
|
|
74
|
-
<UpTail />
|
|
75
|
-
) : (
|
|
76
|
-
<DownTail />
|
|
77
|
-
)}
|
|
78
|
-
<View
|
|
79
|
-
style={{
|
|
80
|
-
flexDirection: 'row',
|
|
81
|
-
marginTop:
|
|
82
|
-
position === 'bottomLeft' || position === 'topRight'
|
|
83
|
-
? 4
|
|
84
|
-
: 0,
|
|
85
|
-
}}>
|
|
86
|
-
<View style={styles.content}>
|
|
87
|
-
<Text
|
|
88
|
-
style={[
|
|
89
|
-
styles.contentText,
|
|
90
|
-
{
|
|
91
|
-
transform: [
|
|
92
|
-
{
|
|
93
|
-
rotate:
|
|
94
|
-
position === 'topRight' ||
|
|
95
|
-
position === 'bottomRight'
|
|
96
|
-
? '180deg'
|
|
97
|
-
: '0deg',
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
},
|
|
101
|
-
]}>
|
|
102
|
-
{title}
|
|
103
|
-
</Text>
|
|
104
|
-
</View>
|
|
105
|
-
<Skew />
|
|
106
|
-
</View>
|
|
107
|
-
</View>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export default RibbonSkew;
|
package/index.js
DELETED
/package/{Shape.js → Shape.tsx}
RENAMED
|
File without changes
|