Skip to content

Commit 39cefbd

Browse files
committed
...
1 parent 220b32b commit 39cefbd

1 file changed

Lines changed: 42 additions & 5 deletions

File tree

src/components/canvas/groups/CollapsibleGroup.ts

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { PortState } from "../../../store/connection/port/Port";
77
import { TGroup, TGroupId } from "../../../store/group/Group";
88
import { TRect } from "../../../utils/types/shapes";
99

10-
import { Group } from "./Group";
10+
import { BlockGroups } from "./BlockGroups";
11+
import { Group, TGroupGeometry, TGroupProps, TGroupStyle } from "./Group";
1112

1213
// ---------------------------------------------------------------------------
1314
// Event declaration
@@ -159,7 +160,46 @@ const GROUP_PORT_LEFT = "_left";
159160
/** Port ID suffix for the group's right-edge delegation target. */
160161
const GROUP_PORT_RIGHT = "_right";
161162

163+
const defaultStyle: TGroupStyle = {
164+
background: "rgba(100, 100, 100, 0.1)",
165+
border: "rgba(100, 100, 100, 0.3)",
166+
borderWidth: 2,
167+
selectedBackground: "rgba(100, 100, 100, 1)",
168+
selectedBorder: "rgba(100, 100, 100, 1)",
169+
highlightedBackground: "rgba(100, 200, 100, 0.3)",
170+
highlightedBorder: "rgba(100, 200, 100, 0.8)",
171+
};
172+
173+
const defaultGeometry: TGroupGeometry = {
174+
padding: [20, 20, 20, 20],
175+
};
176+
162177
export class CollapsibleGroup<T extends TCollapsibleGroup = TCollapsibleGroup> extends Group<T> {
178+
public static define(config: {
179+
style?: Partial<TGroupStyle>;
180+
geometry?: Partial<TGroupGeometry>;
181+
}): typeof CollapsibleGroup {
182+
return class SpecificGroup<T extends TCollapsibleGroup = TCollapsibleGroup> extends this<T> {
183+
constructor(props: TGroupProps, parent: BlockGroups) {
184+
super(
185+
{
186+
...props,
187+
style: {
188+
...defaultStyle,
189+
...config.style,
190+
...props.style,
191+
},
192+
geometry: {
193+
...defaultGeometry,
194+
...config.geometry,
195+
...props.geometry,
196+
},
197+
},
198+
parent
199+
);
200+
}
201+
};
202+
}
163203
/**
164204
* Extend base subscription to also react to collapsed state on init.
165205
* subscribeSignal fires immediately with the current value, so a group
@@ -255,13 +295,10 @@ export class CollapsibleGroup<T extends TCollapsibleGroup = TCollapsibleGroup> e
255295
*/
256296
private computeCollapsedRect(fullRect: TRect): TRect {
257297
const state = this.groupState.$state.value;
258-
console.log(state.getCollapseRect);
259298
if (state.getCollapseRect) {
260299
return state.getCollapseRect(state, fullRect);
261300
}
262-
const a = computeDefaultCollapseRect(fullRect, state.collapseDirection);
263-
console.log(a);
264-
return a;
301+
return computeDefaultCollapseRect(fullRect, state.collapseDirection);
265302
}
266303

267304
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)