Skip to content

Commit 5b38cb1

Browse files
katsuhira02Danil
andauthored
add components buttons and space (#61)
Co-authored-by: Danil <[email protected]>
1 parent d3b60ea commit 5b38cb1

5 files changed

Lines changed: 104 additions & 4 deletions

File tree

App.tsx

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
import * as React from 'react'
22
import { Text } from 'react-native'
3+
import { StyleSheet, ScrollView, View } from 'react-native'
4+
import { DARK, WHITE } from './src/constants'
5+
import { Button, Space } from './src/components'
36

4-
const App = () => (
5-
<Text>Hello world!</Text>
6-
)
7+
const styles = StyleSheet.create({
8+
container: {
9+
flex: 1,
10+
justifyContent: 'center',
11+
alignItems: 'center',
12+
backgroundColor: DARK
13+
},
14+
textStyle: {
15+
color: WHITE,
16+
fontSize: 25,
17+
paddingBottom: 10
18+
}
19+
})
720

8-
export default App
21+
export default function App({}){
22+
const { container, textStyle } = styles
23+
return(
24+
<View style={container}>
25+
<Text style={textStyle}>Buttons</Text>
26+
<Button isOutline={true} isSmall={false} title='Push me'/>
27+
<Space height={15} />
28+
<Button isOutline={false} isSmall={false} title='Push me'/>
29+
<Space height={15} />
30+
<Button isOutline={true} isSmall={true} title='Push me'/>
31+
<Space height={15} />
32+
<Button isOutline={false} isSmall={true} title='Push me'/>
33+
<Space height={15} />
34+
</View>
35+
)
36+
}

src/components/Button/index.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import React from 'react'
2+
import { StyleSheet, Text, Pressable } from 'react-native'
3+
import { PRIMARY, WHITE } from '../../constants'
4+
5+
const styles = StyleSheet.create({
6+
container: {
7+
justifyContent: 'center',
8+
height: 48,
9+
width: 343,
10+
borderRadius: 25
11+
},
12+
textStyle: {
13+
alignItems: 'center',
14+
alignSelf: 'center',
15+
color: WHITE
16+
},
17+
color: {
18+
backgroundColor: PRIMARY
19+
},
20+
outlineStyle: {
21+
borderWidth: 1.5,
22+
borderColor: 'white',
23+
color: 'white'
24+
},
25+
smallContainer: {
26+
justifyContent: 'center',
27+
width: 160,
28+
height: 36,
29+
borderRadius: 25
30+
}
31+
})
32+
33+
interface ButtonT {
34+
title: string,
35+
isOutline: boolean,
36+
isSmall: boolean
37+
}
38+
39+
function Button({ isOutline, title, isSmall }: ButtonT) {
40+
const { container, color, outlineStyle, textStyle, smallContainer } = styles
41+
const colorButton = isOutline ? outlineStyle : color
42+
const sizeButton = isSmall ? smallContainer : container
43+
return (
44+
<Pressable
45+
style={({ pressed }) => [
46+
{
47+
opacity: pressed ? 0.9 : 1
48+
},
49+
colorButton,
50+
sizeButton
51+
]}
52+
>
53+
<Text style={textStyle}>{title}</Text>
54+
</Pressable>
55+
)
56+
}
57+
58+
export { Button }

src/components/Space/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React, { memo } from 'react'
2+
import { View } from 'react-native'
3+
4+
interface SpaceT {
5+
height: number
6+
}
7+
8+
const Space = memo<SpaceT>(({ height }) => (
9+
<View style={{ height: height || 30 }} />
10+
))
11+
12+
export { Space }

src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './Button'
2+
export * from './Space'
File renamed without changes.

0 commit comments

Comments
 (0)