Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/16 - Sidebar, Nodes, Node selection move to meta-diagram theme, add variables #17

Merged
merged 28 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3197831
#16 Add more variables for sidebar customisation, move styles for no…
vidhya-metacell Jul 22, 2022
06cd2bb
#16 Update canvas styles
vidhya-metacell Jul 22, 2022
113653d
#16 Add Nodes UI and color variants
vidhya-metacell Jul 22, 2022
17c0f0d
#16 Linter updates
vidhya-metacell Jul 22, 2022
6d589be
#16 chore: Update dist folder
afonsobspinto Jul 22, 2022
d7d2eb0
#16 Update build folder
vidhya-metacell Jul 22, 2022
a4be292
Merge branch 'feature/16' of github.com:MetaCell/meta-diagram into fe…
vidhya-metacell Jul 22, 2022
ffbf87b
#16 Variables for node color options
vidhya-metacell Jul 22, 2022
843b552
#16 Sidebar selected state for optionns availble in list
vidhya-metacell Jul 22, 2022
5959de3
#16 Node selection
vidhya-metacell Jul 22, 2022
76cca14
#16 Update color option for node
vidhya-metacell Jul 22, 2022
bfeb598
#16 Build files
vidhya-metacell Jul 22, 2022
806236f
#16 Resolve merge conflicts
vidhya-metacell Jul 26, 2022
be962bb
#16 Linter fixes
vidhya-metacell Jul 26, 2022
5fc0394
#16 Make components DRY
vidhya-metacell Jul 27, 2022
d1791e8
#16 Keep the node base styles and a default calue of color in meta theme
vidhya-metacell Jul 29, 2022
edb552b
#16 Add color options for node in example's theme
vidhya-metacell Jul 29, 2022
cb0d701
#16 Remove style options from node widget in example
vidhya-metacell Jul 29, 2022
156c8bc
#16 Linter updates
vidhya-metacell Jul 29, 2022
162f501
#16 Build updates
vidhya-metacell Jul 29, 2022
7f18fb3
#16 Update material version to integrate theme
vidhya-metacell Jul 29, 2022
9545f85
#16 Icon addition from theme to node
vidhya-metacell Jul 30, 2022
b58c1b6
#16 Add icon example to the nodes
vidhya-metacell Jul 30, 2022
8348966
#16 Build files
vidhya-metacell Jul 30, 2022
988ca22
#16 chore: Add variant attribute to entities
afonsobspinto Aug 1, 2022
1ab69b1
#16 chore: Fix linting
afonsobspinto Aug 1, 2022
0c90c00
Merge branch 'develop' into feature/16
afonsobspinto Aug 1, 2022
3b5eaed
#16 chore: Strictly compare against undefined
afonsobspinto Aug 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions dist/components/assets/styles/variables.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
declare const vars: {
nodeGreenBackgroundColor: string;
nodeGreenTextColor: string;
nodeGreenBorderColor: string;
nodeGreenBoxShadow: string;
fontFamily: string;
primaryBg: string;
textWhite: string;
Expand All @@ -23,5 +27,14 @@ declare const vars: {
progressBar: string;
progressShadow: string;
switchShadow: string;
sidebarBg: string;
sidebarShadow: string;
canvasBg: string;
showPropertiesButtonBg: string;
nodeBorderColor: string;
nodePointerBg: string;
nodeButtonTextColor: string;
nodeButtonLineColor: string;
nodeTextColor: string;
};
export default vars;
294 changes: 242 additions & 52 deletions dist/meta-diagram.cjs.development.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/meta-diagram.cjs.development.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/meta-diagram.cjs.production.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/meta-diagram.cjs.production.min.js.map

Large diffs are not rendered by default.

296 changes: 243 additions & 53 deletions dist/meta-diagram.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/meta-diagram.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/models/MetaLink.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export declare class MetaLink implements ILink {
targetId: string;
targetPortId: string;
options: MetaOptions;
constructor(id: string, name: string, shape: string, sourceId: string, sourcePortId: string, targetId: string, targetPortId: string, options: Map<string, any>);
constructor(id: string, name: string, shape: string, sourceId: string, sourcePortId: string, targetId: string, targetPortId: string, variant: string, options: Map<string, any>);
getSourceId(): string;
getSourcePortId(): string;
getTargetId(): string;
Expand Down
2 changes: 1 addition & 1 deletion dist/models/MetaNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { Position } from './Position';
export declare class MetaNode {
children: MetaNode[];
options: MetaOptions;
constructor(id: string, name: string, shape: string, position: Position, options: Map<string, any>);
constructor(id: string, name: string, shape: string, position: Position, variant: string, options: Map<string, any>);
}
2 changes: 1 addition & 1 deletion dist/models/MetaOptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IShape } from './IShape';
import { IId } from './IId';
export declare class MetaOptions implements IShape, IId {
options: Map<string, any>;
constructor(id: string, name: string, shape: string, options: Map<string, any>);
constructor(id: string, name: string, shape: string, variant: string, options: Map<string, any>);
getId(): string;
getShape(): string;
}
180 changes: 90 additions & 90 deletions dist/theme.d.ts
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
declare type ThemeVars = {
[key: string]: any;
};
declare const _default: (customVariables: ThemeVars) => {
components: {
MuiCssBaseline: {
styleOverrides: string;
};
MuiList: {
styleOverrides: {
root: {
'&.customSwitch': {
padding: string;
background: any;
borderRadius: string;
display: string;
'& .MuiListItemButton-root': {
padding: string;
borderRadius: string;
width: string;
display: string;
alignItems: string;
justifyContent: string;
'&:not(:last-child)': {
marginBottom: string;
};
'&.Mui-disabled': {
opacity: number;
};
'&.Mui-selected': {
background: any;
boxShadow: any;
border: string;
'& .MuiTypography-root': {
color: any;
};
};
};
'& .MuiChip-root': {
marginLeft: string;
};
'& .MuiTypography-root': {
fontWeight: number;
fontSize: string;
lineHeight: string;
letterSpacing: string;
color: any;
margin: number;
};
};
};
};
};
MuiListItemIcon: {
styleOverrides: {
root: {
minWidth: string;
};
};
};
MuiListItemButton: {
styleOverrides: {
root: {
padding: number;
width: string;
height: string;
borderRadius: string;
justifyContent: string;
backgroundColor: any;
'&:hover': {
backgroundColor: any;
};
'&:not(:last-child)': {
marginBottom: string;
};
'&.Mui-selected': {
backgroundColor: any;
'&:hover': {
backgroundColor: any;
};
};
'&.Mui-disabled': {
opacity: number;
};
};
};
};
};
};
export default _default;
declare type ThemeVars = {
[key: string]: any;
};
declare const _default: (customVariables: ThemeVars) => {
components: {
MuiCssBaseline: {
styleOverrides: string;
};
MuiList: {
styleOverrides: {
root: {
'&.customSwitch': {
padding: string;
background: any;
borderRadius: string;
display: string;
'& .MuiListItemButton-root': {
padding: string;
borderRadius: string;
width: string;
display: string;
alignItems: string;
justifyContent: string;
'&:not(:last-child)': {
marginBottom: string;
};
'&.Mui-disabled': {
opacity: number;
};
'&.Mui-selected': {
background: any;
boxShadow: any;
border: string;
'& .MuiTypography-root': {
color: any;
};
};
};
'& .MuiChip-root': {
marginLeft: string;
};
'& .MuiTypography-root': {
fontWeight: number;
fontSize: string;
lineHeight: string;
letterSpacing: string;
color: any;
margin: number;
};
};
};
};
};
MuiListItemIcon: {
styleOverrides: {
root: {
minWidth: string;
};
};
};
MuiListItemButton: {
styleOverrides: {
root: {
padding: number;
width: string;
height: string;
borderRadius: string;
justifyContent: string;
backgroundColor: any;
'&:hover': {
backgroundColor: any;
};
'&:not(:last-child)': {
marginBottom: string;
};
'&.Mui-selected': {
backgroundColor: any;
'&:hover': {
backgroundColor: any;
};
};
'&.Mui-disabled': {
opacity: number;
};
};
};
};
};
};
export default _default;
28 changes: 28 additions & 0 deletions example/components/assets/styles/variables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const nodeRed = {
nodeRedBackgroundColor: '#F4D4D4',
nodeRedTextColor: '#9D6666',
nodeRedBorderColor: 'rgba(157, 139, 102, 0.2)',
nodeRedBoxShadow: '0 0.25rem 0.625rem -0.25rem rgba(157, 139, 102, 0.3)',
};

const nodeBlue = {
nodeBlueBackgroundColor: '#D4E6F4',
nodeBlueTextColor: '#66829D',
nodeBlueBorderColor: 'rgba(102, 130, 157, 0.2)',
nodeBlueBoxShadow: '0 0.125rem 0.375rem -0.25rem rgba(102, 130, 157, 0.2)',
};

const nodeGray = {
nodeGrayBackgroundColor: '#E4E4E4',
nodeGrayTextColor: '#818181',
nodeGrayBorderColor: 'rgba(130, 130, 130, 0.2)',
nodeGrayBoxShadow: '0 0.25rem 0.625rem -0.25rem rgba(129, 129, 129, 0.3)',
};

const vars = {
...nodeRed,
...nodeBlue,
...nodeGray,
};

export default vars;
3 changes: 3 additions & 0 deletions example/components/assets/svg/icon-red.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/components/assets/svg/node/blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/components/assets/svg/node/gray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/components/assets/svg/node/red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 15 additions & 46 deletions example/components/widgets/CustomNodeWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,30 @@
import * as React from "react";
import {DiagramEngine, PortWidget} from "@projectstorm/react-diagrams";
import {DiagramEngine} from "@projectstorm/react-diagrams";
import {MetaNodeModel} from "../../../.";
import {Typography} from "@material-ui/core";
import {Box, Typography} from "@mui/material";
import NodeSelection from "./NodeSelection";

export interface CustomNodeWidgetProps {
model: MetaNodeModel;
engine: DiagramEngine;
}

export class CustomNodeWidget extends React.Component<CustomNodeWidgetProps> {

render() {
// @ts-ignore
const customNodeStyle = {
zIndex: 999999999,
border: "solid 2px gray",
borderRadius: "5px",
width: "250px",
height: "200px",
display: "flex",
alignItems: "flex-start",
justifyContent: "space-between",
position: "relative",
background: this.props.model.getOptions()['color'] || "darkgray",
top: this.props.model.getOptions()['position']?.y || 0,
left: this.props.model.getOptions()['position']?.x || 0
}
return (
<Box className={`primary-node ${this.props.model.getOptions()['variant']}`}>
{this.props.model.getOptions()['selected'] && (
<NodeSelection engine={this.props.engine} port={this.props.model} />
)}

const circlePortStyle = {
width: "12px",
height: "12px",
margin: "2px",
borderRadius: "4px",
background: "darkgray",
cursor: "pointer",
}
<Box className="primary-node_header">
<Box className="icon" />

return (
<>
<div style={customNodeStyle}>
<PortWidget
style={{position: 'absolute', top: '0px', left: '0px'}}
engine={this.props.engine}
port={this.props.model.getPort("in")}
>
<div style={circlePortStyle}/>
</PortWidget>
<PortWidget
style={{position: 'absolute', top: '0px', right: '0px'}}
engine={this.props.engine}
port={this.props.model.getPort("out")}
>
<div style={circlePortStyle}/>
</PortWidget>
<Typography>{this.props.model.getOptions()['name']}</Typography>
</div>
</>
<Typography component="p">
{this.props.model.getOptions()['name']}
</Typography>
</Box>
</Box>
);
}
}
Expand Down
37 changes: 37 additions & 0 deletions example/components/widgets/NodeSelection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Box, Button } from "@mui/material";
import { DiagramEngine, PortWidget } from "@projectstorm/react-diagrams";
import * as React from "react";
import PortWigetComp from "./PortWidgetComp";

export interface NodeSelectionProps {
engine: DiagramEngine;
port: any;
}

class NodeSelection extends React.Component<NodeSelectionProps> {
render() {
const { engine, port } = this.props;
const selectionPoint = '-0.375rem';
const IN = 'in';
const OUT = 'out';
return (
<>
<Button className="node-button">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@afonsobspinto @vidhya-metacell I would like to see this refactored , this is not so DRY (see https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)

<Box
className="icon"
/>
Show properties
</Button>

<Box className="nodes">
<PortWigetComp engine={engine} port={port} direction={IN} startPoints={{ left: selectionPoint, top: selectionPoint }} />
<PortWigetComp engine={engine} port={port} direction={OUT} startPoints={{ right: selectionPoint, top: selectionPoint }} />
<PortWigetComp engine={engine} port={port} direction={IN} startPoints={{ left: selectionPoint, bottom: selectionPoint }} />
<PortWigetComp engine={engine} port={port} direction={OUT} startPoints={{ right: selectionPoint, bottom: selectionPoint }} />
</Box>
</>
)
}
}

export default NodeSelection;
16 changes: 16 additions & 0 deletions example/components/widgets/PortWidgetComp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from "react";
import { Box } from "@mui/material";
import { PortWidget } from "@projectstorm/react-diagrams";

const PortWigetComp = (props) => {
const { engine, port, direction, startPoints } = props;
return (
<PortWidget
engine={engine}
port={port.getPort(direction)}
>
<Box style={startPoints} className="pointer" />
</PortWidget>
)
}
export default PortWigetComp;
Loading