Skip to content

Commit 2f91124

Browse files
committed
feat: container
1 parent bb17417 commit 2f91124

File tree

5 files changed

+67
-17
lines changed

5 files changed

+67
-17
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from 'react'
2+
import { View } from 'react-native'
3+
import { Button, Container, Text, TextField } from '@berty/ui-components'
4+
import type { Meta } from '@storybook/react'
5+
6+
const meta = {
7+
title: 'Layout/Page',
8+
component: Button,
9+
argTypes: {
10+
onPress: { action: 'pressed the button' },
11+
color: {
12+
control: {
13+
type: 'text',
14+
options: ['primary', 'secondary'],
15+
defaultValue: 'primary',
16+
},
17+
},
18+
},
19+
args: {
20+
color: 'primary',
21+
children: 'Primary Button',
22+
},
23+
decorators: [
24+
Story => (
25+
<Container>
26+
<Story />
27+
</Container>
28+
),
29+
],
30+
} satisfies Meta<typeof Button>
31+
32+
export default meta
33+
34+
export const Basic = (args: any) => (
35+
<>
36+
<Text.H1>Create The</Text.H1>
37+
<Text.H1>Master</Text.H1>
38+
<Text.H1>Keyword</Text.H1>
39+
<View style={{ height: 16 }} />
40+
<TextField placeholder='Master Keyword' type='password' />
41+
<View style={{ height: 2 }} />
42+
<TextField placeholder='Confirm Master Keyword' type='password' />
43+
<View style={{ height: 8 }} />
44+
<Button>Create</Button>
45+
</>
46+
)

example/.storybook/stories/TextField/TextField.stories.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,9 @@ const meta = {
88
component: TextField,
99
argTypes: {
1010
onPress: { action: 'pressed the button' },
11-
color: {
12-
control: {
13-
type: 'text',
14-
options: ['primary', 'secondary'],
15-
defaultValue: 'primary',
16-
},
17-
},
1811
},
1912
args: {
20-
color: 'primary',
21-
children: 'Primary Button',
13+
children: 'Text Field Content',
2214
placeholder: 'Placeholder Text',
2315
},
2416
decorators: [
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import styled, { DefaultTheme } from 'styled-components/native'
2+
3+
export const Container = styled.View`
4+
flex: 1;
5+
padding: 22px;
6+
background-color: ${({ theme }: { theme: DefaultTheme }) => theme.textinputs?.background};
7+
`

src/components/textFields/TextField.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ import styled, { DefaultTheme } from 'styled-components/native'
44
import { FontAwesome } from '@expo/vector-icons'
55

66
export type Props = {
7-
type: 'password' | 'text'
8-
theme: DefaultTheme
7+
type?: 'password' | 'text'
98
} & TextInputProps
109

11-
export const TextField: React.FC<Props> = props => {
12-
const [isSecureText, setShowSecureText] = React.useState(props.type === 'password')
10+
type PropsWithTheme = Props & { theme: DefaultTheme }
11+
12+
export const TextField: React.FC<Props> = ({ type = 'text', ...rest }) => {
13+
const [isSecureText, setShowSecureText] = React.useState(type === 'password')
1314

1415
return (
1516
<Container>
16-
<TextFieldStyled {...props} secureTextEntry={isSecureText} />
17-
{props.type === 'password' ? (
17+
<TextFieldStyled {...rest} secureTextEntry={isSecureText} />
18+
{type === 'password' ? (
1819
<ToggleIcon>
1920
<FontAwesome size={28} name={isSecureText ? 'eye-slash' : 'eye'} onPress={() => setShowSecureText(prev => !prev)} />
2021
</ToggleIcon>
@@ -35,12 +36,15 @@ const Container = styled.View<Props>`
3536
background-color: ${({ theme }: { theme: DefaultTheme }) => theme.textinputs?.background};
3637
`
3738

38-
const TextFieldStyled = styled.TextInput.attrs((props: Props) => ({
39+
const TextFieldStyled = styled.TextInput.attrs((props: PropsWithTheme) => ({
3940
placeholderTextColor: props.theme.textinputs?.placeholder.color || props.theme.colors.black,
4041
}))`
4142
flex: 1;
4243
height: 40px;
4344
width: 100%;
45+
font-weight: 500;
46+
line-height: 20px;
47+
font-size: 18px;
4448
padding-horizontal: 16px;
4549
placeholder: ${({ theme }: { theme: DefaultTheme }) => theme.colors.black};
4650
border-style: solid;

src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { DefaultTheme, ThemeProvider } from 'styled-components'
22
import { Button } from './components/buttons'
3+
import { Container } from './components/layout/Container'
34
import { H1 } from './components/text'
45
import { TextField } from './components/textFields/TextField'
56

67
export const Text = { H1 }
78

8-
export { ThemeProvider, DefaultTheme, Button, TextField }
9+
export { ThemeProvider, DefaultTheme, Button, TextField, Container }

0 commit comments

Comments
 (0)