import { createStyles, makeStyles } from "@material-ui/styles" import React, { useState } from "react" import { colors } from "../styles/color" type IconButtonProps = { onClick: () => void ariaLabel: string testid: string } type ButtonProps = { ariaLabel: string testid: string primary?: boolean fullWidth?: boolean shadow?: boolean animation?: boolean } & React.AnchorHTMLAttributes const useIconButtonStyles = makeStyles( createStyles({ btn: { margin: "0", cursor: "pointer", lineHeight: "inherit", borderRadius: ".375rem", display: "inline-flex", alignItems: "center", justifyContent: "center", padding: ".5rem", TextOpacity: "1", transitionProperty: "background-color,color", transitionTimingFunction: "cubic-bezier(.4,0,.2,1)", transitionDuration: ".15s", color: colors.gray500, "&:hover": { color: colors.gray600, backgroundColor: colors.gray100, }, "&:focus": { color: colors.gray600, backgroundColor: colors.gray100, outline: 0, boxShadow: "0 0 0 4px rgba(164, 202, 254, 0.45)", }, }, }), ) const useTextButtonStyles = makeStyles( createStyles({ btn: { borderRadius: ".375rem", borderWidth: "0px", display: "inline-flex", alignItems: "center", justifyContent: "center", fontWeight: 600, fontSize: "1rem", lineHeight: "1.5rem", paddingTop: ".5rem", paddingBottom: ".5rem", paddingLeft: "1rem", paddingRight: "1rem", whiteSpace: "nowrap", transitionProperty: "background-color,border-color,color,opacity,transform", transitionTimingFunction: "cubic-bezier(.4,0,.2,1)", transitionDuration: ".15s", willChange: "opacity, transform", }, primary: { color: "#ffffff", background: colors.blue700, "&:hover": { background: colors.blue600, }, "&:focus": { background: colors.blue600, outline: 0, boxShadow: "0 0 0 2px rgba(164, 202, 254, 0.45)", }, }, secondary: { color: colors.gray700, "&:hover": { backgroundColor: colors.gray100, }, "&:focus": { backgroundColor: colors.gray100, outline: 0, boxShadow: "0 0 0 2px rgba(164, 202, 254, 0.45)", }, }, full: { width: "100%", }, shadow: { boxShadow: "0 1px 2px 0 rgba(0, 0, 0, 0.05)", }, show: { opacity: 1, transform: "scale(1)", }, hide: { opacity: 0, transform: "scale(0.95)", }, }), ) export const Button: React.FC = ({ ariaLabel, testid, primary, children, fullWidth, shadow, animation, ...extra }) => { const classes = useTextButtonStyles() const [show, setShow] = useState(false) React.useEffect(() => { setTimeout(() => setShow(true), 0) }, [classes]) let className = `${classes.btn} ${primary ? classes.primary : classes.secondary}` if (fullWidth) { className += " " + classes.full } if (shadow) { className += " " + classes.shadow } if (animation) { className += " " + (show ? classes.show : classes.hide) } return ( {children} ) } export const IconButton: React.FC = ({ onClick, ariaLabel, testid, children }) => { const classes = useIconButtonStyles() return ( ) } export const CloseIconButton: React.FC = (props) => { return ( ) } export const MoreIconButton: React.FC = (props) => { return ( ) }