Skip to content

Commit 1389f36

Browse files
committed
feat: cleanup flow example diagram
1 parent b3d77b0 commit 1389f36

2 files changed

Lines changed: 19 additions & 27 deletions

File tree

src/components/nodes/NodeDisplay.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { StableBadge } from "@/components/ui/StableBadge"
44
import { Card, Flex, Text } from "@code0-tech/pictor"
55
import { IconNote, IconVariable } from "@tabler/icons-react"
6-
import type { ReactNode } from "react"
6+
import type { CSSProperties, ReactNode } from "react"
77

88
export type NodeSegmentType = "text" | "literal" | "reference" | "node"
99
export type NodeAccent = "brand" | "yellow" | "aqua" | "blue" | "pink" | "lime" | "magenta"
@@ -78,9 +78,21 @@ function NodeMessage({ segments }: { segments: NodeSegment[] }) {
7878
})
7979
}
8080

81-
export function NodeDisplay({ node }: { node: NodeItem }) {
81+
export function NodeDisplay({ node, animatedOutline = false }: { node: NodeItem; animatedOutline?: boolean }) {
8282
return (
83-
<Card paddingSize="xs" py="0.35" borderColor="info" color="primary" outline={node.outline}>
83+
<Card
84+
paddingSize="xs"
85+
py="0.35"
86+
borderColor="info"
87+
color="primary"
88+
outline={node.outline}
89+
className={
90+
animatedOutline && node.outline
91+
? "after:pointer-events-none after:absolute after:-inset-[calc(var(--padding)/3)] after:rounded-[calc(1rem+var(--padding)/3)] after:border after:border-[var(--node-accent-color)] after:opacity-[var(--node-accent-opacity,0)]"
92+
: undefined
93+
}
94+
style={{ "--node-accent-color": ICON_COLOR_MAP[node.color] } as CSSProperties}
95+
>
8496
<Flex align="center" style={{ gap: "0.7rem" }}>
8597
<span className="flex size-4 shrink-0 items-center justify-center [&>svg]:size-4" style={{ color: ICON_COLOR_MAP[node.color] }}>
8698
{node.icon ?? <IconNote size={16} />}

src/components/sections/client/FlowExampleDiagram.tsx

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ export function FlowExampleDiagram({ trigger, items }: { trigger: FlowDiagramNod
7777
className="relative isolate rounded-2xl"
7878
animate={
7979
reducedMotion
80-
? { scale: 1 }
80+
? { "--node-accent-opacity": 0.45 }
8181
: {
82-
scale: [1, 1, 1.012, 1, 1, 1, 1],
82+
"--node-accent-opacity": [0, 0, 0.8, 0.45, 0.45, 0, 0],
8383
}
8484
}
8585
transition={{
@@ -89,26 +89,6 @@ export function FlowExampleDiagram({ trigger, items }: { trigger: FlowDiagramNod
8989
times: [0, arrivalTime, arrivalPeakTime, arrivalSettleTime, resetStartTime, resetEndTime, 1],
9090
}}
9191
>
92-
<motion.div
93-
aria-hidden="true"
94-
className="pointer-events-none absolute inset-0 z-0 rounded-[inherit]"
95-
style={{
96-
boxShadow: `0 0 0 1px color-mix(in srgb, ${getNodeAccentColor(node.node.color)} 24%, transparent), 0 0 14px color-mix(in srgb, ${getNodeAccentColor(node.node.color)} 22%, transparent)`,
97-
}}
98-
animate={
99-
reducedMotion
100-
? { opacity: 0.45 }
101-
: {
102-
opacity: [0, 0, 0.75, 0.45, 0.45, 0, 0],
103-
}
104-
}
105-
transition={{
106-
duration: reducedMotion ? 0 : cycleDuration,
107-
repeat: reducedMotion ? 0 : Infinity,
108-
ease: "linear",
109-
times: [0, arrivalTime, arrivalPeakTime, arrivalSettleTime, resetStartTime, resetEndTime, 1],
110-
}}
111-
/>
11292
<motion.div
11393
aria-hidden="true"
11494
className="pointer-events-none absolute -inset-2 z-0 rounded-3xl blur-xl"
@@ -117,7 +97,7 @@ export function FlowExampleDiagram({ trigger, items }: { trigger: FlowDiagramNod
11797
reducedMotion
11898
? { opacity: 0.08 }
11999
: {
120-
opacity: [0, 0, 0.14, 0.08, 0.08, 0, 0],
100+
opacity: [0, 0, 0.1, 0.05, 0.05, 0, 0],
121101
}
122102
}
123103
transition={{
@@ -128,7 +108,7 @@ export function FlowExampleDiagram({ trigger, items }: { trigger: FlowDiagramNod
128108
}}
129109
/>
130110
<div className="relative z-10">
131-
<NodeDisplay node={node.node} />
111+
<NodeDisplay node={node.node} animatedOutline />
132112
</div>
133113
</motion.div>
134114
)}

0 commit comments

Comments
 (0)