From 2415da83d1719617b458a7c650188c12af41d3df Mon Sep 17 00:00:00 2001 From: George Desipris <73396808+desiprisg@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:22:27 +0200 Subject: [PATCH] feat(dashboard): Highlight selected step with border (#6869) --- .../components/workflow-editor/base-node.tsx | 11 ++- .../src/components/workflow-editor/nodes.tsx | 67 ++++++++++++------- 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/apps/dashboard/src/components/workflow-editor/base-node.tsx b/apps/dashboard/src/components/workflow-editor/base-node.tsx index 48c7ce32249..5ebfcb9a43a 100644 --- a/apps/dashboard/src/components/workflow-editor/base-node.tsx +++ b/apps/dashboard/src/components/workflow-editor/base-node.tsx @@ -92,7 +92,7 @@ export const NODE_WIDTH = 300; export const NODE_HEIGHT = 86; const nodeVariants = cva( - `relative border-neutral-alpha-200 bg-foreground-0 flex w-[300px] flex-col gap-1 border p-1 shadow-xs`, + `relative border-neutral-alpha-200 transition-colors aria-selected:border-primary bg-foreground-0 flex w-[300px] flex-col gap-1 border p-1 shadow-xs`, { variants: { variant: { @@ -108,6 +108,11 @@ const nodeVariants = cva( export interface BaseNodeProps extends React.HTMLAttributes, VariantProps {} -export const Node = ({ children, variant, className }: BaseNodeProps) => { - return
{children}
; +export const Node = (props: BaseNodeProps) => { + const { children, variant, className, ...rest } = props; + return ( +
+ {children} +
+ ); }; diff --git a/apps/dashboard/src/components/workflow-editor/nodes.tsx b/apps/dashboard/src/components/workflow-editor/nodes.tsx index 4c425279470..bf9ca35070a 100644 --- a/apps/dashboard/src/components/workflow-editor/nodes.tsx +++ b/apps/dashboard/src/components/workflow-editor/nodes.tsx @@ -1,6 +1,6 @@ import { Handle, Node as FlowNode, NodeProps, Position } from '@xyflow/react'; import { RiPlayCircleLine } from 'react-icons/ri'; -import { Link } from 'react-router-dom'; +import { Link, useParams } from 'react-router-dom'; import { STEP_TYPE_TO_COLOR } from '@/utils/color'; import { STEP_TYPE_TO_ICON } from '../icons/utils'; import { AddStepMenu } from './add-step-menu'; @@ -8,6 +8,8 @@ import { Node, NodeBody, NodeError, NodeHeader, NodeIcon, NodeName } from './bas import { StepTypeEnum } from '@/utils/enums'; import { useWorkflowEditorContext } from './hooks'; import { buildRoute, ROUTES } from '@/utils/routes'; +import { ComponentProps } from 'react'; +import { cn } from '@/utils/ui'; export type NodeData = { name?: string; @@ -41,12 +43,22 @@ export const TriggerNode = (_props: NodeProps) => { ); }; +type StepNodeProps = ComponentProps & { data: NodeData }; +const StepNode = (props: StepNodeProps) => { + const { className, data, ...rest } = props; + const { stepSlug } = useParams<{ + stepSlug: string; + }>(); + + return ; +}; + export const EmailNode = ({ data }: NodeProps) => { const Icon = STEP_TYPE_TO_ICON[StepTypeEnum.EMAIL]; return ( - + @@ -57,17 +69,18 @@ export const EmailNode = ({ data }: NodeProps) => { {data.error && {data.error}} - + ); }; -export const SmsNode = ({ data }: NodeProps) => { +export const SmsNode = (props: NodeProps) => { + const { data } = props; const Icon = STEP_TYPE_TO_ICON[StepTypeEnum.SMS]; return ( - + @@ -78,17 +91,18 @@ export const SmsNode = ({ data }: NodeProps) => { {data.error && {data.error}} - + ); }; -export const InAppNode = ({ data }: NodeProps) => { +export const InAppNode = (props: NodeProps) => { + const { data } = props; const Icon = STEP_TYPE_TO_ICON[StepTypeEnum.IN_APP]; return ( - + @@ -99,17 +113,18 @@ export const InAppNode = ({ data }: NodeProps) => { {data.error && {data.error}} - + ); }; -export const PushNode = ({ data }: NodeProps) => { +export const PushNode = (props: NodeProps) => { + const { data } = props; const Icon = STEP_TYPE_TO_ICON[StepTypeEnum.PUSH]; return ( - + @@ -120,17 +135,18 @@ export const PushNode = ({ data }: NodeProps) => { {data.error && {data.error}} - + ); }; -export const ChatNode = ({ data }: NodeProps) => { +export const ChatNode = (props: NodeProps) => { + const { data } = props; const Icon = STEP_TYPE_TO_ICON[StepTypeEnum.CHAT]; return ( - + @@ -141,16 +157,17 @@ export const ChatNode = ({ data }: NodeProps) => { {data.error && {data.error}} - + ); }; -export const DelayNode = ({ data }: NodeProps) => { +export const DelayNode = (props: NodeProps) => { + const { data } = props; const Icon = STEP_TYPE_TO_ICON[StepTypeEnum.DELAY]; return ( - + @@ -160,15 +177,16 @@ export const DelayNode = ({ data }: NodeProps) => { {data.content || 'You have been invited to the Novu party on "commentSnippet"'} - + ); }; -export const DigestNode = ({ data }: NodeProps) => { +export const DigestNode = (props: NodeProps) => { + const { data } = props; const Icon = STEP_TYPE_TO_ICON[StepTypeEnum.DIGEST]; return ( - + @@ -180,15 +198,16 @@ export const DigestNode = ({ data }: NodeProps) => { - + ); }; -export const CustomNode = ({ data }: NodeProps) => { +export const CustomNode = (props: NodeProps) => { + const { data } = props; const Icon = STEP_TYPE_TO_ICON[StepTypeEnum.CUSTOM]; return ( - + @@ -198,7 +217,7 @@ export const CustomNode = ({ data }: NodeProps) => { Executes the business logic in your bridge application - + ); };