use existing component in button

This commit is contained in:
Pavel Prichodko 2023-01-18 16:41:45 +01:00
parent 7b0ab3dad0
commit 2e4705e572
No known key found for this signature in database
GPG Key ID: 8E4C82D464215E83
1 changed files with 14 additions and 10 deletions

View File

@ -1,16 +1,23 @@
import { Stack, styled, Text } from '@tamagui/core' import { Stack, styled } from '@tamagui/core'
import { Paragraph } from '../typography'
import type { GetProps } from '@tamagui/core' import type { GetProps } from '@tamagui/core'
// import { Pressable } from 'react-native'
const Base = styled(Stack, { const Base = styled(Stack, {
// tag: 'button', name: 'Button',
accessibilityRole: 'button',
cursor: 'pointer', cursor: 'pointer',
borderRadius: 12, borderRadius: 12,
display: 'inline-flex', display: 'inline-flex',
paddingHorizontal: 16, paddingHorizontal: 16,
paddingVertical: 10, paddingTop: 7,
paddingBottom: 9,
animation: 'fast', animation: 'fast',
userSelect: 'none',
variants: { variants: {
type: { type: {
primary: { primary: {
@ -27,12 +34,6 @@ const Base = styled(Stack, {
} as const, } as const,
}) })
const ButtonText = styled(Text, {
fontFamily: '$inter',
textAlign: 'center',
color: '$white-100',
})
type BaseProps = GetProps<typeof Base> type BaseProps = GetProps<typeof Base>
type Props = { type Props = {
@ -46,9 +47,12 @@ const Button = (props: Props) => {
return ( return (
<Base {...rest} type={type} onPress={onPress}> <Base {...rest} type={type} onPress={onPress}>
<ButtonText>{children}</ButtonText> <Paragraph color="$white-100" textAlign="center" weight="medium">
{children}
</Paragraph>
</Base> </Base>
) )
} }
export { Button } export { Button }
export type { Props as ButtonProps }