diff --git a/app/converters/json-yaml/page.tsx b/app/converters/json-yaml/page.tsx index 4a51283..e026b85 100644 --- a/app/converters/json-yaml/page.tsx +++ b/app/converters/json-yaml/page.tsx @@ -83,11 +83,9 @@ export default function Page() { const onJsonChange: EditorProps["onChange"] = value => setJsonReactively(value ?? ""); const onYamlChange: EditorProps["onChange"] = value => setYamlReactively(value ?? ""); - const indentationIcon = useMemo(() => , []); - const indentationConfig = ( } title="Indentation" control={ @@ -66,7 +64,7 @@ export default function Page() { } /> ), - [indentation, indentationIcon] + [indentation] ); const inputPasteButton = useMemo(() => , []); diff --git a/app/generators/hash/page.tsx b/app/generators/hash/page.tsx index c96ee18..6ad3ed1 100644 --- a/app/generators/hash/page.tsx +++ b/app/generators/hash/page.tsx @@ -37,12 +37,10 @@ export default function Page() { const onInputChange: TextareaProps["onChange"] = ({ currentTarget: { value } }) => setInput(value); - const uppercaseIcon = useMemo(() => , []); - const uppercaseConfig = useMemo( () => ( } title="Uppercase" control={ ), - [uppercase, uppercaseIcon] + [uppercase] ); const inputPasteButton = useMemo(() => , []); diff --git a/app/settings/page.tsx b/app/settings/page.tsx index f296370..537932e 100644 --- a/app/settings/page.tsx +++ b/app/settings/page.tsx @@ -20,12 +20,10 @@ import { PageSection } from "@/components/page-section"; export default function Page() { const { theme = "system", setTheme } = useTheme(); - const appThemeIcon = useMemo(() => , []); - const appThemeConfig = useMemo( () => ( } title="App theme" description="Select which app theme to display" control={ @@ -45,7 +43,7 @@ export default function Page() { } /> ), - [appThemeIcon, setTheme, theme] + [setTheme, theme] ); return ( diff --git a/components/buttons/clear.tsx b/components/buttons/clear.tsx index d988fcd..40930eb 100644 --- a/components/buttons/clear.tsx +++ b/components/buttons/clear.tsx @@ -1,5 +1,3 @@ -import { useMemo } from "react"; - import { icons } from "@/components/icons"; import { BaseButton, BaseButtonProps } from "./base"; @@ -7,7 +5,5 @@ import { BaseButton, BaseButtonProps } from "./base"; export type ClearButtonProps = Omit; export function ClearButton({ iconOnly, ...props }: ClearButtonProps) { - const icon = useMemo(() => , []); - - return ; + return } {...{ iconOnly }} labelText="Clear" />; } diff --git a/components/buttons/copy.tsx b/components/buttons/copy.tsx index 5fc8a63..2f9c291 100644 --- a/components/buttons/copy.tsx +++ b/components/buttons/copy.tsx @@ -1,4 +1,4 @@ -import { useCallback, useMemo } from "react"; +import { useCallback } from "react"; import { icons } from "@/components/icons"; @@ -18,7 +18,12 @@ export function CopyButton({ text, iconOnly, ...props }: CopyButtonProps) { }); }, [text]); - const icon = useMemo(() => , []); - - return ; + return ( + } + {...{ iconOnly, onClick }} + labelText="Copy" + /> + ); } diff --git a/components/buttons/file.tsx b/components/buttons/file.tsx index df798ca..a2b0a26 100644 --- a/components/buttons/file.tsx +++ b/components/buttons/file.tsx @@ -1,4 +1,4 @@ -import { useCallback, useMemo, useRef } from "react"; +import { useCallback, useRef } from "react"; import { icons } from "@/components/icons"; @@ -55,11 +55,14 @@ export function FileButton({ [maxFileSizeMb, onFileRead] ); - const icon = useMemo(() => , []); - return ( <> - + } + {...{ iconOnly, onClick }} + labelText="Load a file" + /> ); diff --git a/components/buttons/paste.tsx b/components/buttons/paste.tsx index 881a381..1a2ac1c 100644 --- a/components/buttons/paste.tsx +++ b/components/buttons/paste.tsx @@ -1,4 +1,4 @@ -import { useCallback, useMemo } from "react"; +import { useCallback } from "react"; import { icons } from "@/components/icons"; @@ -21,7 +21,12 @@ export function PasteButton({ iconOnly, onClipboardRead, ...props }: PasteButton }); }, [onClipboardRead]); - const icon = useMemo(() => , []); - - return ; + return ( + } + {...{ iconOnly, onClick }} + labelText="Paste" + /> + ); } diff --git a/components/icons.tsx b/components/icons.tsx index bf5306d..1f2b65a 100644 --- a/components/icons.tsx +++ b/components/icons.tsx @@ -1,3 +1,4 @@ +import { memo, MemoExoticComponent } from "react"; import { AlignLeft, ArrowRightLeft, @@ -29,37 +30,38 @@ import { X, type Icon as LucideIcon, } from "lucide-react"; +import equal from "react-fast-compare"; -export type Icon = LucideIcon; +export type Icon = LucideIcon | MemoExoticComponent; export const icons = { - AlignLeft, - ArrowRightLeft, - Binary, - Braces, - CaseSensitive, - Check, - ChevronDown, - Clipboard, - Code: Code2, - Copy, - Equal, - File: FileIcon, - Fingerprint, - Hash, - Home, - Key, - Link: Link2, - PackagePlus, - Paintbrush: Paintbrush2, - Search, - Settings, - Settings2, - Space, - Sun: SunMedium, - Minus, - Moon, - X, + AlignLeft: memo(AlignLeft, equal), + ArrowRightLeft: memo(ArrowRightLeft, equal), + Binary: memo(Binary, equal), + Braces: memo(Braces, equal), + CaseSensitive: memo(CaseSensitive, equal), + Check: memo(Check, equal), + ChevronDown: memo(ChevronDown, equal), + Clipboard: memo(Clipboard, equal), + Code: memo(Code2, equal), + Copy: memo(Copy, equal), + Equal: memo(Equal, equal), + File: memo(FileIcon, equal), + Fingerprint: memo(Fingerprint, equal), + Hash: memo(Hash, equal), + Home: memo(Home, equal), + Key: memo(Key, equal), + Link: memo(Link2, equal), + PackagePlus: memo(PackagePlus, equal), + Paintbrush: memo(Paintbrush2, equal), + Search: memo(Search, equal), + Settings: memo(Settings, equal), + Settings2: memo(Settings2, equal), + Space: memo(Space, equal), + Sun: memo(SunMedium, equal), + Minus: memo(Minus, equal), + Moon: memo(Moon, equal), + X: memo(X, equal), GitHub: (props: LucideProps) => ( , []); - - const searchIcon = useMemo( - () => , - [] - ); - return (
diff --git a/components/sidebar/tool-group.tsx b/components/sidebar/tool-group.tsx index 77e869d..bad9fed 100644 --- a/components/sidebar/tool-group.tsx +++ b/components/sidebar/tool-group.tsx @@ -1,6 +1,6 @@ "use client"; -import { useCallback, useMemo, useRef } from "react"; +import { useCallback, useRef } from "react"; import { usePathname } from "next/navigation"; import * as Accordion from "@radix-ui/react-accordion"; @@ -20,11 +20,6 @@ export function ToolGroup({ Icon, title, href, tools, isOpend }: Props) { const onClick = useCallback(() => triggerRef.current?.click(), []); - const chevronIcon = useMemo( - () => , - [] - ); - return ( @@ -46,7 +41,7 @@ export function ToolGroup({ Icon, title, href, tools, isOpend }: Props) { className="absolute right-0 flex h-10 w-10 items-center justify-center rounded transition-all duration-0 hover:bg-accent [&[data-state=open]>svg]:rotate-180" aria-label="toggle open/close state of the tool group" > - {chevronIcon} +
diff --git a/components/sidebar/tool-link.tsx b/components/sidebar/tool-link.tsx index d36c542..a0e867e 100644 --- a/components/sidebar/tool-link.tsx +++ b/components/sidebar/tool-link.tsx @@ -1,6 +1,6 @@ "use client"; -import { memo, useMemo } from "react"; +import { memo } from "react"; import Link, { LinkProps } from "next/link"; import { Tool } from "@/config/tools"; @@ -13,8 +13,6 @@ type Props = Pick & }; function RawToolLink({ Icon, shortTitle: title, href, onClick, className, highlight }: Props) { - const icon = useMemo(() => , [Icon]); - return ( - {icon} + {title} diff --git a/components/theme-toggle.tsx b/components/theme-toggle.tsx index 5184d9a..b4dbe8d 100644 --- a/components/theme-toggle.tsx +++ b/components/theme-toggle.tsx @@ -1,6 +1,5 @@ "use client"; -import { useMemo } from "react"; import { useTheme } from "next-themes"; import { Button } from "@/components/ui/button"; @@ -9,27 +8,14 @@ import { icons } from "@/components/icons"; export function ThemeToggle() { const { resolvedTheme, setTheme } = useTheme(); - const sunIcon = useMemo( - () => ( - - ), - [] - ); - const moonIcon = useMemo( - () => ( - - ), - [] - ); - return ( );