From 859b72d634a0141dd0bd069d7749be04a5c1252d Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:48:29 -0300 Subject: [PATCH] fix: add colors to the templates and main page cards (#4497) * Add swatch colors * Implement new colors on templates modal * Implement new colors on main page * Removed hover icon color change on templates --------- Co-authored-by: Cristhian Zanforlin Lousa --- .../TemplateCardComponent/index.tsx | 28 +++++++++---------- .../pages/MainPage/components/grid/index.tsx | 10 ++++++- .../pages/MainPage/components/list/index.tsx | 15 ++++++++-- src/frontend/src/style/index.css | 8 ++++++ src/frontend/src/utils/styleUtils.ts | 9 ++++++ src/frontend/tailwind.config.mjs | 7 +++++ 6 files changed, 60 insertions(+), 17 deletions(-) diff --git a/src/frontend/src/modals/templatesModal/components/TemplateCardComponent/index.tsx b/src/frontend/src/modals/templatesModal/components/TemplateCardComponent/index.tsx index 93b5bfa2f2d4..7bb54f4b1d81 100644 --- a/src/frontend/src/modals/templatesModal/components/TemplateCardComponent/index.tsx +++ b/src/frontend/src/modals/templatesModal/components/TemplateCardComponent/index.tsx @@ -1,5 +1,6 @@ import { convertTestName } from "@/components/storeCardComponent/utils/convert-test-name"; -import { BG_NOISE, flowGradients } from "@/utils/styleUtils"; +import { swatchColors } from "@/utils/styleUtils"; +import { cn } from "@/utils/utils"; import IconComponent, { ForwardedIconComponent, } from "../../../../components/genericIconComponent"; @@ -9,10 +10,11 @@ export default function TemplateCardComponent({ example, onClick, }: TemplateCardComponentProps) { - const directionIndex = - (example.gradient && example.gradient.split(",").length == 1 - ? example.gradient.length - : example.name.length) % flowGradients.length; + const swatchIndex = + (example.gradient && parseInt(example.gradient) + ? parseInt(example.gradient) + : (example.gradient?.length ?? example.name.length)) % + swatchColors.length; const handleKeyDown = (e) => { if (e.key === "Enter" || e.key === " ") { @@ -21,13 +23,6 @@ export default function TemplateCardComponent({ } }; - const bgGradient = - BG_NOISE + - "," + - (example.gradient && example.gradient.split(",").length > 1 - ? "linear-gradient(90deg, " + example.gradient + ")" - : flowGradients[directionIndex]); - return (
-
+
diff --git a/src/frontend/src/pages/MainPage/components/grid/index.tsx b/src/frontend/src/pages/MainPage/components/grid/index.tsx index 84d938280357..7a6f7d5f47c9 100644 --- a/src/frontend/src/pages/MainPage/components/grid/index.tsx +++ b/src/frontend/src/pages/MainPage/components/grid/index.tsx @@ -14,6 +14,8 @@ import useAlertStore from "@/stores/alertStore"; import useFlowsManagerStore from "@/stores/flowsManagerStore"; import { FlowType } from "@/types/flow"; import { getInputsAndOutputs } from "@/utils/storeUtils"; +import { swatchColors } from "@/utils/styleUtils"; +import { cn } from "@/utils/utils"; import { useState } from "react"; import { useParams } from "react-router-dom"; import useDescriptionModal from "../../oldComponents/componentsComponent/hooks/use-description-modal"; @@ -99,6 +101,12 @@ const GridComponent = ({ flowData }: { flowData: FlowType }) => { const { onDragStart } = useDragStart(flowData); + const swatchIndex = + (flowData.gradient && parseInt(flowData.gradient) + ? parseInt(flowData.gradient) + : (flowData.gradient?.length ?? flowData.name.length)) % + swatchColors.length; + return ( <> { }`} >
-
+