diff --git a/web/src/components/AutomationEditor/styles.ts b/web/src/components/AutomationEditor/styles.ts
new file mode 100644
index 0000000..566caa8
--- /dev/null
+++ b/web/src/components/AutomationEditor/styles.ts
@@ -0,0 +1,135 @@
+import { Styles } from "jss";
+import Color from 'chroma-js';
+import { createAppUseStyles } from "~/styles/theme";
+import { Node } from "./types";
+
+
+export const useEditorStyles = createAppUseStyles(theme => ({
+ root: {
+ height: '99%',
+ width: '99%',
+ color: theme.primaryAccent,
+ display: 'flex',
+ flexDirection: 'row',
+ },
+ dag: {
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: theme.secondaryAccent,
+ width: '100%',
+ },
+ svg: {
+ height: '99%',
+ width: '99%',
+ padding: 0,
+ margin: 0,
+ },
+ circle: {
+ fill: Color(theme.secondary).set('rgb.b', 125).hex(),
+ },
+ infoBox: {
+ paddingLeft: '10px',
+ paddingRight: '10px',
+ display: 'flex',
+ flexDirection: 'column',
+ justifyContent: 'flex-start',
+ overflow: 'auto',
+ },
+ dagEdge: {
+ stroke: theme.secondaryAccent,
+ },
+}))
+
+export const useNodeStyles = createAppUseStyles<{
+ color: Node['color'],
+ nodeHeight: number,
+ nodeWidth: number,
+}>(theme => {
+ const edgeStyle: Styles = {
+ flex: '1',
+ display: 'flex',
+ flexDirection: 'column',
+ flexWrap: 'nowrap',
+ borderRadius: '1em',
+ justifyContent: 'space-around',
+ alignItems: 'center',
+ '&:hover': {
+ backgroundColor: theme.primaryAccent,
+ cursor: 'pointer',
+ }
+ }
+ const buttonStyle: Styles = {
+ fontSize: '8px',
+ backgroundColor: "rgba(0,0,0,0)",
+ color: theme.primaryAccent,
+ borderStyle: 'none',
+ height: '15px',
+ width: '15px',
+ cursor: 'pointer',
+ transition: "500ms east-out",
+ }
+ return {
+ root: {
+ display: 'flex',
+ flexDirection: 'column',
+ justifyContent: 'flex-end',
+ height: `100%`,
+ maxHeight: `100%`,
+ maxWidth: '100%',
+ width: '100%',
+ fontSize: 10,
+ },
+ inner: ({color}) => ({
+ position: 'relative',
+ display: 'flex',
+ flexDirection: 'row',
+ backgroundColor: theme.secondary,
+ borderRadius: '1em',
+ flex: 1,
+ height: `calc(100% - 10px)`,
+ maxHeight: `calc(100% - 10px)`,
+ maxWidth: '100%',
+ borderTopWidth: '1px',
+ borderTopStyle: 'solid',
+ borderTopLeftRadius: '10px',
+ borderTopRightRadius: '10px',
+ borderTopColor: color === 'red' ? Color(theme.secondary).set('rgb.r', 125).hex() :
+ color === 'blue' ? Color(theme.secondary).set('rgb.b', 125).hex() :
+ color === 'green' ? Color(theme.secondary).set('rgb.g', 125).hex() :
+ 'none'
+ }),
+ text: {
+ flex: 4,
+ display: 'flex',
+ textAlign: 'center',
+ justifyContent: 'center',
+ alignItems: 'center',
+ height: '100%',
+ maxHeight: '100%',
+ },
+ buttonDelete: {
+ ...buttonStyle,
+ "&:hover": {
+ color: theme.primary,
+ }
+ },
+ buttonEdit: {
+ ...buttonStyle,
+ "&:hover": {
+ transform: "rotate(45deg)"
+ }
+ },
+ leftEdge: {
+ ...edgeStyle,
+ borderLeft: `1px ${theme.secondaryAccent} solid`,
+ borderTopRightRadius: 0,
+ borderBottomRightRadius: 0,
+ },
+ rightEdge: {
+ ...edgeStyle,
+ borderRight: `1px ${theme.secondaryAccent} solid`,
+ borderTopLeftRadius: 0,
+ borderBottomLeftRadius: 0,
+ },
+ }
+})
\ No newline at end of file
diff --git a/web/src/components/SequenceEditor/index.stories.tsx b/web/src/components/SequenceEditor/index.stories.tsx
new file mode 100644
index 0000000..9845d15
--- /dev/null
+++ b/web/src/components/SequenceEditor/index.stories.tsx
@@ -0,0 +1,38 @@
+import { ComponentMeta, ComponentStory } from "@storybook/react";
+import { useState } from "react";
+import { AutomationAction } from "~/automations/types/actions";
+import { usePageTheme } from "~/styles/page";
+import { SequenceEditor } from ".";
+
+export default {
+ title: 'SequenceEditor',
+ component: SequenceEditor,
+ parameters: { actions: { argTypesRegex: '^on.*' } },
+ } as ComponentMeta
;
+
+
+const Template: ComponentStory = ({node, ...args}) => {
+ const {classes} = usePageTheme({});
+ const [data, setData] = useState(node);
+ return
+ {
+ setData(data)
+ }}
+ />
+
+}
+
+export const ServiceAction = Template.bind({})
+ServiceAction.args = {
+ node: {
+ $smType: 'action',
+ action: 'service',
+ action_data: {
+ service: 'switch.toggle',
+ data: {},
+ target: {},
+ }
+ } as AutomationAction
+}
\ No newline at end of file
diff --git a/web/src/components/SequenceEditor/index.tsx b/web/src/components/SequenceEditor/index.tsx
index 753a7b5..d4c1741 100644
--- a/web/src/components/SequenceEditor/index.tsx
+++ b/web/src/components/SequenceEditor/index.tsx
@@ -1,14 +1,18 @@
import { FC } from "react";
-import { AutomationSequenceNode } from "~/automations/types";
+import { AutomationAction } from "~/automations/types/actions";
export const SequenceEditor: FC<{
- node: AutomationSequenceNode
-}> = ({}) => {
+ node: AutomationAction,
+ onUpdate: (u: AutomationAction) => void,
+}> = ({
+ node,
+ onUpdate,
+}) => {
return
}
\ No newline at end of file
diff --git a/web/src/icons/IconBase.tsx b/web/src/icons/IconBase.tsx
index c6fc132..b875913 100644
--- a/web/src/icons/IconBase.tsx
+++ b/web/src/icons/IconBase.tsx
@@ -3,21 +3,30 @@ import { createAppUseStyles } from "~/styles/theme";
-export const useIconStyles = createAppUseStyles(theme => ({
- icon: {
- height: '1em',
- width: '1em',
+export const useIconStyles = createAppUseStyles<{size: number, color?: string}>(theme => ({
+ icon: ({size}) => ({
+ height: `${size}em`,
+ width: `${size}em`,
display: 'flex',
- },
- svg: {
- fill: theme.primaryAccent
- }
+ }),
+ svg: ({color=theme.primaryAccent}) => ({
+ fill: color
+ })
}))
-export const IconBase: FC & {
- viewBox: string;
-}> = ({children, viewBox, className="", ...props}) => {
- const {classes} = useIconStyles({});
+export type IconBaseProps = AnchorHTMLAttributes & {
+ size?: number;
+ color?: string;
+}
+export const IconBase: FC = ({
+ children,
+ viewBox,
+ size=1,
+ color,
+ className="",
+ ...props
+}) => {
+ const {classes} = useIconStyles({ size, color });
return