diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 1b5b56fa3..a9a4f3e1d 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -1,5 +1,6 @@ import { ComponentProps, FC } from 'react'; import classNames from 'classnames'; +import { Spinner } from './Spinner'; type Color = 'blue' | 'alternative' | 'dark' | 'light' | 'green' | 'red' | 'yellow' | 'purple'; type GradientMonochrome = 'blue' | 'green' | 'cyan' | 'teal' | 'lime' | 'red' | 'pink' | 'purple'; @@ -11,28 +12,36 @@ type GradientDuoTone = | 'pinkToOrange' | 'tealToLime' | 'redToYellow'; - +type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl'; +type IconPosition = 'start' | 'end'; export type ButtonProps = ComponentProps<'button'> & { pill?: boolean; outline?: boolean; + loader?: boolean; + iconButton?: boolean; + label?: string; color?: Color; + size?: Size; + icon?: FC>; + iconPosition?: IconPosition; gradientMonochrome?: GradientMonochrome; gradientDuoTone?: GradientDuoTone; }; const colorClasses: Record = { - blue: 'text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800', + blue: 'text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 disabled:hover:bg-blue-700 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 dark:disabled:hover:bg-blue-600', alternative: - 'text-gray-900 bg-white border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:ring-blue-700 focus:text-blue-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 focus:ring-2', - dark: 'text-white bg-gray-800 hover:bg-gray-900 focus:ring-4 focus:ring-gray-300 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-800 dark:border-gray-700', + 'text-gray-900 bg-white border border-gray-200 hover:bg-gray-100 hover:text-blue-700 disabled:hover:bg-white focus:ring-blue-700 focus:text-blue-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 focus:ring-2 dark:disabled:hover:bg-gray-800', + dark: 'text-white bg-gray-800 hover:bg-gray-900 focus:ring-4 focus:ring-gray-300 disabled:hover:bg-gray-800 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-800 dark:border-gray-700 dark:disabled:hover:bg-gray-800', light: - 'text-gray-900 bg-white border border-gray-300 hover:bg-gray-100 focus:ring-4 focus:ring-blue-300 dark:bg-gray-600 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-700 dark:focus:ring-gray-800', + 'text-gray-900 bg-white border border-gray-300 hover:bg-gray-100 focus:ring-4 focus:ring-blue-300 disabled:hover:bg-white dark:bg-gray-600 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-700 dark:focus:ring-gray-800 dark:disabled:hover:bg-gray-600', green: - 'text-white bg-green-700 hover:bg-green-800 focus:ring-4 focus:ring-green-300 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800', - red: 'text-white bg-red-700 hover:bg-red-800 focus:ring-4 focus:ring-red-300 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900', - yellow: 'text-white bg-yellow-400 hover:bg-yellow-500 focus:ring-4 focus:ring-yellow-300 dark:focus:ring-yellow-900', + 'text-white bg-green-700 hover:bg-green-800 focus:ring-4 focus:ring-green-300 disabled:hover:bg-green-700 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800 dark:disabled:hover:bg-green-600', + red: 'text-white bg-red-700 hover:bg-red-800 focus:ring-4 focus:ring-red-300 disabled:hover:bg-red-800 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900 dark:disabled:hover:bg-red-600', + yellow: + 'text-white bg-yellow-400 hover:bg-yellow-500 focus:ring-4 focus:ring-yellow-300 disabled:hover:bg-yellow-400 dark:focus:ring-yellow-900 dark:disabled:hover:bg-yellow-400', purple: - 'text-white bg-purple-700 hover:bg-purple-800 focus:ring-4 focus:ring-purple-300 dark:bg-purple-600 dark:hover:bg-purple-700 dark:focus:ring-purple-900', + 'text-white bg-purple-700 hover:bg-purple-800 focus:ring-4 focus:ring-purple-300 disabled:hover:bg-purple-700 dark:bg-purple-600 dark:hover:bg-purple-700 dark:focus:ring-purple-900 dark:disabled:hover:bg-purple-600', }; const gradientMonochromeClasses: Record = { @@ -65,10 +74,41 @@ const gradientDuoToneClasses: Record = { 'text-gray-900 bg-gradient-to-r from-red-200 via-red-300 to-yellow-200 hover:bg-gradient-to-bl focus:ring-4 focus:ring-red-100 dark:focus:ring-red-400', }; +const sizeClasses: Record = { + xs: 'text-xs px-2 py-1', + sm: 'text-sm px-3 py-1.5', + md: 'text-sm px-4 py-2', + lg: 'text-base px-5 py-2.5', + xl: 'text-base px-6 py-3', +}; + +const iconSizeClasses: Record = { + xs: '!px-1', + sm: '!px-1.5', + md: '!px-2', + lg: '!p-2.5', + xl: '!p-3', +}; + +const previousSize: Record = { + xs: 'xs', + sm: 'xs', + md: 'sm', + lg: 'md', + xl: 'lg', +}; + export const Button: FC = ({ children, pill, outline, + disabled = false, + loader = false, + iconButton = false, + label, + size = 'md', + icon: Icon, + iconPosition = 'start', color = 'blue', gradientMonochrome, gradientDuoTone, @@ -76,24 +116,47 @@ export const Button: FC = ({ }) => { return ( ); }; diff --git a/src/components/Spinner.tsx b/src/components/Spinner.tsx index 94a8fdd74..0a65def24 100644 --- a/src/components/Spinner.tsx +++ b/src/components/Spinner.tsx @@ -2,7 +2,7 @@ import { FC } from 'react'; import classNames from 'classnames'; type Color = 'blue' | 'gray' | 'green' | 'red' | 'yellow' | 'pink' | 'purple'; -type Size = 'xs' | 'sm' | 'md' | 'lg'; +type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl'; export type SpinnerProps = { color?: Color; @@ -20,10 +20,11 @@ const colorClasses: Record = { }; const sizeClasses: Record = { - xs: 'w-4 h-4', - sm: 'w-6 h-6', - md: 'w-8 h-8', - lg: 'w-10 h-10', + xs: 'w-3 h-3', + sm: 'w-4 h-4', + md: 'w-6 h-6', + lg: 'w-8 h-8', + xl: 'w-10 h-10', }; export const Spinner: FC = ({ color = 'blue', size = 'md' }) => ( diff --git a/src/pages/ButtonsPage.tsx b/src/pages/ButtonsPage.tsx index 4d43361f8..9ffaaa7d1 100644 --- a/src/pages/ButtonsPage.tsx +++ b/src/pages/ButtonsPage.tsx @@ -3,6 +3,7 @@ import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'; import { dracula } from 'react-syntax-highlighter/dist/esm/styles/prism'; import tsx from 'react-syntax-highlighter/dist/esm/languages/prism/tsx'; import { Button, Card } from '../components'; +import { HiOutlineArrowRight, HiShoppingCart } from 'react-icons/hi'; SyntaxHighlighter.registerLanguage('tsx', tsx); @@ -133,7 +134,7 @@ const ButtonsPage: FC = () => {
Outline -
+
@@ -165,7 +166,109 @@ const ButtonsPage: FC = () => { - +`.trim()} + + +
+
+ Button sizes + +
+ + + + + +
+ + {` + + + + + +`.trim()} + +
+
+
+ Buttons with icon + +
+ + +
+ + {` + + +`.trim()} + +
+
+
+ Button with label + +
+ +
+ + {` + +`.trim()} + +
+
+
+ Icon buttons + +
+
+ + {` +
+
+ Loader + +
+ + +
+ + {` + + +`.trim()} + +
+
+
+ Disabled + +
+ +
+ + {` + + `.trim()}
diff --git a/src/pages/SpinnersPage.tsx b/src/pages/SpinnersPage.tsx index fa2a163be..92d0799d2 100644 --- a/src/pages/SpinnersPage.tsx +++ b/src/pages/SpinnersPage.tsx @@ -52,6 +52,7 @@ const SpinnersPage: FC = () => { +
{` @@ -59,6 +60,7 @@ const SpinnersPage: FC = () => { + `.trim()}