/* -------------------------------------------------------------------------- */ /* Imports */ /* -------------------------------------------------------------------------- */ import React from "react"; import classNames from "classnames"; import { StyleType } from "core/_variants"; import * as btnEmphasis from "./_btnEmphasis"; import IconButton from "./IconButton"; /* -------------------------------------------------------------------------- */ /* Extention for component */ /* -------------------------------------------------------------------------- */ type ButtonExtentions = { Icon: React.FC<{ children: Required; className?: string; }>; }; /* -------------------------------------------------------------------------- */ /* Component props */ /* -------------------------------------------------------------------------- */ type ButtonProps = { defaultStyle?: boolean; emphasis?: StyleType | undefined; //Choose one of three variants of button. By default it will be "high" disabled?: boolean; } & Omit, "">; /* -------------------------------------------------------------------------- */ /* Component implementation */ /* -------------------------------------------------------------------------- */ export const Button: React.FC & ButtonExtentions = ({ defaultStyle = true, emphasis = "high", disabled = false, className, children, ...props }) => { const isOnlyIcon = children && React.isValidElement(children) && React.Children.only(children).type == IconButton; const padding = isOnlyIcon ? "px-2.5 py-2" : "px-4 py-2"; return ( ); }; Button.Icon = IconButton;