cetirizine

An experimental matrix client written in reactjs utilizing tailwind and storybook
git clone git://archive.git.mtrnord.blog/MTRNord/cetirizine.git
Log | Files | Refs | README | LICENSE

button.tsx (1062B)


      1 import { FC, memo } from "react";
      2 import "./button.scss";
      3 
      4 type ButtonProps = {
      5     /**
      6      * The button type
      7      */
      8     type?: "button" | "submit" | "reset";
      9     /**
     10      * The button style
     11      */
     12     style?: "primary" | "secondary" | "abort";
     13     /**
     14      * The button onClick handler
     15      */
     16     onClick?: () => void;
     17     /**
     18      * The button Label
     19      */
     20     children: string
     21 
     22     /**
     23      * If the button is readonly
     24      */
     25     readonly: boolean
     26 };
     27 
     28 const Button: FC<ButtonProps> = memo(({ type = "button", style = "primary", onClick, children, readonly }: ButtonProps) => {
     29     if (style === "secondary") {
     30         return <button disabled={readonly} onClick={onClick} className="button secondary" type={type}>{children}</button>;
     31     } else if (style === "abort") {
     32         return <button disabled={readonly} onClick={onClick} className="button abort" type={type}>{children}</button>;
     33     } else {
     34         return <button disabled={readonly} onClick={onClick} className="button primary" type={type}>{children}</button>;
     35     }
     36 })
     37 export default Button;