This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
forked from maxGraph/maxGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollapse.stories.js
65 lines (56 loc) · 1.63 KB
/
Collapse.stories.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { Graph, Rectangle } from '@maxgraph/core';
import { globalTypes } from '../.storybook/preview';
export default {
title: 'Layouts/Collapse',
argTypes: {
...globalTypes,
},
};
const Template = ({ label, ...args }) => {
const container = document.createElement('div');
container.style.position = 'relative';
container.style.overflow = 'hidden';
container.style.width = `${args.width}px`;
container.style.height = `${args.height}px`;
container.style.background = 'url(/images/grid.gif)';
container.style.cursor = 'default';
const graph = new Graph(container);
const parent = graph.getDefaultParent();
const getStyle = function () {
// Extends Transactions.getStyle to show an image when collapsed
// TODO cannot use super without a parent class
// let style = super.getStyle();
let style = '';
if (this.isCollapsed()) {
style = {
...style,
shape: 'image',
image: 'http://www.jgraph.com/images/mxgraph.gif',
noLabel: 1,
imageBackground: '#C3D9FF',
imageBorder: '#6482B9',
};
}
return style;
};
graph.batchUpdate(() => {
const v1 = graph.insertVertex({
parent,
value: 'Container',
position: [20, 20],
size: [200, 200],
style: { shape: 'swimlane', startSize: 20 },
});
v1.geometry.alternateBounds = new Rectangle(0, 0, 110, 70);
v1.getStyle = getStyle;
const v11 = graph.insertVertex({
parent: v1,
value: 'Hello,',
position: [10, 40],
size: [120, 80],
});
v11.getStyle = getStyle;
});
return container;
};
export const Default = Template.bind({});