Closed
Description
When creating more complex components that have lots of variations, the hover/auto-completion stops after a certain line. In the case below, both stop with the variation === 'danger'
line.
Note: I am not using any custom settings/regex for my implementation.
import * as React from 'react'
import ctl from '@netlify/classnames-template-literals'
interface IconButtonProps extends React.ComponentPropsWithoutRef<'button'> {
active?: boolean
variation?: 'primary' | 'danger' | 'contrast' | 'default'
}
const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
({ active, variation = 'primary', children, ...rest }, ref) => {
return (
<button
className={ctl(`
text-2xl disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:text-current duration-150 ease-linear focus:outline-none rounded-full p-1
${variation === 'default' && 'hover:bg-gray-200 dark:hover:bg-gray-700'}
${variation === 'primary' && 'hover:text-blue-500 hover:bg-blue-500/5'}
${
variation === 'primary' &&
active &&
'text-blue-500 bg-blue-500/5 cursor-default'
}
${variation === 'danger' && 'hover:text-red-500 hover:bg-red-500/5'}
${
variation === 'contrast' &&
'dark:text-gray-800 text-gray-300 dark:bg-gray-100 bg-gray-800 absolute bottom-2 right-2 z-10'
}
`)}
type="button"
{...rest}
>
{children}
</button>
)
}
)
export default IconButton
Metadata
Metadata
Assignees
Labels
No labels