import React, { HTMLAttributes, useMemo } from 'react'; import { Colors } from '../colors'; export interface ButtonProps extends HTMLAttributes { type?: 'submit' | 'reset' | 'button'; htmlType?: string; mode?: 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'dark' | 'light'; disabled?: boolean; ghost?: boolean; color?: Colors; shape?: 'square' | 'pill'; outline?: boolean; loading?: boolean; spinner?: boolean; dropDown?: boolean; size?: 'large' | 'small' | 'default' value?: string; skeleton?: boolean; }; interface ButtonListProps extends HTMLAttributes { justify?: 'end' | 'center'; } const Button = ({ type = 'button', className, style, mode, disabled, color, ghost, shape, outline, dropDown, spinner, loading, size = 'default', children, value, skeleton, ...props }: ButtonProps) => { const classes = useMemo(() => { const getMode = () => { if (outline) { return `btn-outline-${mode}`; } if (ghost) { `btn-ghost-${mode}` } return `btn-${mode}` } const getSize = (s: string) => { switch (s) { case 'large': return 'btn-lg'; case 'small': return 'btn-sm'; case 'default': default: return ''; } } return [ 'btn', mode && getMode(), disabled && 'disabled cursor-not-allowed', color && `btn-${color}`, shape && `btn-${shape}`, getSize(size), loading && 'btn-loading', dropDown && 'dropdown-toggle', loading && `btn-loading`, skeleton && 'placeholder', className ].filter(Boolean).join(' '); }, [mode, disabled, color, shape, ghost, outline, className, size, loading]); return ( ) } export const ButtonList = ({ className, children, justify, ...props }: ButtonListProps) => (
{children}
) export const ButtonIcon = (props: ButtonProps) => ; export const FaceBookButton = (props: ButtonProps) =>