Skip to content

Commit 4ebbbff

Browse files
committed
feat: added new plop template
1 parent bbc676f commit 4ebbbff

File tree

3 files changed

+54
-30
lines changed

3 files changed

+54
-30
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { RouteProp, useNavigation, useRoute } from '@react-navigation/core';
2+
import { StackNavigationProp } from '@react-navigation/stack';
3+
import { Box } from 'components/molecules/Box';
4+
import { Button } from 'components/molecules/Button';
5+
import { Typography } from 'components/molecules/Typography';
6+
import React from 'react';
7+
import { StyleSheet } from 'react-native';
8+
import { SafeAreaView } from 'react-native-safe-area-context';
9+
import { CommonStackParamList } from 'screens';
10+
import { theme } from 'theme';
11+
12+
type {{pascalCase name}}ScreenNavigationProp = StackNavigationProp<
13+
CommonStackParamList,
14+
'{{pascalCase name}}'
15+
>;
16+
17+
type {{pascalCase name}}ScreenRouteProp = RouteProp<CommonStackParamList, '{{pascalCase name}}'>;
18+
19+
const {{pascalCase name}}Screen = () => {
20+
const navigation = useNavigation<{{pascalCase name}}ScreenNavigationProp>();
21+
const route = useRoute<{{pascalCase name}}ScreenRouteProp>();
22+
23+
return (
24+
<SafeAreaView style={styles.safeArea}>
25+
<Box alignItems="center" justifyContent="center" flex={1}>
26+
<Typography>{{pascalCase name}}</Typography>
27+
<Button onPress={() => {
28+
navigation.goBack();
29+
}}>
30+
<Typography>Back {{pascalCase name}}</Typography>
31+
</Button>
32+
</Box>
33+
</SafeAreaView>
34+
);
35+
};
36+
37+
const styles = StyleSheet.create({
38+
safeArea: {
39+
flex: 1,
40+
backgroundColor: theme.colors.backgroundColor,
41+
},
42+
});
43+
44+
export default {{pascalCase name}}Screen;

template/src/components/molecules/Button/Button.tsx

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { WINDOW_DEVICE_HEIGHT, WINDOW_DEVICE_WIDTH } from '@utils/constants';
21
import React from 'react';
3-
import { Dimensions } from 'react-native';
42
import styled, { DefaultTheme } from 'styled-components/native';
53
import {
64
LayoutProps,
@@ -21,8 +19,6 @@ import {
2119
PositionProps,
2220
ButtonStyleProps,
2321
buttonStyle,
24-
PaddingProps,
25-
padding,
2622
} from 'styled-system';
2723
import { theme } from 'theme';
2824

@@ -31,13 +27,11 @@ type VariantTypes = 'outlined' | 'rounded' | 'box' | 'disabled';
3127
interface ButtonProps
3228
extends LayoutProps,
3329
ColorProps<typeof theme>,
34-
SpaceProps,
35-
BordersProps,
36-
FlexProps,
30+
SpaceProps<typeof theme>,
31+
BordersProps<typeof theme>,
3732
PositionProps,
38-
FlexboxProps,
39-
ButtonStyleProps<typeof theme>,
40-
PaddingProps {
33+
FlexboxProps<typeof theme>,
34+
ButtonStyleProps {
4135
children?: React.ReactNode;
4236
variant?: VariantTypes;
4337
}
@@ -53,11 +47,13 @@ const variantStyle = (theme: DefaultTheme, disabled: boolean) => {
5347
},
5448
outlined: {
5549
borderColor: 'primary',
56-
borderWidth: 1,
50+
borderWidth: 'sm',
5751
borderStyle: 'solid',
5852
},
5953
rounded: {
60-
borderRadius: 8,
54+
borderRadius: 'sm',
55+
padding: 'md',
56+
backgroundColor: 'primary',
6157
},
6258
disabled: {
6359
backgroundColor: 'black',
@@ -67,25 +63,13 @@ const variantStyle = (theme: DefaultTheme, disabled: boolean) => {
6763
};
6864

6965
const Button = styled.TouchableOpacity<ButtonProps>`
70-
${compose(
71-
color,
72-
layout,
73-
space,
74-
borders,
75-
flex,
76-
position,
77-
flexbox,
78-
buttonStyle,
79-
padding,
80-
)}
81-
/* background-color:${({ theme, disabled }) =>
82-
disabled ? theme.colors.black : theme.colors.primary} */
66+
${compose(color, layout, space, borders, position, flexbox, buttonStyle)}
67+
8368
${({ theme, disabled }) => variantStyle(theme, !!disabled)}
8469
`;
8570
Button.defaultProps = {
8671
justifyContent: 'center',
8772
alignItems: 'center',
88-
width: '100%',
8973
height: 48,
9074
};
9175

template/src/components/molecules/Typography/Typography.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { log } from '@utils/console';
2-
import React from 'react';
31
import { Text } from 'react-native';
42
import styled, { DefaultTheme } from 'styled-components/native';
53
import {
@@ -15,8 +13,6 @@ import {
1513
typography,
1614
color,
1715
ColorProps,
18-
FontFamilyProps,
19-
fontFamily,
2016
} from 'styled-system';
2117
import { theme } from 'theme';
2218

0 commit comments

Comments
 (0)