Path: blob/1.0-develop/resources/scripts/components/elements/button/Button.tsx
10263 views
import React, { forwardRef } from 'react';1import classNames from 'classnames';2import { ButtonProps, Options } from '@/components/elements/button/types';3import styles from './style.module.css';45const Button = forwardRef<HTMLButtonElement, ButtonProps>(6({ children, shape, size, variant, className, ...rest }, ref) => {7return (8<button9ref={ref}10className={classNames(11styles.button,12styles.primary,13{14[styles.secondary]: variant === Options.Variant.Secondary,15[styles.square]: shape === Options.Shape.IconSquare,16[styles.small]: size === Options.Size.Small,17[styles.large]: size === Options.Size.Large,18},19className20)}21{...rest}22>23{children}24</button>25);26}27);2829const TextButton = forwardRef<HTMLButtonElement, ButtonProps>(({ className, ...props }, ref) => (30// @ts-expect-error not sure how to get this correct31<Button ref={ref} className={classNames(styles.text, className)} {...props} />32));3334const DangerButton = forwardRef<HTMLButtonElement, ButtonProps>(({ className, ...props }, ref) => (35// @ts-expect-error not sure how to get this correct36<Button ref={ref} className={classNames(styles.danger, className)} {...props} />37));3839const _Button = Object.assign(Button, {40Sizes: Options.Size,41Shapes: Options.Shape,42Variants: Options.Variant,43Text: TextButton,44Danger: DangerButton,45});4647export default _Button;484950