Skip to content

Commit fbb4202

Browse files
committed
adicionando componente Button
1 parent 87fe90c commit fbb4202

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

src/components/Button/Button.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import {Text} from '../Text';
3+
4+
import {ActivityIndicator} from 'react-native';
5+
import {TouchableOpacityBox} from '../TouchableOpacityBox';
6+
import {ButtonProps} from './types';
7+
import {buttonThemes} from './theme';
8+
9+
export function Button({loading, text, buttonType}: ButtonProps) {
10+
const theme = buttonThemes[buttonType];
11+
return (
12+
<TouchableOpacityBox
13+
paddingHorizontal="s20"
14+
height={50}
15+
alignItems="center"
16+
justifyContent="center"
17+
borderRadius="s16"
18+
backgroundColor={theme.background}
19+
borderWidth={theme.borderWidth}
20+
borderColor={theme.borderColor}>
21+
{!loading ? (
22+
<Text type="headingMedium" color={theme.backgroundContrast}>
23+
{text}
24+
</Text>
25+
) : (
26+
<ActivityIndicator color="white" />
27+
)}
28+
</TouchableOpacityBox>
29+
);
30+
}

src/components/Button/theme.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {ButtonTheme, ButtonTypes} from './types';
2+
3+
export const buttonThemes: Record<ButtonTypes, ButtonTheme> = {
4+
primary: {
5+
background: 'primary',
6+
backgroundContrast: 'primaryContrast',
7+
borderWidth: 0,
8+
},
9+
outline: {
10+
background: 'white',
11+
backgroundContrast: 'primary',
12+
borderWidth: 1,
13+
borderColor: 'primary',
14+
},
15+
};

src/components/Button/types.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {Colors} from '../../theme';
2+
import {TouchableOpacityBoxProps} from '../TouchableOpacityBox';
3+
4+
export interface ButtonTheme {
5+
background: Colors;
6+
backgroundContrast: Colors;
7+
borderWidth: number;
8+
borderColor?: Colors;
9+
}
10+
11+
export type ButtonTypes = 'primary' | 'outline';
12+
13+
export interface ButtonProps extends TouchableOpacityBoxProps {
14+
loading?: boolean;
15+
text: string;
16+
buttonType: ButtonTypes;
17+
}

0 commit comments

Comments
 (0)