cleaned up styling
This commit is contained in:
1 parent
38baac3acc
commit
e1c983e1d1
25 files changed
+257
-184
No files matched your search
@@ -8,7 +8,6 @@
|
|||||||
"@types/node": "^12.0.0",
|
"@types/node": "^12.0.0",
|
||||||
"@types/react": "^17.0.0",
|
"@types/react": "^17.0.0",
|
||||||
"@types/react-dom": "^17.0.0",
|
"@types/react-dom": "^17.0.0",
|
||||||
"chroma-js": "^2.1.2",
|
|
||||||
"jss": "^10.8.2",
|
"jss": "^10.8.2",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
|
|||||||
@@ -10,16 +10,7 @@ export default {
|
|||||||
component: AutomationEditor,
|
component: AutomationEditor,
|
||||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||||
args: {
|
args: {
|
||||||
dims: {
|
dims: dgconst.DEFAULT_DIMS
|
||||||
nodeHeight: dgconst.NODE_HEIGHT,
|
|
||||||
nodeWidth: dgconst.NODE_WIDTH,
|
|
||||||
distanceFactor: dgconst.DISTANCE_FACTOR,
|
|
||||||
circleSize: dgconst.CIRCLE_SIZE,
|
|
||||||
padding: {
|
|
||||||
x: dgconst.PADDING,
|
|
||||||
y: dgconst.PADDING,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} as ComponentMeta<typeof AutomationEditor>
|
} as ComponentMeta<typeof AutomationEditor>
|
||||||
|
|
||||||
@@ -43,6 +34,7 @@ export const Simple = Template.bind({})
|
|||||||
Simple.args = {
|
Simple.args = {
|
||||||
...Simple.args,
|
...Simple.args,
|
||||||
automation: {
|
automation: {
|
||||||
|
condition: [],
|
||||||
tags: {
|
tags: {
|
||||||
"Room": "Bathroom",
|
"Room": "Bathroom",
|
||||||
"For": "Toliet",
|
"For": "Toliet",
|
||||||
@@ -103,6 +95,7 @@ export const EmptyStart = Template.bind({})
|
|||||||
EmptyStart.args = {
|
EmptyStart.args = {
|
||||||
...EmptyStart.args,
|
...EmptyStart.args,
|
||||||
automation: {
|
automation: {
|
||||||
|
condition: [],
|
||||||
tags: {},
|
tags: {},
|
||||||
metadata: {
|
metadata: {
|
||||||
id: "random",
|
id: "random",
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
updateSequence,
|
updateSequence,
|
||||||
updateTrigger,
|
updateTrigger,
|
||||||
updateMetadata,
|
updateMetadata,
|
||||||
|
updateCondition,
|
||||||
save,
|
save,
|
||||||
} = useAutomatioEditorState(propsAutos, propsOnUpdate);
|
} = useAutomatioEditorState(propsAutos, propsOnUpdate);
|
||||||
|
|
||||||
@@ -64,8 +65,10 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
className="automation-editor--flow-wrapper--flow"
|
className="automation-editor--flow-wrapper--flow"
|
||||||
sequence={state.data.sequence}
|
sequence={state.data.sequence}
|
||||||
trigger={state.data.trigger}
|
trigger={state.data.trigger}
|
||||||
|
condition={state.data.condition}
|
||||||
onSequenceUpdate={updateSequence}
|
onSequenceUpdate={updateSequence}
|
||||||
onTriggerUpdate={updateTrigger}
|
onTriggerUpdate={updateTrigger}
|
||||||
|
onConditionUpdate={updateCondition}
|
||||||
dims={dims}
|
dims={dims}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export const useAutomatioEditorState = (
|
|||||||
return {
|
return {
|
||||||
updateTrigger: makeUpdate('trigger'),
|
updateTrigger: makeUpdate('trigger'),
|
||||||
updateSequence: makeUpdate('sequence'),
|
updateSequence: makeUpdate('sequence'),
|
||||||
|
updateCondition: makeUpdate('condition'),
|
||||||
updateMetadata: (metadata: AutomationMetadata, tags: Array<[string, string]>) => {
|
updateMetadata: (metadata: AutomationMetadata, tags: Array<[string, string]>) => {
|
||||||
if (state.status !== 'loading') {
|
if (state.status !== 'loading') {
|
||||||
update({
|
update({
|
||||||
@@ -80,6 +81,7 @@ const genEditorData = (automation: AutomationData) => {
|
|||||||
metadata,
|
metadata,
|
||||||
trigger,
|
trigger,
|
||||||
sequence,
|
sequence,
|
||||||
|
condition,
|
||||||
} = automation;
|
} = automation;
|
||||||
|
|
||||||
const tags: [string, string][] = Object.keys(automation.tags).map(tagName => [tagName, automation.tags[tagName]]);
|
const tags: [string, string][] = Object.keys(automation.tags).map(tagName => [tagName, automation.tags[tagName]]);
|
||||||
@@ -88,6 +90,7 @@ const genEditorData = (automation: AutomationData) => {
|
|||||||
metadata,
|
metadata,
|
||||||
trigger,
|
trigger,
|
||||||
sequence,
|
sequence,
|
||||||
|
condition,
|
||||||
tags,
|
tags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Styles } from "jss";
|
import { Styles } from "jss";
|
||||||
import Color from 'chroma-js';
|
|
||||||
import { createAppUseStyles } from "styles/theme";
|
import { createAppUseStyles } from "styles/theme";
|
||||||
|
|
||||||
export const useStyles = createAppUseStyles<{
|
export const useStyles = createAppUseStyles<{
|
||||||
@@ -26,9 +25,9 @@ export const useStyles = createAppUseStyles<{
|
|||||||
padding: 0,
|
padding: 0,
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: hasChildren? 'column' : 'row',
|
flexDirection: hasChildren ? 'column' : 'row',
|
||||||
}),
|
}),
|
||||||
title: ({hasChildren}) => ({
|
title: ({ hasChildren }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
border: hasChildren ? `1px solid ${theme.primaryAccent}` : 'none',
|
border: hasChildren ? `1px solid ${theme.primaryAccent}` : 'none',
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
@@ -36,7 +35,7 @@ export const useStyles = createAppUseStyles<{
|
|||||||
borderBottomLeftRadius: 0,
|
borderBottomLeftRadius: 0,
|
||||||
height: '100%',
|
height: '100%',
|
||||||
}),
|
}),
|
||||||
titleText: ({hasChildren}) => ({
|
titleText: ({ hasChildren }) => ({
|
||||||
background: theme.condition.primaryColor,
|
background: theme.condition.primaryColor,
|
||||||
border: `1px solid ${theme.primaryAccent}`,
|
border: `1px solid ${theme.primaryAccent}`,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
@@ -57,7 +56,7 @@ export const useStyles = createAppUseStyles<{
|
|||||||
left: -35,
|
left: -35,
|
||||||
top: 10,
|
top: 10,
|
||||||
},
|
},
|
||||||
modifyBtn: ({hasChildren}) => ({
|
modifyBtn: ({ hasChildren }) => ({
|
||||||
// styling
|
// styling
|
||||||
backgroundColor: theme.primary,
|
backgroundColor: theme.primary,
|
||||||
fill: theme.primaryAccent,
|
fill: theme.primaryAccent,
|
||||||
@@ -79,8 +78,8 @@ export const useStyles = createAppUseStyles<{
|
|||||||
|
|
||||||
// on hover
|
// on hover
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
backgroundColor: Color(theme.primary).brighten().hex(),
|
backgroundColor: theme.primaryLight,
|
||||||
fill: Color(theme.primaryAccent).brighten().hex(),
|
fill: theme.primaryAccentLight,
|
||||||
},
|
},
|
||||||
"&:hover $icon": {
|
"&:hover $icon": {
|
||||||
transform: "rotate(90deg)"
|
transform: "rotate(90deg)"
|
||||||
@@ -88,13 +87,13 @@ export const useStyles = createAppUseStyles<{
|
|||||||
}),
|
}),
|
||||||
icon: {},
|
icon: {},
|
||||||
deleteBtn,
|
deleteBtn,
|
||||||
children: ({hasChildren}) => ({
|
children: ({ hasChildren }) => ({
|
||||||
flex: 1,
|
flex: 1,
|
||||||
paddingLeft: hasChildren ? 50 : 10,
|
paddingLeft: hasChildren ? 50 : 10,
|
||||||
paddingRight: hasChildren ? 0 : 10,
|
paddingRight: hasChildren ? 0 : 10,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
border: `1px solid ${theme.primaryAccent}`,
|
border: `1px solid ${theme.primaryAccent}`,
|
||||||
borderBottomRightRadius: hasChildren ? 10 : 0,
|
borderBottomRightRadius: hasChildren ? 10 : 0,
|
||||||
borderBottomLeftRadius: hasChildren ? 10 : 0,
|
borderBottomLeftRadius: hasChildren ? 10 : 0,
|
||||||
@@ -114,8 +113,8 @@ export const useStyles = createAppUseStyles<{
|
|||||||
paddingRight: 20,
|
paddingRight: 20,
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
backgroundColor: Color(theme.primary).brighten().hex(),
|
backgroundColor: theme.primaryLight,
|
||||||
fill: Color(theme.primaryAccent).brighten().hex(),
|
fill: theme.primaryAccentLight,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
addBtn: {
|
addBtn: {
|
||||||
@@ -131,8 +130,8 @@ export const useStyles = createAppUseStyles<{
|
|||||||
paddingRight: 20,
|
paddingRight: 20,
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
backgroundColor: Color(theme.primary).brighten().hex(),
|
backgroundColor: theme.primaryLight,
|
||||||
fill: Color(theme.primaryAccent).brighten().hex(),
|
fill: theme.primaryAccentLight,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { Handle, Position, XYPosition } from 'react-flow-renderer';
|
|||||||
|
|
||||||
|
|
||||||
export interface DAGCircleProps {
|
export interface DAGCircleProps {
|
||||||
onEdit?: () => void;
|
|
||||||
onAdd?: () => void;
|
onAdd?: () => void;
|
||||||
onRemove?: () => void;
|
onRemove?: () => void;
|
||||||
size: number,
|
size: number,
|
||||||
@@ -28,7 +27,6 @@ export const makeFlowCircle = (
|
|||||||
export const DAGCircle: FC<{ data: DAGCircleProps }> = ({
|
export const DAGCircle: FC<{ data: DAGCircleProps }> = ({
|
||||||
data: {
|
data: {
|
||||||
size,
|
size,
|
||||||
onEdit,
|
|
||||||
onAdd,
|
onAdd,
|
||||||
onRemove,
|
onRemove,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
@@ -38,7 +36,7 @@ export const DAGCircle: FC<{ data: DAGCircleProps }> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { classes } = useCircleStyles({
|
const { classes } = useCircleStyles({
|
||||||
size,
|
size,
|
||||||
hasOnFunction: !!onEdit || !!onAdd,
|
hasOnFunction: !!onRemove || !!onAdd,
|
||||||
hasRemoveFunction: !!onRemove,
|
hasRemoveFunction: !!onRemove,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
});
|
});
|
||||||
@@ -47,18 +45,13 @@ export const DAGCircle: FC<{ data: DAGCircleProps }> = ({
|
|||||||
{!disableTarget && <Handle type="target" position={Position.Left} />}
|
{!disableTarget && <Handle type="target" position={Position.Left} />}
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
{
|
{
|
||||||
onEdit ?
|
onAdd ?
|
||||||
<PencilIcon
|
<AddIcon
|
||||||
size={70} units="%"
|
size={70} units="%"
|
||||||
className={classes.icon}
|
className={classes.icon}
|
||||||
onClick={onEdit}
|
onClick={onAdd}
|
||||||
/> : onAdd ?
|
/>
|
||||||
<AddIcon
|
: (backgroundColor || onRemove) ? "" : "else"
|
||||||
size={70} units="%"
|
|
||||||
className={classes.icon}
|
|
||||||
onClick={onAdd}
|
|
||||||
/>
|
|
||||||
: backgroundColor ? "" : "else"
|
|
||||||
}
|
}
|
||||||
{onRemove ? <TrashIcon className={classes.trashIcon} onClick={onRemove} /> : <></>}
|
{onRemove ? <TrashIcon className={classes.trashIcon} onClick={onRemove} /> : <></>}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import Color from "chroma-js";
|
|
||||||
import { PencilIcon } from "components/Icons"
|
import { PencilIcon } from "components/Icons"
|
||||||
import { NodeColor } from "types/graphs";
|
import { NodeColor } from "types/graphs";
|
||||||
import { useNodeStyles } from "./styles";
|
import { useNodeStyles } from "./styles";
|
||||||
@@ -14,22 +13,25 @@ export interface DAGNodeProps {
|
|||||||
color: NodeColor;
|
color: NodeColor;
|
||||||
label: string;
|
label: string;
|
||||||
hasInput?: boolean;
|
hasInput?: boolean;
|
||||||
|
accentBackground?: boolean;
|
||||||
}
|
}
|
||||||
export const DAGNode: FC<{ data: DAGNodeProps }> = ({
|
export const DAGNode: FC<{ data: DAGNodeProps }> = ({
|
||||||
data: {
|
data: {
|
||||||
label,
|
label,
|
||||||
height,
|
height,
|
||||||
width,
|
width,
|
||||||
onXClick = () => { },
|
onXClick,
|
||||||
onEditClick = () => { },
|
onEditClick = () => { },
|
||||||
color,
|
color,
|
||||||
hasInput = false,
|
hasInput = false,
|
||||||
|
accentBackground = false,
|
||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
const { classes, theme } = useNodeStyles({
|
const { classes, theme } = useNodeStyles({
|
||||||
color,
|
color,
|
||||||
nodeHeight: height,
|
nodeHeight: height,
|
||||||
nodeWidth: width,
|
nodeWidth: width,
|
||||||
|
accentBackground,
|
||||||
});
|
});
|
||||||
return <>
|
return <>
|
||||||
{hasInput && <Handle type="target" position={Position.Left} />}
|
{hasInput && <Handle type="target" position={Position.Left} />}
|
||||||
@@ -37,7 +39,7 @@ export const DAGNode: FC<{ data: DAGNodeProps }> = ({
|
|||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<div className={classes.inner}>
|
<div className={classes.inner}>
|
||||||
<div className={classes.leftEdge} onClick={onXClick}>
|
<div className={classes.leftEdge} onClick={onXClick}>
|
||||||
<button className={classes.buttonDelete}>X</button>
|
{!!onXClick && <button className={classes.buttonDelete}>X</button>}
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.textWrap}>
|
<div className={classes.textWrap}>
|
||||||
<span className={classes.text} title={label}>
|
<span className={classes.text} title={label}>
|
||||||
@@ -48,7 +50,7 @@ export const DAGNode: FC<{ data: DAGNodeProps }> = ({
|
|||||||
console.log('editing me', label, onEditClick, onEditClick())
|
console.log('editing me', label, onEditClick, onEditClick())
|
||||||
}}>
|
}}>
|
||||||
<button className={classes.buttonEdit}>
|
<button className={classes.buttonEdit}>
|
||||||
<PencilIcon size={1.1} color={Color(theme.primary).set('rgb.g', 200).hex()} />
|
<PencilIcon size={1.1} color={theme.green} />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { makeFlowCircle } from "./DAGCircle"
|
||||||
|
import { DAGAutomationFlowDims, FlowData } from "./types"
|
||||||
|
import { XYPosition } from 'react-flow-renderer';
|
||||||
|
|
||||||
|
export const makeAddButton = (
|
||||||
|
id: string,
|
||||||
|
position: XYPosition,
|
||||||
|
{
|
||||||
|
circleSize,
|
||||||
|
}: DAGAutomationFlowDims,
|
||||||
|
onAdd: () => void,
|
||||||
|
disableTarget: boolean = true,
|
||||||
|
) => makeFlowCircle(
|
||||||
|
id,
|
||||||
|
position,
|
||||||
|
{
|
||||||
|
size: circleSize,
|
||||||
|
onAdd,
|
||||||
|
disableSource: true,
|
||||||
|
disableTarget,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export const makeConditionPoint = (
|
||||||
|
id: string,
|
||||||
|
position: XYPosition,
|
||||||
|
{
|
||||||
|
padding,
|
||||||
|
conditionWidth,
|
||||||
|
conditionHeight,
|
||||||
|
nodeWidth,
|
||||||
|
nodeHeight,
|
||||||
|
circleSize,
|
||||||
|
distanceFactor,
|
||||||
|
}: DAGAutomationFlowDims,
|
||||||
|
totalConditions: number,
|
||||||
|
onEditClick: () => void,
|
||||||
|
) => ({
|
||||||
|
id,
|
||||||
|
type: 'dagnode',
|
||||||
|
position,
|
||||||
|
data: {
|
||||||
|
size: circleSize,
|
||||||
|
color: 'lblue',
|
||||||
|
accentBackground: true,
|
||||||
|
label: `${totalConditions} Condition${totalConditions !== 1 ? 's' : ''}`,
|
||||||
|
height: conditionHeight,
|
||||||
|
width: conditionWidth,
|
||||||
|
hasInput: true,
|
||||||
|
onEditClick,
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -12,16 +12,7 @@ export default {
|
|||||||
component: DAGAutomationFlow,
|
component: DAGAutomationFlow,
|
||||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||||
args: {
|
args: {
|
||||||
dims: {
|
dims: dgconst.DEFAULT_DIMS
|
||||||
nodeHeight: dgconst.NODE_HEIGHT,
|
|
||||||
nodeWidth: dgconst.NODE_WIDTH,
|
|
||||||
distanceFactor: dgconst.DISTANCE_FACTOR,
|
|
||||||
circleSize: dgconst.CIRCLE_SIZE,
|
|
||||||
padding: {
|
|
||||||
x: dgconst.PADDING,
|
|
||||||
y: dgconst.PADDING,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} as ComponentMeta<typeof DAGAutomationFlow>
|
} as ComponentMeta<typeof DAGAutomationFlow>
|
||||||
|
|
||||||
@@ -29,8 +20,8 @@ const Template: ComponentStory<typeof DAGAutomationFlow> = args => {
|
|||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
trigger: args.trigger,
|
trigger: args.trigger,
|
||||||
sequence: args.sequence,
|
sequence: args.sequence,
|
||||||
|
condition: args.condition,
|
||||||
})
|
})
|
||||||
console.log(state)
|
|
||||||
return <div className="page">
|
return <div className="page">
|
||||||
<DAGAutomationFlow
|
<DAGAutomationFlow
|
||||||
{...args}
|
{...args}
|
||||||
@@ -40,6 +31,7 @@ const Template: ComponentStory<typeof DAGAutomationFlow> = args => {
|
|||||||
setState({ ...state, trigger })
|
setState({ ...state, trigger })
|
||||||
}}
|
}}
|
||||||
onSequenceUpdate={sequence => setState({ ...state, sequence })}
|
onSequenceUpdate={sequence => setState({ ...state, sequence })}
|
||||||
|
onConditionUpdate={condition => setState({ ...state, condition })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -47,6 +39,7 @@ const Template: ComponentStory<typeof DAGAutomationFlow> = args => {
|
|||||||
export const Simple = Template.bind({})
|
export const Simple = Template.bind({})
|
||||||
Simple.args = {
|
Simple.args = {
|
||||||
...Simple.args,
|
...Simple.args,
|
||||||
|
condition: [],
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
"platform": "numeric_state",
|
"platform": "numeric_state",
|
||||||
@@ -90,6 +83,7 @@ Simple.args = {
|
|||||||
export const Complex = Template.bind({})
|
export const Complex = Template.bind({})
|
||||||
Complex.args = {
|
Complex.args = {
|
||||||
...Complex.args,
|
...Complex.args,
|
||||||
|
condition: [],
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
"platform": "numeric_state",
|
"platform": "numeric_state",
|
||||||
@@ -213,7 +207,7 @@ Complex.args = {
|
|||||||
export const EmptyStart = Template.bind({})
|
export const EmptyStart = Template.bind({})
|
||||||
EmptyStart.args = {
|
EmptyStart.args = {
|
||||||
...EmptyStart.args,
|
...EmptyStart.args,
|
||||||
trigger: [
|
condition: [],
|
||||||
],
|
trigger: [],
|
||||||
sequence: []
|
sequence: []
|
||||||
}
|
}
|
||||||
@@ -5,13 +5,15 @@ import { AutomationSequenceNode } from "types/automations";
|
|||||||
import { AutomationTrigger } from 'types/automations/triggers';
|
import { AutomationTrigger } from 'types/automations/triggers';
|
||||||
import { triggerToFlow } from "./triggerConvertor";
|
import { triggerToFlow } from "./triggerConvertor";
|
||||||
import { DAGNode } from "./DAGNode";
|
import { DAGNode } from "./DAGNode";
|
||||||
import { DAGAutomationFlowDims, FlowData, ModalState } from './types';
|
import { DAGAutomationFlowDims, FlowData, ModalState, UpdateModalState } from './types';
|
||||||
import { DAGCircle } from './DAGCircle';
|
import { DAGCircle } from './DAGCircle';
|
||||||
import { sequenceToFlow } from "./sequenceConvertor";
|
import { sequenceToFlow } from "./sequenceConvertor";
|
||||||
import { makeSequenceUpdater } from "./updater";
|
import { makeSequenceUpdater } from "./updater";
|
||||||
import { NodeEditor } from "components/NodeEditor";
|
import { NodeEditor } from "components/NodeEditor";
|
||||||
import { MultiNodeEditor } from "components/MultiNodeEditors";
|
import { MultiNodeEditor } from "components/MultiNodeEditors";
|
||||||
import { Modal } from "components/Modal";
|
import { Modal } from "components/Modal";
|
||||||
|
import { AutomationCondition } from "types/automations/conditions";
|
||||||
|
import { makeConditionPoint } from "./flowDataMods";
|
||||||
|
|
||||||
const nodeTypes = {
|
const nodeTypes = {
|
||||||
'dagnode': DAGNode,
|
'dagnode': DAGNode,
|
||||||
@@ -20,19 +22,23 @@ const nodeTypes = {
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
sequence: AutomationSequenceNode[];
|
|
||||||
trigger: AutomationTrigger[];
|
trigger: AutomationTrigger[];
|
||||||
|
condition: AutomationCondition[];
|
||||||
|
sequence: AutomationSequenceNode[];
|
||||||
dims: DAGAutomationFlowDims;
|
dims: DAGAutomationFlowDims;
|
||||||
onTriggerUpdate: (t: AutomationTrigger[]) => void;
|
onTriggerUpdate: (t: AutomationTrigger[]) => void;
|
||||||
onSequenceUpdate: (s: AutomationSequenceNode[]) => void;
|
onSequenceUpdate: (s: AutomationSequenceNode[]) => void;
|
||||||
|
onConditionUpdate: (s: AutomationCondition[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DAGAutomationFlow: FC<Props> = ({
|
export const DAGAutomationFlow: FC<Props> = ({
|
||||||
className,
|
className,
|
||||||
sequence,
|
|
||||||
trigger,
|
trigger,
|
||||||
|
condition,
|
||||||
|
sequence,
|
||||||
onTriggerUpdate,
|
onTriggerUpdate,
|
||||||
onSequenceUpdate,
|
onSequenceUpdate,
|
||||||
|
onConditionUpdate,
|
||||||
dims,
|
dims,
|
||||||
}) => {
|
}) => {
|
||||||
// state
|
// state
|
||||||
@@ -63,7 +69,14 @@ export const DAGAutomationFlow: FC<Props> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// convert automation to flow data
|
// convert automation to flow data
|
||||||
const condPoint = makeConditionPoint(dims);
|
const condPoint = makeConditionPoint('c', {
|
||||||
|
x: dims.padding.x + dims.nodeWidth * dims.distanceFactor,
|
||||||
|
y: dims.padding.y + dims.nodeHeight * 0.25
|
||||||
|
}, dims, condition.length, makeOnEditAutomationConditions(
|
||||||
|
condition,
|
||||||
|
onConditionUpdate,
|
||||||
|
setModalState,
|
||||||
|
));
|
||||||
const flowData: FlowData = {
|
const flowData: FlowData = {
|
||||||
nodes: [condPoint],
|
nodes: [condPoint],
|
||||||
edges: [],
|
edges: [],
|
||||||
@@ -94,7 +107,12 @@ export const DAGAutomationFlow: FC<Props> = ({
|
|||||||
flowData,
|
flowData,
|
||||||
sequence,
|
sequence,
|
||||||
condPoint.id,
|
condPoint.id,
|
||||||
dims,
|
{
|
||||||
|
...dims, padding: {
|
||||||
|
x: condPoint.position.x - dims.nodeWidth - dims.conditionWidth,
|
||||||
|
y: dims.padding.y,
|
||||||
|
}
|
||||||
|
},
|
||||||
makeSequenceUpdater(sequence, onSequenceUpdate, setModalState),
|
makeSequenceUpdater(sequence, onSequenceUpdate, setModalState),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -118,18 +136,13 @@ export const DAGAutomationFlow: FC<Props> = ({
|
|||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const makeOnEditAutomationConditions = (
|
||||||
const makeConditionPoint = ({
|
conditions: AutomationCondition[],
|
||||||
padding,
|
updateConditions: (c: AutomationCondition[]) => void,
|
||||||
nodeWidth,
|
openModal: UpdateModalState,
|
||||||
nodeHeight,
|
) => () => openModal({
|
||||||
circleSize,
|
single: false,
|
||||||
}: DAGAutomationFlowDims) => ({
|
node: conditions,
|
||||||
id: `c`,
|
allowedTypes: ['condition'],
|
||||||
type: 'dagcircle',
|
update: c => updateConditions(c as any),
|
||||||
position: { x: padding.x + nodeWidth * 2, y: padding.y + nodeHeight * 0.25 },
|
|
||||||
data: {
|
|
||||||
size: circleSize,
|
|
||||||
backgroundColor: 'blue',
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
@@ -6,6 +6,7 @@ import { ChooseAction } from 'types/automations/actions';
|
|||||||
import { makeFlowCircle } from './DAGCircle';
|
import { makeFlowCircle } from './DAGCircle';
|
||||||
import { createOnRemoveForChooseNode, SequenceUpdater } from './updater';
|
import { createOnRemoveForChooseNode, SequenceUpdater } from './updater';
|
||||||
import { getNodeType } from 'utils/automations';
|
import { getNodeType } from 'utils/automations';
|
||||||
|
import { makeAddButton, makeConditionPoint } from './flowDataMods';
|
||||||
|
|
||||||
|
|
||||||
export const sequenceToFlow = (
|
export const sequenceToFlow = (
|
||||||
@@ -56,13 +57,19 @@ export const sequenceToFlow = (
|
|||||||
lasPos = position;
|
lasPos = position;
|
||||||
}
|
}
|
||||||
// add button
|
// add button
|
||||||
const addCircle = makeFlowCircle(
|
const addCircle = makeAddButton(
|
||||||
`${prefix}-+`,
|
`${prefix}-+`,
|
||||||
{
|
{
|
||||||
x: (lasPos === null ? dims.padding.x + dims.nodeWidth * dims.distanceFactor * (sequence.length + 1) : lasPos.x) + dims.nodeWidth * dims.distanceFactor,
|
x: (
|
||||||
y: dims.padding.y + dims.circleSize / 2
|
lasPos === null ?
|
||||||
|
dims.padding.x + dims.nodeWidth * dims.distanceFactor * (sequence.length + 1) :
|
||||||
|
lasPos.x
|
||||||
|
) + dims.nodeWidth * dims.distanceFactor,
|
||||||
|
y: dims.padding.y + dims.circleSize / 4
|
||||||
},
|
},
|
||||||
{ onAdd: updater.addNode, size: dims.circleSize, disableSource: true, }
|
dims,
|
||||||
|
updater.addNode,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
flowData.nodes.push(addCircle)
|
flowData.nodes.push(addCircle)
|
||||||
addEdge(flowData, lastPointId, addCircle.id, false)
|
addEdge(flowData, lastPointId, addCircle.id, false)
|
||||||
@@ -130,12 +137,11 @@ const addChooseNode = (
|
|||||||
node.choose.forEach(({ sequence, conditions }, j) => {
|
node.choose.forEach(({ sequence, conditions }, j) => {
|
||||||
const sequenceId = `${nodeId}.${j}`;
|
const sequenceId = `${nodeId}.${j}`;
|
||||||
// edit/delete circle
|
// edit/delete circle
|
||||||
const circle = makeFlowCircle(`${sequenceId}>cond`, {
|
const circle = makeFlowCircle(`${sequenceId}>delete`, {
|
||||||
x: position.x + dims.nodeWidth * dims.distanceFactor,
|
x: position.x + dims.nodeWidth * dims.distanceFactor,
|
||||||
y: lastPos.y + dims.nodeHeight * dims.distanceFactor,
|
y: lastPos.y + dims.nodeHeight * dims.distanceFactor,
|
||||||
}, {
|
}, {
|
||||||
size: dims.circleSize * dims.distanceFactor,
|
size: dims.circleSize,
|
||||||
onEdit: updater.makeOnEditConditionsForChooseNode(i, j),
|
|
||||||
onRemove: createOnRemoveForChooseNode(
|
onRemove: createOnRemoveForChooseNode(
|
||||||
node,
|
node,
|
||||||
d => updater.updateNode(i, d),
|
d => updater.updateNode(i, d),
|
||||||
@@ -144,12 +150,25 @@ const addChooseNode = (
|
|||||||
})
|
})
|
||||||
flowData.nodes.push(circle)
|
flowData.nodes.push(circle)
|
||||||
addEdge(flowData, nodeId, circle.id, true)
|
addEdge(flowData, nodeId, circle.id, true)
|
||||||
|
const condNode = makeConditionPoint(
|
||||||
|
`${sequenceId}>cond`,
|
||||||
|
{
|
||||||
|
x: circle.position.x + dims.circleSize * dims.distanceFactor,
|
||||||
|
y: circle.position.y + dims.circleSize / 8,
|
||||||
|
},
|
||||||
|
dims,
|
||||||
|
conditions.length,
|
||||||
|
updater.makeOnEditConditionsForChooseNode(i, j)
|
||||||
|
);
|
||||||
|
flowData.nodes.push(condNode)
|
||||||
|
addEdge(flowData, circle.id, condNode.id, true)
|
||||||
|
|
||||||
// actual sub sequence
|
// actual sub sequence
|
||||||
const lastPoint = sequenceToFlow(flowData, sequence, circle.id, {
|
const lastPoint = sequenceToFlow(flowData, sequence, condNode.id, {
|
||||||
...dims,
|
...dims,
|
||||||
padding: {
|
padding: {
|
||||||
x: position.x - dims.nodeWidth,
|
x: condNode.position.x - (dims.nodeWidth + dims.conditionWidth),
|
||||||
y: circle.position.y,
|
y: condNode.position.y - dims.conditionHeight / 2,
|
||||||
},
|
},
|
||||||
}, updater.makeChildUpdaterForChooseAction(i, j), `${sequenceId}.`);
|
}, updater.makeChildUpdaterForChooseAction(i, j), `${sequenceId}.`);
|
||||||
if (lastPoint.position) {
|
if (lastPoint.position) {
|
||||||
@@ -161,41 +180,40 @@ const addChooseNode = (
|
|||||||
const totalChildren = node.choose.length;
|
const totalChildren = node.choose.length;
|
||||||
|
|
||||||
// add button
|
// add button
|
||||||
const addCirlce = makeFlowCircle(
|
const addCirlce = makeAddButton(
|
||||||
`${nodeId}>add`, {
|
`${nodeId}>add`,
|
||||||
x: position.x + dims.nodeWidth * dims.distanceFactor,
|
|
||||||
y: lastPos.y + dims.nodeHeight * dims.distanceFactor,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
size: dims.circleSize * dims.distanceFactor,
|
x: position.x + dims.nodeWidth * dims.distanceFactor,
|
||||||
onAdd: () => updater.updateNode(i, {
|
y: lastPos.y + dims.nodeHeight * dims.distanceFactor,
|
||||||
...node,
|
},
|
||||||
choose: [
|
dims,
|
||||||
...node.choose,
|
() => updater.updateNode(i, {
|
||||||
{
|
...node,
|
||||||
sequence: [],
|
choose: [
|
||||||
conditions: [],
|
...node.choose,
|
||||||
}
|
{
|
||||||
]
|
sequence: [],
|
||||||
}),
|
conditions: [],
|
||||||
disableSource: true,
|
}
|
||||||
}
|
]
|
||||||
|
}),
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
flowData.nodes.push(addCirlce)
|
flowData.nodes.push(addCirlce)
|
||||||
addEdge(flowData, nodeId, addCirlce.id, true)
|
addEdge(flowData, nodeId, addCirlce.id, true)
|
||||||
|
|
||||||
// default
|
// else
|
||||||
const elseCircle = makeFlowCircle(`${nodeId}>else`, {
|
const elseCircle = makeFlowCircle(`${nodeId}>else`, {
|
||||||
x: position.x + dims.nodeWidth * dims.distanceFactor,
|
x: position.x + dims.nodeWidth * dims.distanceFactor,
|
||||||
y: lastPos.y + dims.nodeHeight * dims.distanceFactor * 2,
|
y: lastPos.y + dims.nodeHeight * dims.distanceFactor * 2,
|
||||||
}, { size: dims.circleSize * dims.distanceFactor })
|
}, { size: dims.circleSize })
|
||||||
flowData.nodes.push(elseCircle)
|
flowData.nodes.push(elseCircle)
|
||||||
addEdge(flowData, nodeId, elseCircle.id, true)
|
addEdge(flowData, nodeId, elseCircle.id, true)
|
||||||
const lastPoint = sequenceToFlow(flowData, node.default, elseCircle.id, {
|
const lastPoint = sequenceToFlow(flowData, node.default, elseCircle.id, {
|
||||||
...dims,
|
...dims,
|
||||||
padding: {
|
padding: {
|
||||||
x: position.x - dims.nodeWidth,
|
x: position.x - dims.nodeWidth,
|
||||||
y: elseCircle.position.y,
|
y: elseCircle.position.y - dims.circleSize / 4,
|
||||||
},
|
},
|
||||||
}, updater.makeChildUpdaterForChooseAction(i, null), `${nodeId}.${totalChildren}.`)
|
}, updater.makeChildUpdaterForChooseAction(i, null), `${nodeId}.${totalChildren}.`)
|
||||||
if (lastPoint.position) {
|
if (lastPoint.position) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Styles } from "jss";
|
import { Styles } from "jss";
|
||||||
import Color from 'chroma-js';
|
|
||||||
import { createAppUseStyles } from "styles/theme";
|
import { createAppUseStyles } from "styles/theme";
|
||||||
import { NodeColor } from "types/graphs";
|
import { NodeColor } from "types/graphs";
|
||||||
|
|
||||||
@@ -7,6 +6,7 @@ export const useNodeStyles = createAppUseStyles<{
|
|||||||
color: NodeColor,
|
color: NodeColor,
|
||||||
nodeHeight: number,
|
nodeHeight: number,
|
||||||
nodeWidth: number,
|
nodeWidth: number,
|
||||||
|
accentBackground: boolean,
|
||||||
}>(theme => {
|
}>(theme => {
|
||||||
const edgeStyle: Styles = {
|
const edgeStyle: Styles = {
|
||||||
flex: '1',
|
flex: '1',
|
||||||
@@ -41,11 +41,12 @@ export const useNodeStyles = createAppUseStyles<{
|
|||||||
width: nodeWidth,
|
width: nodeWidth,
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
}),
|
}),
|
||||||
inner: ({ color }) => ({
|
inner: ({ color, accentBackground }) => ({
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
backgroundColor: theme.secondary,
|
backgroundColor: !accentBackground ? theme.secondary :
|
||||||
|
color === 'lblue' ? theme.condition.primaryColorOpaque : 'none',
|
||||||
borderRadius: '1em',
|
borderRadius: '1em',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
height: `100%`,
|
height: `100%`,
|
||||||
@@ -57,10 +58,11 @@ export const useNodeStyles = createAppUseStyles<{
|
|||||||
borderTopStyle: 'solid',
|
borderTopStyle: 'solid',
|
||||||
borderTopLeftRadius: '10px',
|
borderTopLeftRadius: '10px',
|
||||||
borderTopRightRadius: '10px',
|
borderTopRightRadius: '10px',
|
||||||
borderTopColor: color === 'red' ? Color(theme.secondary).set('rgb.r', 125).hex() :
|
borderTopColor: color === 'red' ? theme.redAccent :
|
||||||
color === 'blue' ? Color(theme.secondary).set('rgb.b', 125).hex() :
|
color === 'blue' ? theme.condition.primaryColor :
|
||||||
color === 'green' ? Color(theme.secondary).set('rgb.g', 125).hex() :
|
color === 'green' ? theme.green :
|
||||||
'none'
|
color === 'lblue' ? theme.condition.primaryAccent :
|
||||||
|
'none'
|
||||||
}),
|
}),
|
||||||
textWrap: {
|
textWrap: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -112,13 +114,14 @@ export const useCircleStyles = createAppUseStyles<{
|
|||||||
backgroundColor?: string,
|
backgroundColor?: string,
|
||||||
}>(theme => ({
|
}>(theme => ({
|
||||||
root: ({ size, hasOnFunction, hasRemoveFunction, backgroundColor }) => {
|
root: ({ size, hasOnFunction, hasRemoveFunction, backgroundColor }) => {
|
||||||
const baseColor = backgroundColor ? backgroundColor : Color(theme.primary).set('rgb.g', 100).hex();
|
const baseColor = backgroundColor ? backgroundColor : theme.green;
|
||||||
const hoverColor = (hasOnFunction && !hasRemoveFunction) ? Color(theme.primary).set('rgb.g', 150).hex() : baseColor
|
const hoverColor = hasOnFunction ? theme.greenOpaque : baseColor
|
||||||
return {
|
return {
|
||||||
backgroundColor: baseColor,
|
backgroundColor: baseColor,
|
||||||
borderRadius: hasRemoveFunction ? 10 : 500,
|
borderRadius: hasRemoveFunction ? 10 : 500,
|
||||||
height: size,
|
height: size,
|
||||||
width: size,
|
width: size,
|
||||||
|
color: theme.primary,
|
||||||
cursor: hasOnFunction ? "pointer" : 'default',
|
cursor: hasOnFunction ? "pointer" : 'default',
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
backgroundColor: hoverColor,
|
backgroundColor: hoverColor,
|
||||||
@@ -129,18 +132,7 @@ export const useCircleStyles = createAppUseStyles<{
|
|||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon: {
|
|
||||||
"&:hover": {
|
|
||||||
borderRadius: 500,
|
|
||||||
background: Color(theme.primary).set('rgb.g', 150).hex(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
trashIcon: {
|
trashIcon: {
|
||||||
padding: 1,
|
padding: 1,
|
||||||
"&:hover": {
|
|
||||||
borderRadius: 500,
|
|
||||||
background: Color(theme.primary).set('rgb.g', 150).hex(),
|
|
||||||
cursor: 'pointer',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@@ -1,20 +1,23 @@
|
|||||||
import { AutomationTrigger } from 'types/automations/triggers';
|
import { AutomationTrigger } from 'types/automations/triggers';
|
||||||
import { DAGAutomationFlowDims, FlowData, TriggerMakerOptions } from './types';
|
import { DAGAutomationFlowDims, FlowData, TriggerMakerOptions } from './types';
|
||||||
import { makeFlowCircle } from './DAGCircle';
|
import { makeFlowCircle } from './DAGCircle';
|
||||||
|
import { makeAddButton } from './flowDataMods';
|
||||||
|
|
||||||
export const triggerToFlow = (
|
export const triggerToFlow = (
|
||||||
flowData: FlowData,
|
flowData: FlowData,
|
||||||
trigger: AutomationTrigger[],
|
trigger: AutomationTrigger[],
|
||||||
toPoint: string,
|
toPoint: string,
|
||||||
{
|
dims: DAGAutomationFlowDims,
|
||||||
|
opts: TriggerMakerOptions,
|
||||||
|
) => {
|
||||||
|
const {
|
||||||
distanceFactor,
|
distanceFactor,
|
||||||
nodeHeight,
|
nodeHeight,
|
||||||
nodeWidth,
|
nodeWidth,
|
||||||
circleSize,
|
circleSize,
|
||||||
padding,
|
padding,
|
||||||
}: DAGAutomationFlowDims,
|
conditionHeight,
|
||||||
opts: TriggerMakerOptions,
|
} = dims;
|
||||||
) => {
|
|
||||||
// convert all triggers to dag nodes
|
// convert all triggers to dag nodes
|
||||||
trigger.forEach((t, i) => {
|
trigger.forEach((t, i) => {
|
||||||
const flowId = `t-${i}`;
|
const flowId = `t-${i}`;
|
||||||
@@ -39,19 +42,13 @@ export const triggerToFlow = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
// create a 'add button'
|
// create a 'add button'
|
||||||
flowData.nodes.push(makeFlowCircle(
|
flowData.nodes.push(makeAddButton(
|
||||||
'trigger-add',
|
'trigger-add',
|
||||||
{
|
{
|
||||||
x: padding.x + nodeWidth * 0.4,
|
x: padding.x + nodeWidth * 0.4,
|
||||||
y: padding.y + nodeHeight * distanceFactor * trigger.length,
|
y: padding.y + conditionHeight / 2 + nodeHeight * distanceFactor * trigger.length,
|
||||||
},
|
},
|
||||||
{
|
dims,
|
||||||
size: circleSize,
|
opts.onAdd
|
||||||
backgroundColor: 'green',
|
|
||||||
onAdd: opts.onAdd,
|
|
||||||
disableSource: true,
|
|
||||||
disableTarget: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,8 @@ export type DAGAutomationFlowDims = {
|
|||||||
padding: XYPosition;
|
padding: XYPosition;
|
||||||
nodeHeight: number;
|
nodeHeight: number;
|
||||||
nodeWidth: number;
|
nodeWidth: number;
|
||||||
|
conditionWidth: number;
|
||||||
|
conditionHeight: number;
|
||||||
circleSize: number;
|
circleSize: number;
|
||||||
distanceFactor: number;
|
distanceFactor: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export const makeSequenceUpdater = (
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
|
import { DAGAutomationFlowDims } from "components/DAGFlow/types";
|
||||||
|
|
||||||
export const NODE_WIDTH = 150 as const;
|
export const NODE_WIDTH = 150 as const;
|
||||||
export const NODE_HEIGHT = 60 as const;
|
export const NODE_HEIGHT = 60 as const;
|
||||||
export const ADD_HEIGHT = 10 as const;
|
export const CONDITION_HEIGHT = 30 as const;
|
||||||
export const ADD_WIDTH = 10 as const;
|
export const CONDITION_WIDTH = 120 as const;
|
||||||
export const CIRCLE_SIZE = 30 as const;
|
export const CIRCLE_SIZE = 40 as const;
|
||||||
export const DISTANCE_FACTOR = 1.5 as const;
|
export const DISTANCE_FACTOR = 1.5 as const;
|
||||||
export const PADDING = 50 as const;
|
export const PADDING = 50 as const;
|
||||||
|
|
||||||
export const DEFAULT_DIMS = {
|
export const DEFAULT_DIMS = {
|
||||||
nodeHeight: NODE_HEIGHT,
|
nodeHeight: NODE_HEIGHT,
|
||||||
nodeWidth: NODE_WIDTH,
|
nodeWidth: NODE_WIDTH,
|
||||||
|
conditionHeight: CONDITION_HEIGHT,
|
||||||
|
conditionWidth: CONDITION_WIDTH,
|
||||||
distanceFactor: DISTANCE_FACTOR,
|
distanceFactor: DISTANCE_FACTOR,
|
||||||
circleSize: CIRCLE_SIZE,
|
circleSize: CIRCLE_SIZE,
|
||||||
padding: {
|
padding: {
|
||||||
x: PADDING,
|
x: PADDING,
|
||||||
y: PADDING,
|
y: PADDING,
|
||||||
},
|
},
|
||||||
}
|
} as DAGAutomationFlowDims
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import { createAppUseStyles, AppTheme } from "styles/theme";
|
import { createAppUseStyles, AppTheme } from "styles/theme";
|
||||||
import Color from 'chroma-js';
|
|
||||||
|
|
||||||
const commonInputStyle = (theme: AppTheme) => ({
|
const commonInputStyle = (theme: AppTheme) => ({
|
||||||
input: {
|
input: {
|
||||||
@@ -251,8 +250,8 @@ export const useInputBubblesStyles = createAppUseStyles<{}>(theme => ({
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
border: `1px solid ${theme.primaryAccent}`,
|
border: `1px solid ${theme.primaryAccent}`,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
backgroundColor: Color(theme.primary).set('rgb.g', 150).alpha(0.35).hex(),
|
backgroundColor: theme.greenOpaque,
|
||||||
color: Color(theme.primary).brighten(5).hex(),
|
color: theme.primaryLight,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
|
|
||||||
marginLeft: 1,
|
marginLeft: 1,
|
||||||
@@ -262,8 +261,8 @@ export const useInputBubblesStyles = createAppUseStyles<{}>(theme => ({
|
|||||||
|
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
backgroundColor: Color(theme.primary).set('rgb.r', 150).alpha(0.35).hex(),
|
backgroundColor: theme.redOpaque,
|
||||||
color: Color(theme.primary).brighten(5).alpha(0.35).hex(),
|
color: theme.primaryLightOpaque,
|
||||||
},
|
},
|
||||||
|
|
||||||
"&:hover $deleteIcon": {
|
"&:hover $deleteIcon": {
|
||||||
@@ -291,7 +290,7 @@ export const useInputBubblesStyles = createAppUseStyles<{}>(theme => ({
|
|||||||
padding: "3px 7px",
|
padding: "3px 7px",
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
borderRadius: 100,
|
borderRadius: 100,
|
||||||
backgroundColor: Color(theme.primary).set('rgb.g', 150).alpha(0.35).hex(),
|
backgroundColor: theme.greenOpaque,
|
||||||
borderColor: theme.secondaryAccent,
|
borderColor: theme.secondaryAccent,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { createAppUseStyles } from "styles/theme";
|
import { createAppUseStyles } from "styles/theme";
|
||||||
import Color from 'chroma-js';
|
|
||||||
|
|
||||||
export interface ModalStyleProps {
|
export interface ModalStyleProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -26,7 +25,7 @@ const useModalStyle = createAppUseStyles<ModalStyleProps>(theme => ({
|
|||||||
width: '100vw',
|
width: '100vw',
|
||||||
top: 0,
|
top: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
backgroundColor: Color(theme.secondary).alpha(0.5).hex(),
|
backgroundColor: theme.secondaryOpaque,
|
||||||
},
|
},
|
||||||
inner: {
|
inner: {
|
||||||
zIndex: 10,
|
zIndex: 10,
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
:root {
|
:root {
|
||||||
--primary: #111111;
|
--primary: #111;
|
||||||
|
--primary-light: #333;
|
||||||
|
--primary-light-opaque: #3335;
|
||||||
|
--secondary-opaque: #1c1c1c;
|
||||||
--secondary: #1c1c1c;
|
--secondary: #1c1c1c;
|
||||||
--primary-accent: #bbbbbb;
|
--primary-accent: #bbb;
|
||||||
|
--primary-accent-light: #eee;
|
||||||
--secondary-accent: #929191;
|
--secondary-accent: #929191;
|
||||||
|
--green: #1f1;
|
||||||
|
--green-opaque: #1f15;
|
||||||
|
--green-light: #6f5;
|
||||||
--error: #c55;
|
--error: #c55;
|
||||||
|
--error-opaque: #c555;
|
||||||
|
--error-accent: #9f3a3a;
|
||||||
--change: #0f9;
|
--change: #0f9;
|
||||||
|
--condition-primary: #447;
|
||||||
|
--condition-accent: #8af;
|
||||||
|
--condition-primary-opaque: #4476;
|
||||||
touch-action: pan-x pan-y;
|
touch-action: pan-x pan-y;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-16
@@ -11,15 +11,25 @@ export const {
|
|||||||
ThemeProvider,
|
ThemeProvider,
|
||||||
useTheme,
|
useTheme,
|
||||||
} = createTheming(createContext({
|
} = createTheming(createContext({
|
||||||
primary: '#111111',
|
primary: 'var(--primary)',
|
||||||
secondary: '#1c1c1c',
|
primaryLight: 'var(--primary-light)',
|
||||||
primaryAccent: '#bbbbbb',
|
primaryLightOpaque: 'var(--primary-light-opaque)',
|
||||||
secondaryAccent: '#929191',
|
secondary: 'var(--secondary)',
|
||||||
|
secondaryOpaque: 'var(--secondary-opaque)',
|
||||||
|
primaryAccent: 'var(--primary-acccent)',
|
||||||
|
primaryAccentLight: 'var(--primary-acccent-light)',
|
||||||
|
secondaryAccent: 'var(--secondary-accent)',
|
||||||
condition: {
|
condition: {
|
||||||
primaryColor: '#4f4f77',
|
primaryColor: 'var(--condition-primary)',
|
||||||
|
primaryAccent: 'var(--condition-accent)',
|
||||||
|
primaryColorOpaque: 'var(--condition-primary-opaque)'
|
||||||
},
|
},
|
||||||
red: '#ed0c0c',
|
green: 'var(--green)',
|
||||||
redAccent: '#9f3a3a',
|
greenLight: 'var(--green-light)',
|
||||||
|
greenOpaque: 'var(--green-opaque)',
|
||||||
|
red: 'var(--error)',
|
||||||
|
redOpaque: 'var(--error-opaque)',
|
||||||
|
redAccent: 'var(--error-accent)',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export type GetThemeType<C extends Context<any>> = C extends Context<infer T> ? T : unknown;
|
export type GetThemeType<C extends Context<any>> = C extends Context<infer T> ? T : unknown;
|
||||||
@@ -28,12 +38,12 @@ export type AppTheme = GetThemeType<typeof ThemeContext>;
|
|||||||
export const createAppUseStyles = <
|
export const createAppUseStyles = <
|
||||||
Props extends {} = {},
|
Props extends {} = {},
|
||||||
C extends string = string,
|
C extends string = string,
|
||||||
>(f: (theme: AppTheme) => Styles<C, Props, AppTheme>) => (props: Props): {
|
>(f: (theme: AppTheme) => Styles<C, Props, AppTheme>) => (props: Props): {
|
||||||
classes: Classes<keyof Styles<C, Props, AppTheme>>,
|
classes: Classes<keyof Styles<C, Props, AppTheme>>,
|
||||||
theme: AppTheme,
|
theme: AppTheme,
|
||||||
} => {
|
} => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const useStyles = createUseStyles<C,Props,AppTheme>(f as any)
|
const useStyles = createUseStyles<C, Props, AppTheme>(f as any)
|
||||||
const classes = useStyles({...props, theme}) as Classes<keyof Styles<C, Props, AppTheme>>;
|
const classes = useStyles({ ...props, theme }) as Classes<keyof Styles<C, Props, AppTheme>>;
|
||||||
return {classes, theme};
|
return { classes, theme };
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ export interface AutomationMetadata {
|
|||||||
export interface AutomationData {
|
export interface AutomationData {
|
||||||
metadata: AutomationMetadata;
|
metadata: AutomationMetadata;
|
||||||
trigger: AutomationTrigger[];
|
trigger: AutomationTrigger[];
|
||||||
|
condition: AutomationCondition[];
|
||||||
sequence: AutomationSequenceNode[];
|
sequence: AutomationSequenceNode[];
|
||||||
tags: Record<string, string>;
|
tags: Record<string, string>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export type NodeColor = 'red' | 'blue' | 'green';
|
export type NodeColor = 'red' | 'blue' | 'green' | 'lblue';
|
||||||
@@ -58,4 +58,5 @@ export const defaultAutomation = (id: string): AutomationData => ({
|
|||||||
tags: {},
|
tags: {},
|
||||||
trigger: [],
|
trigger: [],
|
||||||
sequence: [],
|
sequence: [],
|
||||||
|
condition: [],
|
||||||
})
|
})
|
||||||
@@ -12,6 +12,7 @@ export const createMockAuto = (tags: Record<string, string> = {}): AutomationDat
|
|||||||
mode: 'single',
|
mode: 'single',
|
||||||
},
|
},
|
||||||
tags,
|
tags,
|
||||||
|
condition: [],
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
"platform": "numeric_state",
|
"platform": "numeric_state",
|
||||||
|
|||||||
@@ -6704,13 +6704,6 @@ chownr@^2.0.0:
|
|||||||
resolved "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz"
|
resolved "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz"
|
||||||
integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==
|
integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==
|
||||||
|
|
||||||
chroma-js@^2.1.2:
|
|
||||||
version "2.1.2"
|
|
||||||
resolved "https://registry.npmjs.org/chroma-js/-/chroma-js-2.1.2.tgz"
|
|
||||||
integrity sha512-ri/ouYDWuxfus3UcaMxC1Tfp3IE9K5iQzxc2hSxbBRVNQFut1UuGAsZmiAf2mOUubzGJwgMSv9lHg+XqLaz1QQ==
|
|
||||||
dependencies:
|
|
||||||
cross-env "^6.0.3"
|
|
||||||
|
|
||||||
chrome-trace-event@^1.0.2:
|
chrome-trace-event@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz"
|
resolved "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz"
|
||||||
@@ -7249,13 +7242,6 @@ create-require@^1.1.0:
|
|||||||
resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz"
|
resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz"
|
||||||
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==
|
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==
|
||||||
|
|
||||||
cross-env@^6.0.3:
|
|
||||||
version "6.0.3"
|
|
||||||
resolved "https://registry.npmjs.org/cross-env/-/cross-env-6.0.3.tgz"
|
|
||||||
integrity sha512-+KqxF6LCvfhWvADcDPqo64yVIB31gv/jQulX2NGzKS/g3GEVz6/pt4wjHFtFWsHMddebWD/sDthJemzM4MaAag==
|
|
||||||
dependencies:
|
|
||||||
cross-spawn "^7.0.0"
|
|
||||||
|
|
||||||
cross-spawn@7.0.3, cross-spawn@^7.0.0, cross-spawn@^7.0.2:
|
cross-spawn@7.0.3, cross-spawn@^7.0.0, cross-spawn@^7.0.2:
|
||||||
version "7.0.3"
|
version "7.0.3"
|
||||||
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz"
|
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz"
|
||||||
|
|||||||
Reference in new issue
Block a user