* Tweak toaster look and feel * Add icons, tweak plus icon names * Rename commandBarMeta to commandBarConfig * Refactor command bar, add support for icons * Create a tailwind plugin for aria-pressed button state * Remove overlay from behind command bar * Clean up toolbar * Button and other style tweaks * Icon tweaks follow-up: make old icons work with new sizing * Delete unused static icons * More CSS tweaks * Small CSS tweak to project sidebar * Add command bar E2E test * fumpt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix typo in a comment * Fix icon padding (built version only) * Update onboarding and warning banner icons padding * Misc minor style fixes --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import {
|
|
IconDefinition as SolidIconDefinition,
|
|
faCircleExclamation,
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
import { IconDefinition as BrandIconDefinition } from '@fortawesome/free-brands-svg-icons'
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
import { CustomIcon, CustomIconName } from './CustomIcon'
|
|
|
|
const iconSizes = {
|
|
xs: 12,
|
|
sm: 14,
|
|
md: 20,
|
|
lg: 24,
|
|
}
|
|
|
|
export interface ActionIconProps extends React.PropsWithChildren {
|
|
icon?: SolidIconDefinition | BrandIconDefinition | CustomIconName
|
|
className?: string
|
|
bgClassName?: string
|
|
iconClassName?: string
|
|
size?: keyof typeof iconSizes
|
|
}
|
|
|
|
export const ActionIcon = ({
|
|
icon = faCircleExclamation,
|
|
className,
|
|
bgClassName,
|
|
iconClassName,
|
|
size = 'md',
|
|
children,
|
|
}: ActionIconProps) => {
|
|
// By default, we reverse the icon color and background color in dark mode
|
|
const computedIconClassName = `h-auto dark:text-energy-10 !group-disabled:text-chalkboard-60 !group-disabled:text-chalkboard-60 ${iconClassName}`
|
|
|
|
const computedBgClassName = `bg-chalkboard-20 dark:bg-chalkboard-90 !group-disabled:bg-chalkboard-30 !dark:group-disabled:bg-chalkboard-80 ${bgClassName}`
|
|
|
|
return (
|
|
<div
|
|
className={
|
|
`w-fit inline-grid place-content-center ${className} ` +
|
|
computedBgClassName
|
|
}
|
|
>
|
|
{children ? (
|
|
children
|
|
) : typeof icon === 'string' ? (
|
|
<CustomIcon
|
|
name={icon}
|
|
width={iconSizes[size]}
|
|
height={iconSizes[size]}
|
|
className={computedIconClassName}
|
|
/>
|
|
) : (
|
|
<FontAwesomeIcon
|
|
icon={icon}
|
|
width={iconSizes[size]}
|
|
height={iconSizes[size]}
|
|
className={computedIconClassName}
|
|
/>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|