add transparent icon color variant

This commit is contained in:
jeffvli
2026-05-12 21:43:27 -07:00
parent 984b85e0e9
commit 6e634972c9
2 changed files with 15 additions and 2 deletions
@@ -79,6 +79,10 @@ img.size-5xl {
color: rgb(255 49 49); color: rgb(255 49 49);
} }
.color-transparent {
color: transparent;
}
.fill { .fill {
fill: transparent; fill: transparent;
} }
@@ -123,6 +127,10 @@ img.size-5xl {
fill: rgb(255 49 49); fill: rgb(255 49 49);
} }
.fill-transparent {
fill: transparent;
}
.spin { .spin {
animation: spin 1s linear infinite; animation: spin 1s linear infinite;
} }
+7 -2
View File
@@ -35,6 +35,7 @@ import {
LuChevronLeft, LuChevronLeft,
LuChevronRight, LuChevronRight,
LuChevronUp, LuChevronUp,
LuCircle,
LuCircleCheck, LuCircleCheck,
LuCircleX, LuCircleX,
LuClipboardCopy, LuClipboardCopy,
@@ -247,6 +248,7 @@ export const AppIcon = {
brandSpotify: SpotifyLogoIcon, brandSpotify: SpotifyLogoIcon,
cache: LuCloudDownload, cache: LuCloudDownload,
check: LuCheck, check: LuCheck,
circle: LuCircle,
clipboardCopy: LuClipboardCopy, clipboardCopy: LuClipboardCopy,
collection: LuPackage2, collection: LuPackage2,
delete: LuTrash, delete: LuTrash,
@@ -384,6 +386,7 @@ type IconColor =
| 'muted' | 'muted'
| 'primary' | 'primary'
| 'success' | 'success'
| 'transparent'
| 'warn'; | 'warn';
const _Icon = forwardRef<HTMLDivElement, IconProps>((props, ref) => { const _Icon = forwardRef<HTMLDivElement, IconProps>((props, ref) => {
@@ -391,17 +394,19 @@ const _Icon = forwardRef<HTMLDivElement, IconProps>((props, ref) => {
const IconComponent: ComponentType<any> = AppIcon[icon]; const IconComponent: ComponentType<any> = AppIcon[icon];
const colorClassToken = color ?? (fill && fill !== 'transparent' ? fill : undefined);
const classNames = useMemo( const classNames = useMemo(
() => () =>
clsx(className, { clsx(className, {
[styles.fill]: true, [styles.fill]: true,
[styles.pulse]: animate === 'pulse', [styles.pulse]: animate === 'pulse',
[styles.spin]: animate === 'spin', [styles.spin]: animate === 'spin',
[styles[`color-${color || fill}`]]: color || fill, [styles[`color-${colorClassToken}`]]: colorClassToken,
[styles[`fill-${fill}`]]: fill, [styles[`fill-${fill}`]]: fill,
[styles[`size-${size}`]]: true, [styles[`size-${size}`]]: true,
}), }),
[animate, className, color, fill, size], [animate, className, colorClassToken, fill, size],
); );
return ( return (