@principal-ai/subsystems-react 0.56.24 → 0.56.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/stories/Canvases/Subsystem/issuesFixtures.d.ts +4 -0
- package/dist/stories/Canvases/Subsystem/issuesFixtures.d.ts.map +1 -0
- package/dist/stories/Canvases/Subsystem/issuesFixtures.js +189 -0
- package/dist/stories/Canvases/Subsystem/issuesFixtures.js.map +1 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.d.ts +8 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.d.ts.map +1 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.js +103 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.js.map +1 -0
- package/dist/subsystem/C4ContainersPanel.d.ts +35 -0
- package/dist/subsystem/C4ContainersPanel.d.ts.map +1 -0
- package/dist/subsystem/C4ContainersPanel.js +165 -0
- package/dist/subsystem/C4ContainersPanel.js.map +1 -0
- package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
- package/dist/subsystem/C4NodeCard.js +10 -4
- package/dist/subsystem/C4NodeCard.js.map +1 -1
- package/dist/subsystem/C4ProjectionView.d.ts.map +1 -1
- package/dist/subsystem/C4ProjectionView.js +81 -27
- package/dist/subsystem/C4ProjectionView.js.map +1 -1
- package/dist/subsystem/C4SketchView.d.ts.map +1 -1
- package/dist/subsystem/C4SketchView.js +53 -34
- package/dist/subsystem/C4SketchView.js.map +1 -1
- package/dist/subsystem/DescriptionOverlay.d.ts +10 -2
- package/dist/subsystem/DescriptionOverlay.d.ts.map +1 -1
- package/dist/subsystem/DescriptionOverlay.js +4 -4
- package/dist/subsystem/DescriptionOverlay.js.map +1 -1
- package/dist/subsystem/DescriptionPreview.d.ts +31 -0
- package/dist/subsystem/DescriptionPreview.d.ts.map +1 -0
- package/dist/subsystem/DescriptionPreview.js +31 -0
- package/dist/subsystem/DescriptionPreview.js.map +1 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +3 -19
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4Sketch.d.ts.map +1 -1
- package/dist/subsystem/__fixtures__/c4Sketch.js +1 -0
- package/dist/subsystem/__fixtures__/c4Sketch.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts +27 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts.map +1 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.js +312 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.js.map +1 -0
- package/dist/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +777 -0
- package/dist/subsystem/__fixtures__/c4Sketches/openbot.json +886 -0
- package/dist/subsystem/c4Sketch.d.ts +12 -0
- package/dist/subsystem/c4Sketch.d.ts.map +1 -1
- package/dist/subsystem/c4Sketch.js +2 -1
- package/dist/subsystem/c4Sketch.js.map +1 -1
- package/dist/subsystem/containerCard.d.ts +3 -1
- package/dist/subsystem/containerCard.d.ts.map +1 -1
- package/dist/subsystem/containerCard.js +2 -2
- package/dist/subsystem/containerCard.js.map +1 -1
- package/dist/subsystem/techIcons/index.d.ts +3 -1
- package/dist/subsystem/techIcons/index.d.ts.map +1 -1
- package/dist/subsystem/techIcons/index.js +2 -2
- package/dist/subsystem/techIcons/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +10 -0
- package/src/stories/Canvases/C4/C4CardGrow.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Component.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Container.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Draft.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4NodeGallery.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Sketch.stories.tsx +56 -4
- package/src/stories/Canvases/C4/C4ToComponentDrill.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Transition.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/AnimatedProgression.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Appearance.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Basics.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Captures.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Constructs.stories.tsx +3 -7
- package/src/stories/Canvases/Subsystem/ConstructsEmbed.stories.tsx +27 -0
- package/src/stories/Canvases/Subsystem/ContainerFrames.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/CustomEntities.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Deprecated.stories.tsx +2 -100
- package/src/stories/Canvases/Subsystem/DeprecatedGraph.stories.tsx +124 -0
- package/src/stories/Canvases/Subsystem/DetailPanel.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Diagnostics.stories.tsx +1 -43
- package/src/stories/Canvases/Subsystem/DiagnosticsStates.stories.tsx +63 -0
- package/src/stories/Canvases/Subsystem/EdgeViews.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/FrameworkStereotype.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/GraphTitle.stories.tsx +1 -19
- package/src/stories/Canvases/Subsystem/GraphTitleGraph.stories.tsx +51 -0
- package/src/stories/Canvases/Subsystem/Issues.stories.tsx +3 -228
- package/src/stories/Canvases/Subsystem/IssuesList.stories.tsx +60 -0
- package/src/stories/Canvases/Subsystem/LayoutDirection.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/ModuleBadges.stories.tsx +3 -61
- package/src/stories/Canvases/Subsystem/ModuleBadgesNode.stories.tsx +81 -0
- package/src/stories/Canvases/Subsystem/ModulePathNesting.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Modules.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/NodeAnatomy.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Packages.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Presentation.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Processes.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Reorder.stories.tsx +3 -153
- package/src/stories/Canvases/Subsystem/ReorderPanel.stories.tsx +75 -0
- package/src/stories/Canvases/Subsystem/Scenarios.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Spotlights.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/StepEmphasis.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/StoreValueType.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/TrailAutoplay.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/TrailSidebarViews.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Trails.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/WorkspacePackageFrames.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/issuesFixtures.ts +192 -0
- package/src/stories/Canvases/Subsystem/reorderFixtures.tsx +125 -0
- package/src/subsystem/C4ContainersPanel.test.tsx +151 -0
- package/src/subsystem/C4ContainersPanel.tsx +315 -0
- package/src/subsystem/C4NodeCard.tsx +12 -4
- package/src/subsystem/C4ProjectionView.tsx +107 -37
- package/src/subsystem/C4SketchView.tsx +96 -74
- package/src/subsystem/DescriptionOverlay.test.tsx +2 -0
- package/src/subsystem/DescriptionOverlay.tsx +20 -5
- package/src/subsystem/DescriptionPreview.tsx +96 -0
- package/src/subsystem/SubsystemComponentGraph.sidebar.test.tsx +1 -1
- package/src/subsystem/SubsystemComponentGraph.tsx +14 -43
- package/src/subsystem/__fixtures__/c4Sketch.ts +2 -0
- package/src/subsystem/__fixtures__/c4SketchGallery.test.ts +65 -0
- package/src/subsystem/__fixtures__/c4SketchGallery.ts +351 -0
- package/src/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +777 -0
- package/src/subsystem/__fixtures__/c4Sketches/openbot.json +886 -0
- package/src/subsystem/c4Sketch.ts +13 -0
- package/src/subsystem/containerCard.tsx +4 -1
- package/src/subsystem/techIcons/index.tsx +11 -2
|
@@ -10,9 +10,13 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
10
10
|
import type { CSSProperties, ReactNode } from 'react';
|
|
11
11
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
12
12
|
import { PencilRuler } from 'lucide-react';
|
|
13
|
-
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
14
13
|
import { C4Graph } from './C4Graph';
|
|
14
|
+
import { C4ContainersPanel } from './C4ContainersPanel';
|
|
15
|
+
import { DescriptionOverlay } from './DescriptionOverlay';
|
|
16
|
+
import { DescriptionPreview } from './DescriptionPreview';
|
|
15
17
|
import { GraphWithSidebar } from './GraphWithSidebar';
|
|
18
|
+
import type { C4Component, C4Container } from './c4';
|
|
19
|
+
import { C4_SKETCH_DESCRIPTION_MAX } from './c4Sketch';
|
|
16
20
|
import type { C4Sketch } from './c4Sketch';
|
|
17
21
|
|
|
18
22
|
export interface C4SketchViewProps {
|
|
@@ -51,6 +55,25 @@ export function C4SketchView({
|
|
|
51
55
|
[onOpenContainerIdsChange, openContainerIds],
|
|
52
56
|
);
|
|
53
57
|
|
|
58
|
+
/** The container last activated from the sidebar — the camera target. */
|
|
59
|
+
const [focus, setFocus] = useState<{ id: string } | null>(null);
|
|
60
|
+
|
|
61
|
+
const containers = useMemo(() => {
|
|
62
|
+
const components = sketch.model.nodes.filter(
|
|
63
|
+
(node): node is C4Component => node.kind === 'component',
|
|
64
|
+
);
|
|
65
|
+
return sketch.model.nodes
|
|
66
|
+
.filter((node): node is C4Container => node.kind === 'container')
|
|
67
|
+
.map((container) => ({
|
|
68
|
+
container,
|
|
69
|
+
open: resolvedOpenIds.includes(container.id),
|
|
70
|
+
members: components.filter(
|
|
71
|
+
(component) =>
|
|
72
|
+
(component.container ?? component.parentId) === container.id,
|
|
73
|
+
),
|
|
74
|
+
}));
|
|
75
|
+
}, [sketch.model.nodes, resolvedOpenIds]);
|
|
76
|
+
|
|
54
77
|
const model = useMemo(
|
|
55
78
|
() => ({ ...sketch.model, openContainerIds: resolvedOpenIds }),
|
|
56
79
|
[resolvedOpenIds, sketch.model],
|
|
@@ -58,16 +81,18 @@ export function C4SketchView({
|
|
|
58
81
|
|
|
59
82
|
const toggleContainer = useCallback(
|
|
60
83
|
(id: string) => {
|
|
61
|
-
|
|
62
|
-
resolvedOpenIds.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
84
|
+
if (resolvedOpenIds.includes(id)) {
|
|
85
|
+
setOpenIds(resolvedOpenIds.filter((openId) => openId !== id));
|
|
86
|
+
setFocus((prev) => (prev?.id === id ? null : prev));
|
|
87
|
+
} else {
|
|
88
|
+
setOpenIds([...resolvedOpenIds, id].sort());
|
|
89
|
+
}
|
|
66
90
|
},
|
|
67
91
|
[resolvedOpenIds, setOpenIds],
|
|
68
92
|
);
|
|
69
93
|
|
|
70
94
|
const openAll = useCallback(() => {
|
|
95
|
+
setFocus(null);
|
|
71
96
|
setOpenIds(
|
|
72
97
|
sketch.model.nodes
|
|
73
98
|
.filter((node) => node.kind === 'container')
|
|
@@ -76,33 +101,48 @@ export function C4SketchView({
|
|
|
76
101
|
);
|
|
77
102
|
}, [setOpenIds, sketch.model.nodes]);
|
|
78
103
|
|
|
79
|
-
const collapseAll = useCallback(() =>
|
|
104
|
+
const collapseAll = useCallback(() => {
|
|
105
|
+
setFocus(null);
|
|
106
|
+
setOpenIds([]);
|
|
107
|
+
}, [setOpenIds]);
|
|
108
|
+
|
|
109
|
+
/** Row click: toggle the container's internals and frame it (dropdown). */
|
|
110
|
+
const activateContainer = useCallback(
|
|
111
|
+
(id: string) => {
|
|
112
|
+
if (resolvedOpenIds.includes(id)) {
|
|
113
|
+
setOpenIds(resolvedOpenIds.filter((openId) => openId !== id));
|
|
114
|
+
setFocus((prev) => (prev?.id === id ? null : prev));
|
|
115
|
+
} else {
|
|
116
|
+
setFocus({ id });
|
|
117
|
+
setOpenIds([...resolvedOpenIds, id].sort());
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
[resolvedOpenIds, setOpenIds],
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
/** Select-only row (no components to expand): just frame the container. */
|
|
124
|
+
const selectContainer = useCallback((id: string) => setFocus({ id }), []);
|
|
80
125
|
|
|
126
|
+
const [notesOpen, setNotesOpen] = useState(false);
|
|
127
|
+
const rawDescription = sketch.description?.trim();
|
|
128
|
+
// The store caps the authored description; trim defensively for other hosts.
|
|
129
|
+
const description =
|
|
130
|
+
rawDescription && rawDescription.length > C4_SKETCH_DESCRIPTION_MAX
|
|
131
|
+
? `${rawDescription.slice(0, C4_SKETCH_DESCRIPTION_MAX - 1)}…`
|
|
132
|
+
: rawDescription;
|
|
81
133
|
const notes = sketch.notes?.trim();
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
<IndustryMarkdownSlide
|
|
95
|
-
content={notes}
|
|
96
|
-
slideIdPrefix={`c4-sketch-notes-${sketch.id}`}
|
|
97
|
-
slideIndex={0}
|
|
98
|
-
isVisible={true}
|
|
99
|
-
theme={theme}
|
|
100
|
-
disableScroll={true}
|
|
101
|
-
disableBasePadding
|
|
102
|
-
enableKeyboardScrolling={false}
|
|
103
|
-
autoFocusOnVisible={false}
|
|
104
|
-
/>
|
|
105
|
-
</div>
|
|
134
|
+
// The short description owns the top-left slot; a legacy sketch with only
|
|
135
|
+
// notes falls back to a clamped preview of them.
|
|
136
|
+
const preview = description || notes;
|
|
137
|
+
const descriptionPanel = preview ? (
|
|
138
|
+
<DescriptionPreview
|
|
139
|
+
content={preview}
|
|
140
|
+
clamp={!description}
|
|
141
|
+
open={notesOpen}
|
|
142
|
+
onOpen={notes ? () => setNotesOpen(true) : undefined}
|
|
143
|
+
onClose={notes ? () => setNotesOpen(false) : undefined}
|
|
144
|
+
slideIdPrefix={`c4-sketch-description-${sketch.id}`}
|
|
145
|
+
/>
|
|
106
146
|
) : null;
|
|
107
147
|
|
|
108
148
|
return (
|
|
@@ -181,61 +221,43 @@ export function C4SketchView({
|
|
|
181
221
|
}}
|
|
182
222
|
>
|
|
183
223
|
{headerActions}
|
|
184
|
-
<button
|
|
185
|
-
type="button"
|
|
186
|
-
onClick={openAll}
|
|
187
|
-
style={smallButton(theme, { width: 132 })}
|
|
188
|
-
>
|
|
189
|
-
Open all
|
|
190
|
-
</button>
|
|
191
|
-
<button
|
|
192
|
-
type="button"
|
|
193
|
-
onClick={collapseAll}
|
|
194
|
-
style={smallButton(theme, { width: 132 })}
|
|
195
|
-
>
|
|
196
|
-
Collapse all
|
|
197
|
-
</button>
|
|
198
224
|
</div>
|
|
199
225
|
</header>
|
|
200
226
|
|
|
201
227
|
<div style={{ flex: 1, minHeight: 0 }}>
|
|
202
228
|
<GraphWithSidebar
|
|
203
|
-
hidden={!notes}
|
|
204
|
-
stretchHeader
|
|
205
229
|
defaultWidth={320}
|
|
206
230
|
minWidth={240}
|
|
207
231
|
maxWidth={480}
|
|
208
232
|
persistKey={persistKey ?? `c4-sketch-notes-${sketch.id}`}
|
|
209
|
-
header={
|
|
233
|
+
header={descriptionPanel}
|
|
234
|
+
sidebarBody={
|
|
235
|
+
<C4ContainersPanel
|
|
236
|
+
containers={containers}
|
|
237
|
+
activeId={focus?.id ?? null}
|
|
238
|
+
onActivate={activateContainer}
|
|
239
|
+
onSelect={selectContainer}
|
|
240
|
+
onOpenAll={openAll}
|
|
241
|
+
onCloseAll={collapseAll}
|
|
242
|
+
/>
|
|
243
|
+
}
|
|
210
244
|
>
|
|
211
|
-
|
|
245
|
+
{notes && notesOpen && (
|
|
246
|
+
<DescriptionOverlay
|
|
247
|
+
description={notes}
|
|
248
|
+
title="Overview"
|
|
249
|
+
ariaLabel="Sketch notes"
|
|
250
|
+
slideIdPrefix={`c4-sketch-notes-overlay-${sketch.id}`}
|
|
251
|
+
onClose={() => setNotesOpen(false)}
|
|
252
|
+
/>
|
|
253
|
+
)}
|
|
254
|
+
<C4Graph
|
|
255
|
+
model={model}
|
|
256
|
+
onToggleContainer={toggleContainer}
|
|
257
|
+
containerFocus={focus}
|
|
258
|
+
/>
|
|
212
259
|
</GraphWithSidebar>
|
|
213
260
|
</div>
|
|
214
261
|
</div>
|
|
215
262
|
);
|
|
216
263
|
}
|
|
217
|
-
|
|
218
|
-
function smallButton(
|
|
219
|
-
theme: ReturnType<typeof useTheme>['theme'],
|
|
220
|
-
opts: { width?: number } = {},
|
|
221
|
-
) {
|
|
222
|
-
return {
|
|
223
|
-
flexShrink: 0,
|
|
224
|
-
display: 'inline-flex',
|
|
225
|
-
alignItems: 'center',
|
|
226
|
-
justifyContent: 'center',
|
|
227
|
-
gap: 5,
|
|
228
|
-
...(opts.width ? { width: opts.width } : {}),
|
|
229
|
-
height: 34,
|
|
230
|
-
padding: '0 10px',
|
|
231
|
-
boxSizing: 'border-box',
|
|
232
|
-
whiteSpace: 'nowrap',
|
|
233
|
-
borderRadius: 6,
|
|
234
|
-
border: `1px solid ${theme.colors.border}`,
|
|
235
|
-
background: 'transparent',
|
|
236
|
-
color: theme.colors.textSecondary,
|
|
237
|
-
fontFamily: theme.fonts.body,
|
|
238
|
-
fontSize: theme.fontSizes[1],
|
|
239
|
-
cursor: 'pointer',
|
|
240
|
-
} as const;
|
|
241
|
-
}
|
|
@@ -57,12 +57,14 @@ describe('subsystem description overlay', () => {
|
|
|
57
57
|
expect(overlay.style.position).toBe('absolute');
|
|
58
58
|
expect(overlay.parentElement?.contains(view.getByLabelText('Resize sidebar'))).toBe(false);
|
|
59
59
|
expect(more.getAttribute('aria-expanded')).toBe('true');
|
|
60
|
+
expect(more.textContent).toBe('Close');
|
|
60
61
|
const close = view.getByRole('button', { name: 'Close description' });
|
|
61
62
|
expect(document.activeElement).toBe(close);
|
|
62
63
|
if (closeWithEscape) fireEvent.keyDown(close, { key: 'Escape' });
|
|
63
64
|
else fireEvent.click(close);
|
|
64
65
|
expect(view.queryByRole('dialog')).toBeNull();
|
|
65
66
|
expect(more.getAttribute('aria-expanded')).toBe('false');
|
|
67
|
+
expect(more.textContent).toBe('Show more');
|
|
66
68
|
expect(document.activeElement).toBe(more);
|
|
67
69
|
expect(view.getByText('Request flow')).toBeTruthy();
|
|
68
70
|
});
|
|
@@ -3,10 +3,25 @@ import { useTheme } from '@principal-ade/industry-theme';
|
|
|
3
3
|
import { X } from 'lucide-react';
|
|
4
4
|
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export interface DescriptionOverlayProps {
|
|
7
|
+
/** Full Markdown shown in the dialog. */
|
|
7
8
|
description: string;
|
|
8
9
|
onClose: () => void;
|
|
9
|
-
|
|
10
|
+
/** Dialog heading. Defaults to `Overview`. */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** Accessible name for the dialog. */
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
/** Prefix for the Markdown slide ids (keeps duplicate headings unique). */
|
|
15
|
+
slideIdPrefix?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function DescriptionOverlay({
|
|
19
|
+
description,
|
|
20
|
+
onClose,
|
|
21
|
+
title = 'Overview',
|
|
22
|
+
ariaLabel = 'Description',
|
|
23
|
+
slideIdPrefix = 'description-desc-overlay',
|
|
24
|
+
}: DescriptionOverlayProps) {
|
|
10
25
|
const { theme } = useTheme();
|
|
11
26
|
const closeRef = useRef<HTMLButtonElement>(null);
|
|
12
27
|
|
|
@@ -21,7 +36,7 @@ export function DescriptionOverlay({ description, onClose }: {
|
|
|
21
36
|
return (
|
|
22
37
|
<div
|
|
23
38
|
role="dialog"
|
|
24
|
-
aria-label=
|
|
39
|
+
aria-label={ariaLabel}
|
|
25
40
|
onKeyDown={(event) => {
|
|
26
41
|
if (event.key === 'Escape') {
|
|
27
42
|
event.stopPropagation();
|
|
@@ -54,7 +69,7 @@ export function DescriptionOverlay({ description, onClose }: {
|
|
|
54
69
|
textTransform: 'uppercase',
|
|
55
70
|
color: theme.colors.textSecondary,
|
|
56
71
|
}}>
|
|
57
|
-
|
|
72
|
+
{title}
|
|
58
73
|
</h3>
|
|
59
74
|
<button
|
|
60
75
|
ref={closeRef}
|
|
@@ -82,7 +97,7 @@ export function DescriptionOverlay({ description, onClose }: {
|
|
|
82
97
|
<div style={{ lineHeight: 1.7 }}>
|
|
83
98
|
<IndustryMarkdownSlide
|
|
84
99
|
content={description}
|
|
85
|
-
slideIdPrefix=
|
|
100
|
+
slideIdPrefix={slideIdPrefix}
|
|
86
101
|
slideIndex={0}
|
|
87
102
|
isVisible
|
|
88
103
|
theme={theme}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useTheme } from '@principal-ade/industry-theme';
|
|
2
|
+
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
3
|
+
|
|
4
|
+
export interface DescriptionPreviewProps {
|
|
5
|
+
/** The full Markdown document. */
|
|
6
|
+
content: string;
|
|
7
|
+
/** Open the full description overlay. Omit to hide the toggle. */
|
|
8
|
+
onOpen?: () => void;
|
|
9
|
+
/** Close the full description overlay. */
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
/** Whether the overlay is currently open (for `aria-expanded` and the label). */
|
|
12
|
+
open?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Clamp the preview to `clampLines`. Pass `false` when the content is
|
|
15
|
+
* already length-capped and should size the header by its own height.
|
|
16
|
+
*/
|
|
17
|
+
clamp?: boolean;
|
|
18
|
+
/** Visible lines before the clamp (only when `clamp` is true). */
|
|
19
|
+
clampLines?: number;
|
|
20
|
+
/** Prefix for the Markdown slide ids (keeps duplicate headings unique). */
|
|
21
|
+
slideIdPrefix?: string;
|
|
22
|
+
/** Link text while the overlay is closed. */
|
|
23
|
+
moreLabel?: string;
|
|
24
|
+
/** Link text while the overlay is open. */
|
|
25
|
+
lessLabel?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The top-of-sidebar description shared by the subsystem and C4 views:
|
|
30
|
+
* Markdown plus an optional `Show more` link that opens the full document in
|
|
31
|
+
* a `DescriptionOverlay` (and turns into `Close` while it is open).
|
|
32
|
+
*/
|
|
33
|
+
export function DescriptionPreview({
|
|
34
|
+
content,
|
|
35
|
+
onOpen,
|
|
36
|
+
onClose,
|
|
37
|
+
open = false,
|
|
38
|
+
clamp = true,
|
|
39
|
+
clampLines = 6,
|
|
40
|
+
slideIdPrefix = 'description-preview',
|
|
41
|
+
moreLabel = 'Show more',
|
|
42
|
+
lessLabel = 'Close',
|
|
43
|
+
}: DescriptionPreviewProps) {
|
|
44
|
+
const { theme } = useTheme();
|
|
45
|
+
return (
|
|
46
|
+
<div style={{ fontSize: theme.fontSizes[0], lineHeight: 1.5 }}>
|
|
47
|
+
<div
|
|
48
|
+
style={
|
|
49
|
+
clamp
|
|
50
|
+
? {
|
|
51
|
+
display: '-webkit-box',
|
|
52
|
+
WebkitBoxOrient: 'vertical',
|
|
53
|
+
WebkitLineClamp: clampLines,
|
|
54
|
+
maxHeight: `${clampLines * 1.5}em`,
|
|
55
|
+
overflow: 'hidden',
|
|
56
|
+
}
|
|
57
|
+
: undefined
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
<IndustryMarkdownSlide
|
|
61
|
+
content={content}
|
|
62
|
+
slideIdPrefix={slideIdPrefix}
|
|
63
|
+
slideIndex={0}
|
|
64
|
+
isVisible={true}
|
|
65
|
+
theme={theme}
|
|
66
|
+
disableScroll={true}
|
|
67
|
+
disableBasePadding
|
|
68
|
+
enableKeyboardScrolling={false}
|
|
69
|
+
autoFocusOnVisible={false}
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
{(onOpen || onClose) && (
|
|
73
|
+
<button
|
|
74
|
+
type="button"
|
|
75
|
+
aria-label={open ? 'Close description preview' : 'Read full description'}
|
|
76
|
+
aria-haspopup="dialog"
|
|
77
|
+
aria-expanded={open}
|
|
78
|
+
onClick={() => (open ? onClose?.() : onOpen?.())}
|
|
79
|
+
style={{
|
|
80
|
+
marginTop: 6,
|
|
81
|
+
padding: 0,
|
|
82
|
+
border: 'none',
|
|
83
|
+
background: 'transparent',
|
|
84
|
+
color: theme.colors.textSecondary,
|
|
85
|
+
fontFamily: theme.fonts.body,
|
|
86
|
+
fontSize: theme.fontSizes[0],
|
|
87
|
+
textDecoration: 'underline',
|
|
88
|
+
cursor: 'pointer',
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
{open ? lessLabel : moreLabel}
|
|
92
|
+
</button>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -69,7 +69,7 @@ describe('subsystem graph sidebar', () => {
|
|
|
69
69
|
expect(description.style.overflow).toBe('hidden');
|
|
70
70
|
expect(description.style.maxHeight).toBe('9em');
|
|
71
71
|
const more = body.querySelector('button[aria-label="Read full description"]');
|
|
72
|
-
expect(more?.textContent).toBe('
|
|
72
|
+
expect(more?.textContent).toBe('Show more');
|
|
73
73
|
expect(more?.getAttribute('aria-haspopup')).toBe('dialog');
|
|
74
74
|
expect(more?.getAttribute('aria-expanded')).toBe('false');
|
|
75
75
|
expect(body.querySelector('[role="dialog"]')).toBeNull();
|
|
@@ -33,7 +33,6 @@ import {
|
|
|
33
33
|
} from '@xyflow/react';
|
|
34
34
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
35
35
|
import { ArrowDown, ArrowRight, Boxes, Files, Route, Unlink, X } from 'lucide-react';
|
|
36
|
-
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
37
36
|
import {
|
|
38
37
|
buildSubsystemGraph,
|
|
39
38
|
deriveGraphEdges,
|
|
@@ -98,6 +97,7 @@ import type { DeclarationSymbolRef, SymbolInspection } from './symbolRefs';
|
|
|
98
97
|
import { FileDrawer, FILE_DRAWER_HEIGHT_MS } from './FileDrawer';
|
|
99
98
|
import { GraphWithSidebar } from './GraphWithSidebar';
|
|
100
99
|
import { DescriptionOverlay } from './DescriptionOverlay';
|
|
100
|
+
import { DescriptionPreview } from './DescriptionPreview';
|
|
101
101
|
import type { GraphSidebarTab } from './GraphSidebar';
|
|
102
102
|
import { TrailsPanel, TRAIL_PLAY_PAUSE_MS, TRAIL_HOVER_PREVIEW_MS } from './TrailsPanel';
|
|
103
103
|
import type { StepEmphasisMap } from './stepEmphasis';
|
|
@@ -2991,47 +2991,13 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
2991
2991
|
<>
|
|
2992
2992
|
{sidebarExtra}
|
|
2993
2993
|
{description && (
|
|
2994
|
-
<
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
}}>
|
|
3002
|
-
<IndustryMarkdownSlide
|
|
3003
|
-
content={description}
|
|
3004
|
-
slideIdPrefix="subsystem-desc"
|
|
3005
|
-
slideIndex={0}
|
|
3006
|
-
isVisible={true}
|
|
3007
|
-
theme={theme}
|
|
3008
|
-
disableScroll={true}
|
|
3009
|
-
disableBasePadding
|
|
3010
|
-
enableKeyboardScrolling={false}
|
|
3011
|
-
autoFocusOnVisible={false}
|
|
3012
|
-
/>
|
|
3013
|
-
</div>
|
|
3014
|
-
<button
|
|
3015
|
-
type="button"
|
|
3016
|
-
aria-label="Read full description"
|
|
3017
|
-
aria-haspopup="dialog"
|
|
3018
|
-
aria-expanded={descriptionOpen}
|
|
3019
|
-
onClick={() => setDescriptionOpen(true)}
|
|
3020
|
-
style={{
|
|
3021
|
-
marginTop: 6,
|
|
3022
|
-
padding: 0,
|
|
3023
|
-
border: 'none',
|
|
3024
|
-
background: 'transparent',
|
|
3025
|
-
color: theme.colors.textSecondary,
|
|
3026
|
-
fontFamily: theme.fonts.body,
|
|
3027
|
-
fontSize: theme.fontSizes[0],
|
|
3028
|
-
textDecoration: 'underline',
|
|
3029
|
-
cursor: 'pointer',
|
|
3030
|
-
}}
|
|
3031
|
-
>
|
|
3032
|
-
More
|
|
3033
|
-
</button>
|
|
3034
|
-
</div>
|
|
2994
|
+
<DescriptionPreview
|
|
2995
|
+
content={description}
|
|
2996
|
+
open={descriptionOpen}
|
|
2997
|
+
onOpen={() => setDescriptionOpen(true)}
|
|
2998
|
+
onClose={() => setDescriptionOpen(false)}
|
|
2999
|
+
slideIdPrefix="subsystem-desc"
|
|
3000
|
+
/>
|
|
3035
3001
|
)}
|
|
3036
3002
|
{sidebarAfterDescription}
|
|
3037
3003
|
</>
|
|
@@ -3178,7 +3144,12 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
|
|
|
3178
3144
|
onResizeEnd={() => requestAnimationFrame(() => fitView())}
|
|
3179
3145
|
>
|
|
3180
3146
|
{!hideSidebar && description && descriptionOpen && (
|
|
3181
|
-
<DescriptionOverlay
|
|
3147
|
+
<DescriptionOverlay
|
|
3148
|
+
description={description}
|
|
3149
|
+
ariaLabel="Subsystem description"
|
|
3150
|
+
slideIdPrefix="subsystem-desc-overlay"
|
|
3151
|
+
onClose={() => setDescriptionOpen(false)}
|
|
3152
|
+
/>
|
|
3182
3153
|
)}
|
|
3183
3154
|
{/* Graph area */}
|
|
3184
3155
|
<div style={{ flex: 1, position: 'relative', display: 'flex', flexDirection: committedDirection === 'vertical' ? 'row' : 'column', minHeight: 0, minWidth: 0 }}>
|
|
@@ -14,6 +14,8 @@ export const SKETCH_FIXTURE: C4Sketch = {
|
|
|
14
14
|
title: 'Acme widget architecture',
|
|
15
15
|
repoKeys: [PURL],
|
|
16
16
|
author: 'storybook',
|
|
17
|
+
description:
|
|
18
|
+
'An authored hypothesis for the Acme widget: a host, a worker, a store inside the host, and a GitHub integration.',
|
|
17
19
|
notes:
|
|
18
20
|
'## About this sketch\n\nThis is an **authored hypothesis** for the Acme widget. It describes the host and worker containers, the store inside the host, and the GitHub integration.\n\n- The worker calls the host over RPC.\n- The host calls GitHub over HTTPS.\n- Nothing here is verified or promoted.',
|
|
19
21
|
createdAt: '2026-10-25T00:00:00.000Z',
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import type { C4Container } from '../c4';
|
|
3
|
+
import { C4_SKETCH_DESCRIPTION_MAX } from '../c4Sketch';
|
|
4
|
+
import {
|
|
5
|
+
CONTAINER_MATRIX_SKETCH,
|
|
6
|
+
DESCRIPTION_BOUNDARY_SKETCH,
|
|
7
|
+
MAINTENANCE_BRIDGE_SKETCH,
|
|
8
|
+
OPENBOT_SKETCH,
|
|
9
|
+
STUDIO_SKETCH,
|
|
10
|
+
} from './c4SketchGallery';
|
|
11
|
+
|
|
12
|
+
const containers = (sketch: { model: { nodes: Array<{ kind: string }> } }) =>
|
|
13
|
+
sketch.model.nodes.filter((node): node is C4Container => node.kind === 'container');
|
|
14
|
+
|
|
15
|
+
describe('C4 sketch gallery fixtures', () => {
|
|
16
|
+
test('the studio sketch carries the shipped system containers', () => {
|
|
17
|
+
const labels = containers(STUDIO_SKETCH).map((c) => c.label);
|
|
18
|
+
expect(labels).toEqual([
|
|
19
|
+
'Studio host',
|
|
20
|
+
'Studio renderer',
|
|
21
|
+
'Principal CLI',
|
|
22
|
+
'Site — web',
|
|
23
|
+
'Model store',
|
|
24
|
+
]);
|
|
25
|
+
const store = containers(STUDIO_SKETCH).find((c) => c.label === 'Model store');
|
|
26
|
+
expect(store?.containerKind).toBe('data-store');
|
|
27
|
+
expect(containers(STUDIO_SKETCH).every((c) => c.state === 'proposed')).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('the real sketches keep their authored container counts', () => {
|
|
31
|
+
expect(containers(OPENBOT_SKETCH)).toHaveLength(12);
|
|
32
|
+
expect(containers(MAINTENANCE_BRIDGE_SKETCH)).toHaveLength(6);
|
|
33
|
+
expect(OPENBOT_SKETCH.notes?.length ?? 0).toBeGreaterThan(0);
|
|
34
|
+
expect(MAINTENANCE_BRIDGE_SKETCH.notes?.length ?? 0).toBeGreaterThan(0);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('the matrix covers kind, state, technology, and member-count variants', () => {
|
|
38
|
+
const rows = containers(CONTAINER_MATRIX_SKETCH);
|
|
39
|
+
expect(rows.length).toBe(7);
|
|
40
|
+
expect(new Set(rows.map((c) => c.containerKind))).toEqual(
|
|
41
|
+
new Set(['application', 'data-store']),
|
|
42
|
+
);
|
|
43
|
+
expect(new Set(rows.map((c) => c.state))).toEqual(
|
|
44
|
+
new Set(['accepted', 'proposed']),
|
|
45
|
+
);
|
|
46
|
+
expect(rows.some((c) => c.technology === '')).toBe(true);
|
|
47
|
+
expect(rows.some((c) => c.label.length > 50)).toBe(true);
|
|
48
|
+
expect(rows.some((c) => c.label === 'Crowded container')).toBe(true);
|
|
49
|
+
expect(rows.some((c) => c.label === 'Empty but accepted')).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('descriptions stay inside the 200-character contract', () => {
|
|
53
|
+
for (const sketch of [
|
|
54
|
+
STUDIO_SKETCH,
|
|
55
|
+
CONTAINER_MATRIX_SKETCH,
|
|
56
|
+
DESCRIPTION_BOUNDARY_SKETCH,
|
|
57
|
+
]) {
|
|
58
|
+
expect((sketch.description ?? '').length).toBeLessThanOrEqual(
|
|
59
|
+
C4_SKETCH_DESCRIPTION_MAX,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
expect(DESCRIPTION_BOUNDARY_SKETCH.description?.length).toBeGreaterThan(180);
|
|
63
|
+
expect(DESCRIPTION_BOUNDARY_SKETCH.notes?.length ?? 0).toBeGreaterThan(200);
|
|
64
|
+
});
|
|
65
|
+
});
|