Compare commits

..
3 Commits
Author SHA1 Message Date
ari d250018c9a v0.0.11 2022-04-13 22:15:03 -04:00
ari 95af6392ba fixed styling 2022-04-13 22:14:24 -04:00
ari fedc6c889a added lazy saving 2022-04-13 22:06:38 -04:00
7 changed files with 55 additions and 21 deletions

No files matched your search

+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [0.0.11] - Zoom
- Added lazy saving
## [0.0.10] - Zoom
- Introducing Zoom!
+1 -1
View File
@@ -1,5 +1,5 @@
name: Shortumation
version: 0.0.10
version: 0.0.11
slug: shortumation
url: "https://github.com/asosnovsky/Shortumation"
description: "A homeassitant addon which provides better UI for automations & scripts."
@@ -27,7 +27,9 @@ const Template: ComponentStory<typeof AutomationEditor> = args => {
<AutomationEditor
{...args}
automation={state}
onUpdate={setState}
onUpdate={s => {
window.setTimeout(() => setState(s), 3000)
}}
/>
</div>
}
@@ -1,8 +1,8 @@
import "./index.css";
import { DAGBoardElmDims } from "components/DAGSvgs/DAGBoard";
import { ArrowIcon, ZoomIcon } from "components/Icons";
import { ArrowIcon, CheckMarkIcon, ZoomIcon } from "components/Icons";
import { SequenceNodes } from "components/SequenceNodes";
import { FC, useState } from "react";
import { FC, useEffect, useState } from "react";
import { AutomationData, AutomationSequenceNode } from "types/automations";
import useWindowSize from "utils/useWindowSize";
import { AutoInfoBox } from "./AutoInfoBox";
@@ -13,6 +13,7 @@ import { AutomationTrigger } from 'types/automations/triggers';
import { Modal } from "components/Modal";
import { NodeEditor } from "components/NodeEditor";
import { ButtonIcon } from "components/Icons/ButtonIcons";
import { Button } from "components/Inputs/Button";
interface TriggerEditorModalState {
trigger: AutomationTrigger;
@@ -25,10 +26,13 @@ interface Props {
}
export const AutomationEditor: FC<Props> = ({
dims,
automation,
onUpdate,
automation: propsAutos,
onUpdate: propsOnUpdate,
}) => {
// state
const [[autoChanged, automation], setAutomation] = useState<[
'unchanged' | 'changed' | 'loading', AutomationData]
>(['unchanged', propsAutos]);
const [zoomLevel, setZoomLevel] = useState(40);
const { ratioWbh } = useWindowSize();
const [closeInfo, setCloseInfo] = useState(false);
@@ -47,6 +51,12 @@ export const AutomationEditor: FC<Props> = ({
...automation,
trigger,
});
const onUpdate = (a: AutomationData) => setAutomation(['changed', a]);
// effects
useEffect(() => {
setAutomation(['unchanged', propsAutos]);
}, [propsAutos])
// render
return <div className={classes.root}>
@@ -75,14 +85,28 @@ export const AutomationEditor: FC<Props> = ({
<div className={classes.wrapper}>
<div className={classes.toolbar}>
<ZoomIcon className={classes.zoomImg} size={1} color="white" />
<input
type="number"
min={1} max={100} step={1}
className={classes.zoom}
value={zoomLevel}
onChange={z => setZoomLevel(z.target.valueAsNumber ?? 40)}
/>
<div style={{ display: 'flex' }}>
<ZoomIcon className={classes.zoomImg} size={1} color="white" />
<input
type="number"
min={1} max={100} step={1}
className={classes.zoom}
value={zoomLevel}
onChange={z => setZoomLevel(z.target.valueAsNumber ?? 40)}
/>
</div>
{autoChanged !== 'unchanged' && <Button
className={classes.saveBtn}
onClick={() => {
if (autoChanged === 'changed') {
setAutomation(['loading', automation]);
propsOnUpdate(automation);
}
}}
disabled={autoChanged !== 'changed'}
>
Save <CheckMarkIcon />
</Button>}
</div>
<SequenceNodes
zoomLevel={zoomLevel * 200 / 100 + 50}
@@ -36,14 +36,20 @@ export const useEditorStyles = createAppUseStyles<{
maxWidth: "3em",
},
zoomImg: {
// width: "1em",
},
toolbar: {
width: "100%",
display: "flex",
flexDirection: "row",
justifyContent: 'start',
justifyContent: 'space-between',
alignItems: "center",
},
saveBtn: {
display: "flex",
gap: '0.5em',
maxHeight: '1em',
justifyContent: 'center',
alignItems: 'center',
}
}))
@@ -15,9 +15,7 @@
}
.automation-list--viewer {
/* flex: 6; */
min-width: 100%;
max-width: 100%;
overflow: hidden;
}
/* list children: on hide */
+2 -2
View File
@@ -29,8 +29,8 @@ const commonInputStyle = (theme: AppTheme) => ({
export const useButtonStyles = createAppUseStyles<{}>(theme => ({
input: {
...commonInputStyle(theme).input,
paddingTop: '2%',
paddingBottom: '2%',
paddingTop: '1em',
paddingBottom: '1em',
cursor: 'pointer',
},
}));