Skip to content

Commit

Permalink
feat (elements): add new component
Browse files Browse the repository at this point in the history
add new component 'button' in two (filled/bordered) styles from figma
  • Loading branch information
sgrisshk committed Sep 4, 2024
1 parent a0ab453 commit 55bd340
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/Button/button.props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface ButtonProps {
label:string;
disabled?:boolean;
color?: 'filled' | 'bordered';
}
22 changes: 22 additions & 0 deletions src/components/Button/button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { Meta, StoryFn } from '@storybook/react';
import Button from './button';

export default {
title: 'Components/Button',
component: Button,
} as Meta<typeof Button>;

const Template: StoryFn<typeof Button> = (args) => <Button {...args} />;

export const Primary = Template.bind({});
Primary.args = {
label: 'Удалить',
color: 'filled',
};

export const Secondary = Template.bind({});
Secondary.args = {
label: 'Мои Боты',
color: 'bordered',
};
21 changes: 21 additions & 0 deletions src/components/Button/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { ButtonProps } from './button.props';
import '../Text/index'
const Button: React.FC<ButtonProps> = ({ label, disabled = false, color = 'primary' }) => {
const baseStyles = 'px-4 py-2 font-headline-small rounded';
const filledStyles = 'bg-color-red text-white w-full max-w-lg h-14 p-4 rounded-2xl gap-4';
const borderedStyles = 'font-title-large text-white border-color-grey rounded-2xl w-44 h-16 p-4 gap-16 border-2';

const buttonStyles = color === 'filled' ? filledStyles : borderedStyles;

return (
<button
className={`${baseStyles} ${buttonStyles} ${disabled}`}
disabled={disabled}
>
{label}
</button>
);
};

export default Button;
1 change: 1 addition & 0 deletions src/stories/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
font-size: 16px;
padding: 12px 24px;
}

0 comments on commit 55bd340

Please sign in to comment.