From c1c6b2e4befdda6066b66d0d4ffd90aaca17f23f Mon Sep 17 00:00:00 2001 From: Pavel Prichodko <14926950+prichodko@users.noreply.github.com> Date: Mon, 16 Jan 2023 13:10:58 +0100 Subject: [PATCH] add button component --- .../components/src/button/button.stories.tsx | 33 ++++++++++ packages/components/src/button/button.tsx | 60 +++++++++++++++++++ packages/components/src/button/index.tsx | 1 + 3 files changed, 94 insertions(+) create mode 100644 packages/components/src/button/button.stories.tsx create mode 100644 packages/components/src/button/button.tsx create mode 100644 packages/components/src/button/index.tsx diff --git a/packages/components/src/button/button.stories.tsx b/packages/components/src/button/button.stories.tsx new file mode 100644 index 00000000..a68a3ee3 --- /dev/null +++ b/packages/components/src/button/button.stories.tsx @@ -0,0 +1,33 @@ +import { Button } from './button' + +import type { Meta, StoryObj } from '@storybook/react' + +// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction +const meta: Meta = { + component: Button, + argTypes: {}, +} + +type Story = StoryObj + +// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args +export const Primary: Story = { + args: { + children: 'Click me', + }, +} + +export const PrimaryLong: Story = { + args: { + children: 'Lorem ipsum dim sum', + }, +} + +export const Success: Story = { + args: { + type: 'positive', + children: 'Click me', + }, +} + +export default meta diff --git a/packages/components/src/button/button.tsx b/packages/components/src/button/button.tsx new file mode 100644 index 00000000..886e6b8b --- /dev/null +++ b/packages/components/src/button/button.tsx @@ -0,0 +1,60 @@ +import { Stack, styled, Text } from '@tamagui/core' + +import type { GetProps } from '@tamagui/core' +// import { Button} from 'react-native' + +// import { Button as RNButton } from 'react-native' + +// setupReactNative({ Button: RNButton }) + +// import type { GetProps} from '@tamagui/core'; + +const Base = styled(Stack, { + // tag: 'button', + + cursor: 'pointer', + borderRadius: 12, + display: 'inline-flex', + paddingHorizontal: 16, + paddingVertical: 10, + + variants: { + type: { + primary: { + backgroundColor: 'hsla(229, 71%, 57%, 1)', + hoverStyle: { backgroundColor: 'hsla(229, 54%, 45%, 1)' }, + pressStyle: { backgroundColor: 'hsla(229, 54%, 45%, 1)' }, + }, + positive: { + backgroundColor: 'hsla(174, 63%, 40%, 1)', + hoverStyle: { backgroundColor: 'hsla(174, 63%, 34%, 1)' }, + pressStyle: { backgroundColor: 'hsla(174, 63%, 34%, 1)' }, + }, + }, + } as const, +}) + +const ButtonText = styled(Text, { + color: 'rgb(255, 255, 255)', + textAlign: 'center', +}) + +type BaseProps = GetProps + +interface Props { + type?: BaseProps['type'] + children: string +} + +const Button = (props: Props) => { + const { type = 'primary', children } = props + + return ( + + {children} + + ) +} + +export { Button } +// const Button = diff --git a/packages/components/src/button/index.tsx b/packages/components/src/button/index.tsx new file mode 100644 index 00000000..db783b10 --- /dev/null +++ b/packages/components/src/button/index.tsx @@ -0,0 +1 @@ +export { Button } from './button'