Skip to content
This repository was archived by the owner on Feb 25, 2024. It is now read-only.

Commit cd7eb85

Browse files
authored
Merge pull request #338 from riccardo-forina/description
Show the description property for both nodes and transitions
2 parents 259fb02 + 196e44d commit cd7eb85

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

.changeset/real-seas-yawn.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'xstate-viz-app': minor
3+
---
4+
5+
You can now visualize descriptions added directly to state nodes and transitions

src/StateNodeViz.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export const StateNodeViz: React.FC<{
8282
return null;
8383
}
8484

85+
const description = stateNode.description || stateNode.meta?.description;
86+
8587
return (
8688
<div
8789
data-viz="stateNodeGroup"
@@ -166,14 +168,14 @@ export const StateNodeViz: React.FC<{
166168
})}
167169
</div>
168170
)}
169-
{stateNode.meta?.description && (
171+
{description && (
170172
<div data-viz="stateNode-meta">
171173
<ReactMarkdown
172174
components={{
173175
a: ({ node, ...props }) => <Link {...props} />,
174176
}}
175177
>
176-
{stateNode.meta.description}
178+
{description}
177179
</ReactMarkdown>
178180
</div>
179181
)}

src/TransitionViz.scss

+14
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,17 @@
7272
}
7373
padding: 0rem 0.5rem 0.5rem;
7474
}
75+
76+
[data-viz='transition-description'] {
77+
&:empty {
78+
display: none;
79+
}
80+
border-top: 2px solid var(--chakra-colors-whiteAlpha-300);
81+
padding: 0.5rem;
82+
min-width: max-content;
83+
font-size: var(--chakra-fontSizes-sm);
84+
text-align: left;
85+
> p {
86+
max-width: 10rem;
87+
}
88+
}

src/TransitionViz.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ export const TransitionViz: React.FC<{
165165
</div>
166166
)}
167167
</div>
168+
{definition.description && (
169+
<div data-viz="transition-description">
170+
<p>{definition.description}</p>
171+
</div>
172+
)}
168173
</button>
169174
);
170175
};

0 commit comments

Comments
 (0)