import React, { PropsWithChildren, useEffect, useState } from 'react' import classNames from 'classnames' import Link from 'next/link' import AddIcon from '~public/icons/Add.svg' import CheckIcon from '~public/icons/LargeCheck.svg' import CrossIcon from '~public/icons/Cross.svg' import EditIcon from '~public/icons/Edit.svg' import LinkIcon from '~public/icons/Link.svg' import MenuIcon from '~public/icons/Menu.svg' import SaveIcon from '~public/icons/Save.svg' import SettingsIcon from '~public/icons/Settings.svg' import './index.scss' import { ButtonType } from '~utils/enums' import { access } from 'fs' interface Props extends React.DetailedHTMLProps< React.ButtonHTMLAttributes, HTMLButtonElement > { accessoryIcon?: React.ReactNode active?: boolean blended?: boolean contained?: boolean size?: 'small' | 'medium' | 'large' text?: string } const defaultProps = { active: false, blended: false, contained: false, size: 'medium', } const Button = React.forwardRef( ( { accessoryIcon, active, blended, contained, size, text, ...props }, forwardedRef ) => { const classes = classNames( { Button: true, Active: active, Blended: blended, Contained: contained, // 'btn-pressed': pressed, // 'btn-disabled': disabled, // save: props.icon === 'save', // destructive: props.type == ButtonType.Destructive, }, size, props.className ) const hasAccessory = () => { if (accessoryIcon) return {accessoryIcon} } const hasText = () => { if (text) return {text} } return ( ) // useEffect(() => { // if (props.type) setButtonType(props.type) // }, [props.type]) // const addIcon = ( // // // // ) // const menuIcon = ( // // // // ) // const linkIcon = ( // // // // ) // const checkIcon = ( // // // // ) // const crossIcon = ( // // // // ) // const editIcon = ( // // // // ) // const saveIcon = ( // // // // ) // const settingsIcon = ( // // // // ) // function getIcon() { // let icon: React.ReactNode // switch (props.icon) { // case 'new': // icon = addIcon // break // case 'menu': // icon = menuIcon // break // case 'link': // icon = linkIcon // break // case 'check': // icon = checkIcon // break // case 'cross': // icon = crossIcon // break // case 'edit': // icon = editIcon // break // case 'save': // icon = saveIcon // break // case 'settings': // icon = settingsIcon // break // } // return icon // } // function handleMouseDown() { // setPressed(true) // } // function handleMouseUp() { // setPressed(false) // } // return ( // // ) } ) Button.defaultProps = defaultProps export default Button