diff --git a/web/src/app/icons/components/icon-search.tsx b/web/src/app/icons/components/icon-search.tsx index 8250b99b..14cc5b01 100644 --- a/web/src/app/icons/components/icon-search.tsx +++ b/web/src/app/icons/components/icon-search.tsx @@ -10,6 +10,7 @@ import Image from "next/image" import Link from "next/link" import { usePathname, useRouter, useSearchParams } from "next/navigation" import { useCallback, useEffect, useRef, useState } from "react" +import { useTheme } from "next-themes" export function IconSearch({ icons }: IconSearchProps) { const searchParams = useSearchParams() @@ -18,6 +19,7 @@ export function IconSearch({ icons }: IconSearchProps) { const pathname = usePathname() const [searchQuery, setSearchQuery] = useState(initialQuery ?? "") const timeoutRef = useRef(null) + const { resolvedTheme } = useTheme() const [filteredIcons, setFilteredIcons] = useState(() => { if (!initialQuery?.trim()) return icons @@ -79,6 +81,23 @@ export function IconSearch({ icons }: IconSearchProps) { } }, []) + // Helper function to get the appropriate icon variant based on theme + const getIconVariant = (name: string, data: any) => { + // Check if the icon has theme variants and use appropriate one + if (data.colors) { + // If in dark mode and a light variant exists, use the light variant + if (resolvedTheme === 'dark' && data.colors.light) { + return data.colors.light; + } + // If in light mode and a dark variant exists, use the dark variant + else if (resolvedTheme === 'light' && data.colors.dark) { + return data.colors.dark; + } + } + // Fall back to the default name if no appropriate variant + return name; + } + if (!searchParams) return null return ( @@ -133,7 +152,7 @@ export function IconSearch({ icons }: IconSearchProps) {
{`${name}>({}) + // Helper function to get the appropriate icon variant based on theme + const getIconVariant = (iconName: string) => { + // Check if the icon has theme variants + if (iconColorVariants) { + // If in dark mode and a light variant exists, use the light variant + if (resolvedTheme === 'dark' && iconColorVariants.light) { + return iconColorVariants.light; + } + // If in light mode and a dark variant exists, use the dark variant + else if (resolvedTheme === 'light' && iconColorVariants.dark) { + return iconColorVariants.dark; + } + } + // Fall back to the default name if no appropriate variant + return iconName; + } + const handleCopy = (url: string, variantKey: string) => { navigator.clipboard.writeText(url) setCopiedVariants((prev) => ({ @@ -168,7 +187,7 @@ export function IconDetails({ icon, iconData, authorData }: IconDetailsProps) {
{icon}Source