2021-08-30 14:20:26 +00:00
|
|
|
import maxgraph from '@maxgraph/core';
|
2021-04-24 12:30:27 +00:00
|
|
|
|
|
|
|
import { globalTypes } from '../.storybook/preview';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Layouts/Collapse',
|
|
|
|
argTypes: {
|
2021-08-30 14:20:26 +00:00
|
|
|
...globalTypes,
|
|
|
|
},
|
2021-04-24 12:30:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const Template = ({ label, ...args }) => {
|
2021-08-30 14:20:26 +00:00
|
|
|
const { Graph, Rectangle } = maxgraph;
|
2021-04-24 12:30:27 +00:00
|
|
|
|
|
|
|
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';
|
|
|
|
|
2021-08-30 14:20:26 +00:00
|
|
|
const graph = new Graph(container);
|
2021-04-25 03:39:40 +00:00
|
|
|
const parent = graph.getDefaultParent();
|
|
|
|
|
2021-08-30 14:20:26 +00:00
|
|
|
const getStyle = function () {
|
2021-06-06 13:04:44 +00:00
|
|
|
// Extends Transactions.getStyle to show an image when collapsed
|
2021-04-25 03:39:40 +00:00
|
|
|
// 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`;
|
2021-04-24 12:30:27 +00:00
|
|
|
}
|
2021-04-25 03:39:40 +00:00
|
|
|
return style;
|
2021-08-30 14:20:26 +00:00
|
|
|
};
|
2021-04-24 12:30:27 +00:00
|
|
|
|
|
|
|
graph.batchUpdate(() => {
|
|
|
|
const v1 = graph.insertVertex({
|
|
|
|
parent,
|
|
|
|
value: 'Container',
|
|
|
|
position: [20, 20],
|
|
|
|
size: [200, 200],
|
|
|
|
style: 'shape=swimlane;startSize=20;',
|
|
|
|
});
|
2021-08-30 14:20:26 +00:00
|
|
|
v1.geometry.alternateBounds = new Rectangle(0, 0, 110, 70);
|
2021-04-25 03:39:40 +00:00
|
|
|
v1.getStyle = getStyle;
|
2021-04-24 12:30:27 +00:00
|
|
|
|
|
|
|
const v11 = graph.insertVertex({
|
|
|
|
parent: v1,
|
|
|
|
value: 'Hello,',
|
|
|
|
position: [10, 40],
|
|
|
|
size: [120, 80],
|
|
|
|
});
|
2021-04-25 03:39:40 +00:00
|
|
|
v11.getStyle = getStyle;
|
2021-04-24 12:30:27 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return container;
|
2021-08-30 14:20:26 +00:00
|
|
|
};
|
2021-04-24 12:30:27 +00:00
|
|
|
|
2021-08-30 14:20:26 +00:00
|
|
|
export const Default = Template.bind({});
|