From 937b96877a93206ac424cd1ad99b865676e1c567 Mon Sep 17 00:00:00 2001 From: Kristian Gjertsen Date: Sat, 14 Nov 2026 16:33:41 +0100 Subject: [PATCH 01/12] standardize AddToBuildButton component to include optional icon display --- .../components/DesktopComponentDetailPage.tsx | 17 +++-------------- .../src/components/buttons/AddToBuildButton.tsx | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/frontend/src/components/DesktopComponentDetailPage.tsx b/frontend/src/components/DesktopComponentDetailPage.tsx index 716032a..dd04b50 100644 --- a/frontend/src/components/DesktopComponentDetailPage.tsx +++ b/frontend/src/components/DesktopComponentDetailPage.tsx @@ -1,4 +1,4 @@ -import { Trash2, X } from "lucide-react"; +import { X } from "lucide-react"; import { useId, useState } from "react"; import { Link } from "react-router"; import type { PcPart } from "@/types/types"; @@ -8,14 +8,11 @@ import { getSpecifications, } from "@/utils/partSpecifications"; import AddToBuildButton from "./buttons/AddToBuildButton"; -import { useSelector } from "react-redux"; -import { selectIsPartInBuild } from "@/state/selectedPartsSlice"; export default function DesktopComponentDetailPage({ part }: { part: PcPart }) { const [expanded, setExpanded] = useState(false); const [failedImage, setFailedImage] = useState(""); const specificationsId = useId(); - const inBuild = useSelector((state) => selectIsPartInBuild(state, part)); const specifications = getSpecifications(part); const category = categories.find((item) => item.value === part.category)?.label ?? @@ -133,16 +130,8 @@ export default function DesktopComponentDetailPage({ part }: { part: PcPart }) { - {inBuild ? ( - + showIcon + /> diff --git a/frontend/src/components/buttons/AddToBuildButton.tsx b/frontend/src/components/buttons/AddToBuildButton.tsx index c4f1e18..ac8c76e 100644 --- a/frontend/src/components/buttons/AddToBuildButton.tsx +++ b/frontend/src/components/buttons/AddToBuildButton.tsx @@ -1,4 +1,4 @@ -import type { ReactNode } from "react"; +import { Trash2 } from "lucide-react"; import { useRef, useState } from "react"; import type { PcPart } from "@/types/types"; import { twMerge } from "tailwind-merge"; @@ -17,13 +17,13 @@ import { showNotification } from "@/state/notificationSlice"; type AddToBuildButtonProps = { part: PcPart; - children?: ReactNode; + showIcon?: boolean; className?: string; }; export default function AddToBuildButton({ part, - children, + showIcon = false, className, }: AddToBuildButtonProps) { const [showFeedback, setShowFeedback] = useState(false); @@ -102,7 +102,15 @@ export default function AddToBuildButton({ )} onClick={handleClick} > - {children ?? (inBuild ? "Remove from build" : "Add to build")} + {showIcon && + (inBuild ? ( +