From 1f8b8fd6026d6cadc87263406c98c9202e5874ba Mon Sep 17 00:00:00 2001 From: Nasreddine Bac Ali Date: Sun, 13 Mar 2022 12:36:23 +0100 Subject: [PATCH] feat: add Button group component --- public/images/button-group-dark.svg | 10 +++ public/images/button-group-light.svg | 10 +++ src/Root.tsx | 10 ++- src/components/Button.tsx | 19 +++- src/components/ButtonGroup.tsx | 29 +++++++ src/components/index.ts | 1 + src/pages/ButtonGroupPage.tsx | 124 +++++++++++++++++++++++++++ src/pages/DashboardPage.tsx | 6 ++ 8 files changed, 204 insertions(+), 5 deletions(-) create mode 100644 public/images/button-group-dark.svg create mode 100644 public/images/button-group-light.svg create mode 100644 src/components/ButtonGroup.tsx create mode 100644 src/pages/ButtonGroupPage.tsx diff --git a/public/images/button-group-dark.svg b/public/images/button-group-dark.svg new file mode 100644 index 000000000..930100393 --- /dev/null +++ b/public/images/button-group-dark.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/public/images/button-group-light.svg b/public/images/button-group-light.svg new file mode 100644 index 000000000..a2c301a83 --- /dev/null +++ b/public/images/button-group-light.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/Root.tsx b/src/Root.tsx index 50ef524a7..bd9842cdb 100644 --- a/src/Root.tsx +++ b/src/Root.tsx @@ -10,7 +10,7 @@ import { HiHome, HiMenuAlt1, } from 'react-icons/hi'; -import { BsGithub, BsImages } from 'react-icons/bs'; +import { BsCreditCard2FrontFill, BsGithub, BsImages } from 'react-icons/bs'; import { FaSpinner } from 'react-icons/fa'; import { Route, Routes } from 'react-router-dom'; @@ -22,6 +22,7 @@ const AccordionPage = lazy(() => import('./pages/AccordionPage')); const BadgesPage = lazy(() => import('./pages/BadgesPage')); const BreadcrumbPage = lazy(() => import('./pages/BreadcrumbPage')); const ButtonsPage = lazy(() => import('./pages/ButtonsPage')); +const ButtonGroupPage = lazy(() => import('./pages/ButtonGroupPage')); const CardPage = lazy(() => import('./pages/CardPage')); const CarouselPage = lazy(() => import('./pages/CarouselPage')); const SpinnersPage = lazy(() => import('./pages/SpinnersPage')); @@ -70,6 +71,12 @@ export const Root: FC = () => { { group: false, icon: HiDuplicate, + title: 'Button group', + href: '/button-group', + }, + { + group: false, + icon: BsCreditCard2FrontFill, title: 'Card', href: '/card', }, @@ -133,6 +140,7 @@ export const Root: FC = () => { } /> } /> } /> + } /> } /> } /> } /> diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 2131b971e..5cc37f313 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -12,6 +12,7 @@ type GradientDuoTone = | 'tealToLime' | 'redToYellow'; type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl'; +type PositionInGroup = 'start' | 'middle' | 'end'; export type ButtonProps = ComponentProps<'button'> & { pill?: boolean; @@ -22,6 +23,7 @@ export type ButtonProps = ComponentProps<'button'> & { icon?: FC>; gradientMonochrome?: GradientMonochrome; gradientDuoTone?: GradientDuoTone; + positionInGroup?: PositionInGroup; }; const colorClasses: Record = { @@ -88,6 +90,7 @@ const iconSizeClasses: Record = { export const Button: FC = ({ children, + className, pill, outline, disabled = false, @@ -96,30 +99,38 @@ export const Button: FC = ({ color = 'blue', gradientMonochrome, gradientDuoTone, + positionInGroup, ...props }) => { return ( + + + + ), + }, + { + title: 'Group buttons with icons', + code: ( + + + + + + ), + }, + { + title: 'All colors', + code: ( +
+ + + + + + + + + + + + + + + +
+ ), + }, + { + title: 'Outline', + code: ( +
+ + + + + + + + + + + + + + + +
+ ), + }, + { + title: 'Outline with icons', + code: ( +
+ + + + + + + + + + + + + + + +
+ ), + }, + ]; + + return ; +}; + +export default ButtonGroupPage; diff --git a/src/pages/DashboardPage.tsx b/src/pages/DashboardPage.tsx index 18051c460..b452f25dc 100644 --- a/src/pages/DashboardPage.tsx +++ b/src/pages/DashboardPage.tsx @@ -43,6 +43,12 @@ const DashboardPage: FC = () => { className: 'w-24', images: { light: 'buttons.svg', dark: 'buttons.svg' }, }, + { + title: 'Button group', + href: '/button-group', + className: 'w-56', + images: { light: 'button-group-light.svg', dark: 'button-group-dark.svg' }, + }, { title: 'Card', href: '/card',