From 1621d53afa92db0d113a4a9bbc2e295d712a2652 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 6 Dec 2022 19:27:26 -0800 Subject: [PATCH] Fix SelectItem bug and lint warnings --- components/Button/index.tsx | 289 ++++++++++++++++---------------- components/Dialog/index.tsx | 2 +- components/Input/index.tsx | 43 ++--- components/SelectItem/index.tsx | 34 ++-- 4 files changed, 186 insertions(+), 182 deletions(-) diff --git a/components/Button/index.tsx b/components/Button/index.tsx index 2f48de7f..2e0fcea8 100644 --- a/components/Button/index.tsx +++ b/components/Button/index.tsx @@ -37,154 +37,151 @@ const defaultProps = { 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 Button = React.forwardRef(function button( + { 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 ( - // - // ) + 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 diff --git a/components/Dialog/index.tsx b/components/Dialog/index.tsx index 9683da38..2438a2ed 100644 --- a/components/Dialog/index.tsx +++ b/components/Dialog/index.tsx @@ -11,7 +11,7 @@ interface Props > {} export const DialogContent = React.forwardRef( - ({ children, ...props }, forwardedRef) => { + function dialog({ children, ...props }, forwardedRef) { const classes = classNames( { Dialog: true, diff --git a/components/Input/index.tsx b/components/Input/index.tsx index f96b990b..27d21315 100644 --- a/components/Input/index.tsx +++ b/components/Input/index.tsx @@ -11,27 +11,28 @@ interface Props label?: string } -const Input = React.forwardRef( - (props: Props, forwardedRef) => { - const classes = classNames({ Input: true }, props.className) +const Input = React.forwardRef(function input( + props: Props, + forwardedRef +) { + const classes = classNames({ Input: true }, props.className) - return ( - - ) - } -) + return ( + + ) +}) export default Input diff --git a/components/SelectItem/index.tsx b/components/SelectItem/index.tsx index 9bae53fe..5d3eb7c7 100644 --- a/components/SelectItem/index.tsx +++ b/components/SelectItem/index.tsx @@ -1,21 +1,27 @@ -import React from 'react' +import React, { ComponentProps } from 'react' import * as Select from '@radix-ui/react-select' import './index.scss' import classNames from 'classnames' -const SelectItem = React.forwardRef( - ({ children, className, ...props }, forwardedRef) => { - return ( - - {children} - - ) - } -) +interface Props extends ComponentProps<'div'> { + value: string | number +} + +const SelectItem = React.forwardRef(function selectItem( + { children, ...props }, + forwardedRef +) { + return ( + + {children} + + ) +}) export default SelectItem