@principal-ai/subsystems-react 0.56.23 → 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
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C4ContainersPanel — sidebar overview of a C4 diagram's containers.
|
|
3
|
+
*
|
|
4
|
+
* The C4 counterpart to the subsystem graph's `ContainersPanel`: one row per
|
|
5
|
+
* container and a bulk open/close header. A row behaves as a dropdown —
|
|
6
|
+
* selecting it toggles the container's internals on the canvas and frames it,
|
|
7
|
+
* with a chevron showing the open state. A container with no components is
|
|
8
|
+
* select-only: it frames the box without a dropdown.
|
|
9
|
+
*
|
|
10
|
+
* The panel is pure chrome — the view owns the open set and the camera focus,
|
|
11
|
+
* exactly as `SubsystemComponentGraph` owns its frame state.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { useTheme } from '@principal-ade/industry-theme';
|
|
15
|
+
import { ChevronRight, Component, Database, AppWindow } from 'lucide-react';
|
|
16
|
+
import { Fragment } from 'react';
|
|
17
|
+
import type { CSSProperties } from 'react';
|
|
18
|
+
import type { C4Component, C4Container } from './c4';
|
|
19
|
+
import { nodeKindIcon, nodeStyle, nodeTechnology } from './C4NodeCard';
|
|
20
|
+
import { TechMark, technologyBrand } from './techIcons';
|
|
21
|
+
|
|
22
|
+
/** One row height for containers and their members, so the dropdown stays tabular. */
|
|
23
|
+
const ROW_HEIGHT = 38;
|
|
24
|
+
|
|
25
|
+
export interface C4ContainerListItem {
|
|
26
|
+
/** Element id — the container the canvas toggles and frames. */
|
|
27
|
+
container: C4Container;
|
|
28
|
+
/** Drawn with its internals laid out. */
|
|
29
|
+
open: boolean;
|
|
30
|
+
/** The authored C4 components inside this container, in model order. */
|
|
31
|
+
members: readonly C4Component[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface C4ContainersPanelProps {
|
|
35
|
+
containers: readonly C4ContainerListItem[];
|
|
36
|
+
/** The container last activated from this list. */
|
|
37
|
+
activeId?: string | null;
|
|
38
|
+
/** Toggle a container's internals and frame it. */
|
|
39
|
+
onActivate: (id: string) => void;
|
|
40
|
+
/** Frame a container that has nothing to expand. */
|
|
41
|
+
onSelect: (id: string) => void;
|
|
42
|
+
onOpenAll: () => void;
|
|
43
|
+
onCloseAll: () => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function C4ContainersPanel({
|
|
47
|
+
containers,
|
|
48
|
+
activeId,
|
|
49
|
+
onActivate,
|
|
50
|
+
onSelect,
|
|
51
|
+
onOpenAll,
|
|
52
|
+
onCloseAll,
|
|
53
|
+
}: C4ContainersPanelProps) {
|
|
54
|
+
const { theme } = useTheme();
|
|
55
|
+
const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
|
|
56
|
+
const anyOpen = containers.some((c) => c.open);
|
|
57
|
+
const anyClosed = containers.some((c) => !c.open);
|
|
58
|
+
const bulkStyle = (enabled: boolean): CSSProperties => ({
|
|
59
|
+
padding: '2px 8px',
|
|
60
|
+
border: `1px solid ${theme.colors.border}`,
|
|
61
|
+
borderRadius: 4,
|
|
62
|
+
background: 'transparent',
|
|
63
|
+
color: enabled ? theme.colors.textSecondary : muted,
|
|
64
|
+
fontFamily: theme.fonts.monospace,
|
|
65
|
+
fontSize: theme.fontSizes[0],
|
|
66
|
+
cursor: enabled ? 'pointer' : 'default',
|
|
67
|
+
opacity: enabled ? 1 : 0.5,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (containers.length === 0) {
|
|
71
|
+
return (
|
|
72
|
+
<div style={{ padding: 16, color: theme.colors.textSecondary }}>No containers.</div>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div style={{ display: 'flex', flexDirection: 'column', minHeight: 0 }}>
|
|
78
|
+
<style>{`
|
|
79
|
+
.c4-containers-row {
|
|
80
|
+
background: transparent;
|
|
81
|
+
transition: background 120ms ease;
|
|
82
|
+
}
|
|
83
|
+
.c4-containers-row:hover {
|
|
84
|
+
background: color-mix(in srgb, currentColor 8%, transparent);
|
|
85
|
+
}
|
|
86
|
+
.c4-containers-row[data-active='true'] {
|
|
87
|
+
background: color-mix(in srgb, currentColor 12%, transparent);
|
|
88
|
+
}
|
|
89
|
+
.c4-containers-row[data-active='true']:hover {
|
|
90
|
+
background: color-mix(in srgb, currentColor 16%, transparent);
|
|
91
|
+
}
|
|
92
|
+
`}</style>
|
|
93
|
+
<div
|
|
94
|
+
style={{
|
|
95
|
+
display: 'flex',
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
gap: 6,
|
|
98
|
+
padding: '8px 12px',
|
|
99
|
+
borderBottom: `1px solid ${theme.colors.border}`,
|
|
100
|
+
flexShrink: 0,
|
|
101
|
+
}}
|
|
102
|
+
>
|
|
103
|
+
<span
|
|
104
|
+
style={{
|
|
105
|
+
flex: 1,
|
|
106
|
+
fontFamily: theme.fonts.monospace,
|
|
107
|
+
fontSize: theme.fontSizes[0],
|
|
108
|
+
color: muted,
|
|
109
|
+
textTransform: 'uppercase',
|
|
110
|
+
letterSpacing: 0.5,
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
{containers.length} {containers.length === 1 ? 'container' : 'containers'}
|
|
114
|
+
</span>
|
|
115
|
+
<button type="button" onClick={onOpenAll} disabled={!anyClosed} style={bulkStyle(anyClosed)}>
|
|
116
|
+
Open all
|
|
117
|
+
</button>
|
|
118
|
+
<button type="button" onClick={onCloseAll} disabled={!anyOpen} style={bulkStyle(anyOpen)}>
|
|
119
|
+
Close all
|
|
120
|
+
</button>
|
|
121
|
+
</div>
|
|
122
|
+
<ul
|
|
123
|
+
role="list"
|
|
124
|
+
aria-label="Containers"
|
|
125
|
+
style={{ listStyle: 'none', margin: 0, padding: '6px 0', overflow: 'auto', minHeight: 0 }}
|
|
126
|
+
>
|
|
127
|
+
{containers.map((item) => {
|
|
128
|
+
const canToggle = item.members.length > 0;
|
|
129
|
+
return (
|
|
130
|
+
<Fragment key={item.container.id}>
|
|
131
|
+
<ContainerRow
|
|
132
|
+
item={item}
|
|
133
|
+
active={item.container.id === activeId}
|
|
134
|
+
canToggle={canToggle}
|
|
135
|
+
onActivate={() =>
|
|
136
|
+
canToggle
|
|
137
|
+
? onActivate(item.container.id)
|
|
138
|
+
: onSelect(item.container.id)
|
|
139
|
+
}
|
|
140
|
+
/>
|
|
141
|
+
{item.open &&
|
|
142
|
+
item.members.map((member) => (
|
|
143
|
+
<ContainerMemberRow key={member.id} component={member} />
|
|
144
|
+
))}
|
|
145
|
+
</Fragment>
|
|
146
|
+
);
|
|
147
|
+
})}
|
|
148
|
+
</ul>
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function ContainerRow({
|
|
154
|
+
item,
|
|
155
|
+
active,
|
|
156
|
+
canToggle,
|
|
157
|
+
onActivate,
|
|
158
|
+
}: {
|
|
159
|
+
item: C4ContainerListItem;
|
|
160
|
+
active: boolean;
|
|
161
|
+
canToggle: boolean;
|
|
162
|
+
onActivate: () => void;
|
|
163
|
+
}) {
|
|
164
|
+
const { theme } = useTheme();
|
|
165
|
+
const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
|
|
166
|
+
const { container, open } = item;
|
|
167
|
+
const Icon = nodeKindIcon(container) ?? (container.containerKind === 'data-store' ? Database : AppWindow);
|
|
168
|
+
const brand = technologyBrand(nodeTechnology(container) ?? container.containerKind);
|
|
169
|
+
const proposed = container.state === 'proposed';
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<li
|
|
173
|
+
className="c4-containers-row"
|
|
174
|
+
data-active={active || undefined}
|
|
175
|
+
style={
|
|
176
|
+
{
|
|
177
|
+
display: 'flex',
|
|
178
|
+
alignItems: 'center',
|
|
179
|
+
gap: 8,
|
|
180
|
+
height: ROW_HEIGHT,
|
|
181
|
+
boxSizing: 'border-box',
|
|
182
|
+
padding: '0 12px',
|
|
183
|
+
} as CSSProperties
|
|
184
|
+
}
|
|
185
|
+
>
|
|
186
|
+
<button
|
|
187
|
+
type="button"
|
|
188
|
+
onClick={onActivate}
|
|
189
|
+
aria-current={active || undefined}
|
|
190
|
+
aria-expanded={canToggle ? open : undefined}
|
|
191
|
+
style={{
|
|
192
|
+
flex: 1,
|
|
193
|
+
minWidth: 0,
|
|
194
|
+
display: 'grid',
|
|
195
|
+
gridTemplateColumns: '18px minmax(0, 1fr) 12px',
|
|
196
|
+
columnGap: 8,
|
|
197
|
+
alignItems: 'center',
|
|
198
|
+
padding: 0,
|
|
199
|
+
border: 'none',
|
|
200
|
+
background: 'transparent',
|
|
201
|
+
color: theme.colors.text,
|
|
202
|
+
textAlign: 'left',
|
|
203
|
+
cursor: 'pointer',
|
|
204
|
+
fontFamily: theme.fonts.body,
|
|
205
|
+
}}
|
|
206
|
+
>
|
|
207
|
+
<span
|
|
208
|
+
style={{
|
|
209
|
+
display: 'flex',
|
|
210
|
+
alignItems: 'center',
|
|
211
|
+
justifyContent: 'center',
|
|
212
|
+
gridColumn: 1,
|
|
213
|
+
gridRow: 1,
|
|
214
|
+
}}
|
|
215
|
+
>
|
|
216
|
+
{brand ? (
|
|
217
|
+
<span aria-hidden style={{ display: 'inline-flex', transform: 'translateY(2px)' }}>
|
|
218
|
+
<TechMark brand={brand} size={16} showTitle={false} />
|
|
219
|
+
</span>
|
|
220
|
+
) : (
|
|
221
|
+
<Icon size={16} color={theme.colors.textSecondary} aria-hidden />
|
|
222
|
+
)}
|
|
223
|
+
</span>
|
|
224
|
+
<span
|
|
225
|
+
style={{
|
|
226
|
+
gridColumn: 2,
|
|
227
|
+
gridRow: 1,
|
|
228
|
+
display: 'flex',
|
|
229
|
+
alignItems: 'center',
|
|
230
|
+
gap: 6,
|
|
231
|
+
fontSize: theme.fontSizes[2],
|
|
232
|
+
fontWeight: 600,
|
|
233
|
+
lineHeight: 1.35,
|
|
234
|
+
minWidth: 0,
|
|
235
|
+
}}
|
|
236
|
+
>
|
|
237
|
+
<span
|
|
238
|
+
style={{
|
|
239
|
+
overflow: 'hidden',
|
|
240
|
+
textOverflow: 'ellipsis',
|
|
241
|
+
whiteSpace: 'nowrap',
|
|
242
|
+
}}
|
|
243
|
+
>
|
|
244
|
+
{container.label}
|
|
245
|
+
</span>
|
|
246
|
+
{proposed && (
|
|
247
|
+
<span
|
|
248
|
+
style={{
|
|
249
|
+
flexShrink: 0,
|
|
250
|
+
padding: '0 4px',
|
|
251
|
+
borderRadius: 3,
|
|
252
|
+
border: '1px solid #e3b34166',
|
|
253
|
+
color: '#e3b341',
|
|
254
|
+
fontFamily: theme.fonts.monospace,
|
|
255
|
+
fontSize: 9,
|
|
256
|
+
letterSpacing: 0.4,
|
|
257
|
+
textTransform: 'uppercase',
|
|
258
|
+
}}
|
|
259
|
+
>
|
|
260
|
+
proposed
|
|
261
|
+
</span>
|
|
262
|
+
)}
|
|
263
|
+
</span>
|
|
264
|
+
{canToggle && (
|
|
265
|
+
<ChevronRight
|
|
266
|
+
size={12}
|
|
267
|
+
aria-hidden
|
|
268
|
+
style={{
|
|
269
|
+
gridColumn: 3,
|
|
270
|
+
gridRow: 1,
|
|
271
|
+
justifySelf: 'center',
|
|
272
|
+
color: muted,
|
|
273
|
+
transform: open ? 'rotate(90deg)' : undefined,
|
|
274
|
+
transition: 'transform 120ms ease',
|
|
275
|
+
}}
|
|
276
|
+
/>
|
|
277
|
+
)}
|
|
278
|
+
</button>
|
|
279
|
+
</li>
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** One authored component under an opened container — the dropdown's rows. */
|
|
284
|
+
function ContainerMemberRow({ component }: { component: C4Component }) {
|
|
285
|
+
const { theme } = useTheme();
|
|
286
|
+
const style = nodeStyle(component, theme);
|
|
287
|
+
return (
|
|
288
|
+
<li
|
|
289
|
+
style={{
|
|
290
|
+
display: 'flex',
|
|
291
|
+
alignItems: 'center',
|
|
292
|
+
gap: 7,
|
|
293
|
+
height: ROW_HEIGHT,
|
|
294
|
+
boxSizing: 'border-box',
|
|
295
|
+
padding: '0 12px 0 28px',
|
|
296
|
+
color: theme.colors.textSecondary,
|
|
297
|
+
}}
|
|
298
|
+
>
|
|
299
|
+
<Component size={12} color={style.color} aria-hidden />
|
|
300
|
+
<span
|
|
301
|
+
style={{
|
|
302
|
+
minWidth: 0,
|
|
303
|
+
fontSize: theme.fontSizes[1],
|
|
304
|
+
fontFamily: theme.fonts.body,
|
|
305
|
+
lineHeight: 1.4,
|
|
306
|
+
overflow: 'hidden',
|
|
307
|
+
textOverflow: 'ellipsis',
|
|
308
|
+
whiteSpace: 'nowrap',
|
|
309
|
+
}}
|
|
310
|
+
>
|
|
311
|
+
{component.label}
|
|
312
|
+
</span>
|
|
313
|
+
</li>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
@@ -379,6 +379,13 @@ export function C4NodeCard({ node, selected = false, handles, onClick, component
|
|
|
379
379
|
const shape = nodeShape(node);
|
|
380
380
|
const Icon = nodeKindIcon(node);
|
|
381
381
|
const brand = technologyBrand(nodeTechnology(node));
|
|
382
|
+
// An unbranded container's border is the muted theme border — fine for a
|
|
383
|
+
// hairline, too dark for the glyph and the box accent. Keep a selected card's
|
|
384
|
+
// accent, and otherwise give the whole card a legible neutral.
|
|
385
|
+
const accentColor =
|
|
386
|
+
node.kind === 'container' && !brand && !selected
|
|
387
|
+
? theme.colors.textSecondary
|
|
388
|
+
: style.color;
|
|
382
389
|
const topLabel = nodeTopLabel(node);
|
|
383
390
|
const subtitle = nodeSubtitle(node);
|
|
384
391
|
|
|
@@ -432,7 +439,7 @@ export function C4NodeCard({ node, selected = false, handles, onClick, component
|
|
|
432
439
|
padding: pillInset ? '10px 30px' : '10px 12px',
|
|
433
440
|
borderRadius: shape.radius,
|
|
434
441
|
background: theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
435
|
-
border: `${style.width}px ${style.dash} ${
|
|
442
|
+
border: `${style.width}px ${style.dash} ${accentColor}`,
|
|
436
443
|
boxShadow: '0 1px 4px rgba(0,0,0,0.25)',
|
|
437
444
|
cursor: onClick ? 'pointer' : 'default',
|
|
438
445
|
fontFamily: theme.fonts.body,
|
|
@@ -442,7 +449,8 @@ export function C4NodeCard({ node, selected = false, handles, onClick, component
|
|
|
442
449
|
label={node.label}
|
|
443
450
|
Icon={Icon}
|
|
444
451
|
iconLabel={node.kind === 'container' ? node.containerKind : node.kind}
|
|
445
|
-
color={
|
|
452
|
+
color={accentColor}
|
|
453
|
+
iconColor={accentColor}
|
|
446
454
|
topLabel={topLabel}
|
|
447
455
|
brand={brand}
|
|
448
456
|
hasTechRow={hasTechRow}
|
|
@@ -494,9 +502,9 @@ export function C4NodeCard({ node, selected = false, handles, onClick, component
|
|
|
494
502
|
height: TOGGLE_SIZE,
|
|
495
503
|
padding: 0,
|
|
496
504
|
borderRadius: 4,
|
|
497
|
-
border: `1px solid ${
|
|
505
|
+
border: `1px solid ${accentColor}`,
|
|
498
506
|
background: theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
499
|
-
color:
|
|
507
|
+
color: accentColor,
|
|
500
508
|
cursor: 'pointer',
|
|
501
509
|
lineHeight: 1,
|
|
502
510
|
}}
|
|
@@ -17,6 +17,7 @@ import { useTheme } from '@principal-ade/industry-theme';
|
|
|
17
17
|
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
18
18
|
import { C4Graph } from './C4Graph';
|
|
19
19
|
import type { C4ConstructGraph, C4GraphProps } from './C4Graph';
|
|
20
|
+
import { C4ContainersPanel } from './C4ContainersPanel';
|
|
20
21
|
import { GraphWithSidebar } from './GraphWithSidebar';
|
|
21
22
|
import { TrailStepsNav } from './TrailStepsNav';
|
|
22
23
|
import {
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
deriveTrailPlayerElements,
|
|
25
26
|
} from './c4TrailFocus';
|
|
26
27
|
import { deriveGraphEdges, trailStepGraphEdgeId } from './model';
|
|
27
|
-
import type { C4Element, C4Model } from './c4';
|
|
28
|
+
import type { C4Component, C4Container, C4Element, C4Model } from './c4';
|
|
28
29
|
import type { SubsystemComponent, SubsystemTrail } from './model';
|
|
29
30
|
import type { TrailComponentLabels } from './trailStepDisplay';
|
|
30
31
|
|
|
@@ -235,6 +236,27 @@ export function C4ProjectionView({
|
|
|
235
236
|
} | null>(null);
|
|
236
237
|
const trailOpenedRef = useRef<Set<string>>(new Set());
|
|
237
238
|
|
|
239
|
+
/** Sidebar section: the container overview or the trails. */
|
|
240
|
+
const [sidebarTab, setSidebarTab] = useState<'containers' | 'trails'>('containers');
|
|
241
|
+
/** Container last activated from the sidebar — the camera target. */
|
|
242
|
+
const [containerFocus, setContainerFocus] = useState<{ id: string } | null>(null);
|
|
243
|
+
|
|
244
|
+
const containerItems = useMemo(() => {
|
|
245
|
+
const components = model.nodes.filter(
|
|
246
|
+
(node): node is C4Component => node.kind === 'component',
|
|
247
|
+
);
|
|
248
|
+
return model.nodes
|
|
249
|
+
.filter((node): node is C4Container => node.kind === 'container')
|
|
250
|
+
.map((container) => ({
|
|
251
|
+
container,
|
|
252
|
+
open: resolvedOpenIds.includes(container.id),
|
|
253
|
+
members: components.filter(
|
|
254
|
+
(component) =>
|
|
255
|
+
(component.container ?? component.parentId) === container.id,
|
|
256
|
+
),
|
|
257
|
+
}));
|
|
258
|
+
}, [model.nodes, resolvedOpenIds]);
|
|
259
|
+
|
|
238
260
|
const parents = useMemo(() => parentIdsOf(model), [model]);
|
|
239
261
|
const allElementIds = useMemo(
|
|
240
262
|
() => model.nodes.map((node) => node.id),
|
|
@@ -297,6 +319,7 @@ export function C4ProjectionView({
|
|
|
297
319
|
setFocusedTrailId(trailId);
|
|
298
320
|
setHoveredStep(null);
|
|
299
321
|
setOpenIds(next);
|
|
322
|
+
setContainerFocus(null);
|
|
300
323
|
onTrailSelect?.({ trailId });
|
|
301
324
|
},
|
|
302
325
|
[containers, onTrailSelect, resolvedOpenIds, setOpenIds],
|
|
@@ -315,15 +338,69 @@ export function C4ProjectionView({
|
|
|
315
338
|
|
|
316
339
|
const toggleContainer = useCallback(
|
|
317
340
|
(id: string) => {
|
|
318
|
-
|
|
319
|
-
resolvedOpenIds.
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
341
|
+
if (resolvedOpenIds.includes(id)) {
|
|
342
|
+
setOpenIds(resolvedOpenIds.filter((openId) => openId !== id));
|
|
343
|
+
setContainerFocus((prev) => (prev?.id === id ? null : prev));
|
|
344
|
+
} else {
|
|
345
|
+
setOpenIds([...resolvedOpenIds, id].sort());
|
|
346
|
+
}
|
|
323
347
|
},
|
|
324
348
|
[resolvedOpenIds, setOpenIds],
|
|
325
349
|
);
|
|
326
350
|
|
|
351
|
+
/**
|
|
352
|
+
* Sidebar row click: drop any trail focus (whose opened containers were a
|
|
353
|
+
* previous frame), then toggle the picked container (dropdown) and frame it.
|
|
354
|
+
*/
|
|
355
|
+
const activateContainer = useCallback(
|
|
356
|
+
(id: string) => {
|
|
357
|
+
const opened = trailOpenedRef.current;
|
|
358
|
+
const clearing = focusedTrailId != null;
|
|
359
|
+
const base = clearing
|
|
360
|
+
? resolvedOpenIds.filter((openId) => !opened.has(openId))
|
|
361
|
+
: resolvedOpenIds;
|
|
362
|
+
if (clearing) {
|
|
363
|
+
trailOpenedRef.current = new Set();
|
|
364
|
+
setFocusedTrailId(null);
|
|
365
|
+
setHoveredStep(null);
|
|
366
|
+
setFocusedStep(null);
|
|
367
|
+
onTrailSelect?.(null);
|
|
368
|
+
}
|
|
369
|
+
if (base.includes(id)) {
|
|
370
|
+
setOpenIds(base.filter((openId) => openId !== id));
|
|
371
|
+
setContainerFocus((prev) => (prev?.id === id ? null : prev));
|
|
372
|
+
} else {
|
|
373
|
+
setContainerFocus({ id });
|
|
374
|
+
setOpenIds([...base, id].sort());
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
[focusedTrailId, onTrailSelect, resolvedOpenIds, setOpenIds],
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Select-only row (no components to expand): drop any trail focus, keep the
|
|
382
|
+
* open set as it is, and frame the container.
|
|
383
|
+
*/
|
|
384
|
+
const selectContainer = useCallback(
|
|
385
|
+
(id: string) => {
|
|
386
|
+
const opened = trailOpenedRef.current;
|
|
387
|
+
const clearing = focusedTrailId != null;
|
|
388
|
+
const base = clearing
|
|
389
|
+
? resolvedOpenIds.filter((openId) => !opened.has(openId))
|
|
390
|
+
: resolvedOpenIds;
|
|
391
|
+
if (clearing) {
|
|
392
|
+
trailOpenedRef.current = new Set();
|
|
393
|
+
setFocusedTrailId(null);
|
|
394
|
+
setHoveredStep(null);
|
|
395
|
+
setFocusedStep(null);
|
|
396
|
+
onTrailSelect?.(null);
|
|
397
|
+
if (base.length !== resolvedOpenIds.length) setOpenIds(base);
|
|
398
|
+
}
|
|
399
|
+
setContainerFocus({ id });
|
|
400
|
+
},
|
|
401
|
+
[focusedTrailId, onTrailSelect, resolvedOpenIds, setOpenIds],
|
|
402
|
+
);
|
|
403
|
+
|
|
327
404
|
const activeStep = focusedStep ?? hoveredStep;
|
|
328
405
|
const emphasis = useMemo(() => {
|
|
329
406
|
let hiddenElementIds: ReadonlySet<string> | null = null;
|
|
@@ -408,6 +485,7 @@ export function C4ProjectionView({
|
|
|
408
485
|
);
|
|
409
486
|
|
|
410
487
|
const openAll = useCallback(() => {
|
|
488
|
+
setContainerFocus(null);
|
|
411
489
|
setOpenIds(
|
|
412
490
|
model.nodes
|
|
413
491
|
.filter((node) => node.kind === 'container')
|
|
@@ -417,6 +495,7 @@ export function C4ProjectionView({
|
|
|
417
495
|
}, [model, setOpenIds]);
|
|
418
496
|
|
|
419
497
|
const collapseAll = useCallback(() => {
|
|
498
|
+
setContainerFocus(null);
|
|
420
499
|
setOpenIds([]);
|
|
421
500
|
}, [setOpenIds]);
|
|
422
501
|
|
|
@@ -482,16 +561,6 @@ export function C4ProjectionView({
|
|
|
482
561
|
}}
|
|
483
562
|
>
|
|
484
563
|
{headerActions}
|
|
485
|
-
<button type="button" onClick={openAll} style={smallButton(theme)}>
|
|
486
|
-
Open all
|
|
487
|
-
</button>
|
|
488
|
-
<button
|
|
489
|
-
type="button"
|
|
490
|
-
onClick={collapseAll}
|
|
491
|
-
style={smallButton(theme)}
|
|
492
|
-
>
|
|
493
|
-
Collapse all
|
|
494
|
-
</button>
|
|
495
564
|
</div>
|
|
496
565
|
</header>
|
|
497
566
|
<div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }}>
|
|
@@ -502,7 +571,18 @@ export function C4ProjectionView({
|
|
|
502
571
|
maxWidth={480}
|
|
503
572
|
headerMaxHeight="30%"
|
|
504
573
|
header={sidebarHeader}
|
|
574
|
+
tabs={
|
|
575
|
+
trails.length > 0
|
|
576
|
+
? [
|
|
577
|
+
{ id: 'containers', label: 'Containers' },
|
|
578
|
+
{ id: 'trails', label: 'Trails' },
|
|
579
|
+
]
|
|
580
|
+
: undefined
|
|
581
|
+
}
|
|
582
|
+
activeTab={trails.length > 0 ? sidebarTab : undefined}
|
|
583
|
+
onTabChange={(id) => setSidebarTab(id as 'containers' | 'trails')}
|
|
505
584
|
sidebarBody={
|
|
585
|
+
trails.length > 0 && sidebarTab === 'trails' ? (
|
|
506
586
|
<TrailStepsNav
|
|
507
587
|
trails={[...trails]}
|
|
508
588
|
focusedTrailId={focusedTrailId}
|
|
@@ -544,6 +624,16 @@ export function C4ProjectionView({
|
|
|
544
624
|
onTrailStepHover?.(null);
|
|
545
625
|
}}
|
|
546
626
|
/>
|
|
627
|
+
) : (
|
|
628
|
+
<C4ContainersPanel
|
|
629
|
+
containers={containerItems}
|
|
630
|
+
activeId={containerFocus?.id ?? null}
|
|
631
|
+
onActivate={activateContainer}
|
|
632
|
+
onSelect={selectContainer}
|
|
633
|
+
onOpenAll={openAll}
|
|
634
|
+
onCloseAll={collapseAll}
|
|
635
|
+
/>
|
|
636
|
+
)
|
|
547
637
|
}
|
|
548
638
|
>
|
|
549
639
|
<C4Graph
|
|
@@ -554,6 +644,7 @@ export function C4ProjectionView({
|
|
|
554
644
|
}}
|
|
555
645
|
onTrailClick={(ref) => focusTrail(ref.trailId)}
|
|
556
646
|
onToggleContainer={toggleContainer}
|
|
647
|
+
containerFocus={focusedTrailId ? undefined : containerFocus}
|
|
557
648
|
hiddenElementIds={emphasis.hiddenElementIds}
|
|
558
649
|
hiddenEdgeIds={emphasis.hiddenEdgeIds}
|
|
559
650
|
dimmedElementIds={emphasis.dimmedElementIds}
|
|
@@ -572,24 +663,3 @@ export function C4ProjectionView({
|
|
|
572
663
|
</div>
|
|
573
664
|
);
|
|
574
665
|
}
|
|
575
|
-
|
|
576
|
-
function smallButton(theme: ReturnType<typeof useTheme>['theme']) {
|
|
577
|
-
return {
|
|
578
|
-
flexShrink: 0,
|
|
579
|
-
display: 'inline-flex',
|
|
580
|
-
alignItems: 'center',
|
|
581
|
-
justifyContent: 'center',
|
|
582
|
-
width: 132,
|
|
583
|
-
height: 34,
|
|
584
|
-
padding: '0 12px',
|
|
585
|
-
boxSizing: 'border-box',
|
|
586
|
-
whiteSpace: 'nowrap',
|
|
587
|
-
borderRadius: 6,
|
|
588
|
-
border: `1px solid ${theme.colors.border}`,
|
|
589
|
-
background: 'transparent',
|
|
590
|
-
color: theme.colors.textSecondary,
|
|
591
|
-
fontFamily: theme.fonts.body,
|
|
592
|
-
fontSize: theme.fontSizes[1],
|
|
593
|
-
cursor: 'pointer',
|
|
594
|
-
} as const;
|
|
595
|
-
}
|