fixed up styling for autos
This commit is contained in:
1 parent
634f3e9219
commit
c256400518
9 files changed
+104
-107
No files matched your search
@@ -1,10 +1,69 @@
|
||||
.automation-editor--info-icon {
|
||||
.automation-editor {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper {
|
||||
flex: 1;
|
||||
padding: 0 0.5em 0 0.5em;
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper--toolbar {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper.unchanged>.automation-editor--flow-wrapper--toolbar {
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper.changed>.automation-editor--flow-wrapper--toolbar * {
|
||||
border-color: var(--change);
|
||||
color: var(--change)
|
||||
}
|
||||
|
||||
|
||||
.automation-editor--flow-wrapper--toolbar--save-btn {
|
||||
display: flex;
|
||||
gap: 0.5em;
|
||||
align-items: center;
|
||||
padding: 0.25em;
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper.changed>.automation-editor--flow-wrapper--flow {
|
||||
border-color: var(--change);
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper--flow {
|
||||
flex: 1;
|
||||
border: 1px solid var(--secondary-accent);
|
||||
margin: 0 0 0.5em 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.automation-editor--info-box {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.automation-editor--info-box--icon {
|
||||
position: absolute;
|
||||
right: 1.5em;
|
||||
right: 0em;
|
||||
bottom: 0.5em;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.automation-editor--info-box.hide>.automation-editor--info-icon {
|
||||
.automation-editor--info-box.hide>.automation-editor--info-box--icon {
|
||||
transform: rotate(180deg);
|
||||
z-index: 2;
|
||||
}
|
||||
@@ -36,6 +36,9 @@ const Template: ComponentStory<typeof AutomationEditor> = args => {
|
||||
</div>
|
||||
}
|
||||
|
||||
export const Loading = Template.bind({});
|
||||
|
||||
|
||||
export const Simple = Template.bind({})
|
||||
Simple.args = {
|
||||
...Simple.args,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { DAGAutomationFlow } from "components/DAGFlow";
|
||||
import { DAGAutomationFlowDims } from "components/DAGFlow/types";
|
||||
|
||||
interface Props {
|
||||
automation: AutomationData;
|
||||
automation?: AutomationData;
|
||||
dims: DAGAutomationFlowDims;
|
||||
onUpdate: (auto: AutomationData) => void;
|
||||
}
|
||||
@@ -30,22 +30,15 @@ export const AutomationEditor: FC<Props> = ({
|
||||
save,
|
||||
} = useAutomatioEditorState(propsAutos, propsOnUpdate);
|
||||
|
||||
const { ratioWbh } = useWindowSize();
|
||||
const [closeInfo, setCloseInfo] = useState(false);
|
||||
const { classes } = useEditorStyles({
|
||||
closeInfo,
|
||||
horizontalMode: ratioWbh < 0.75,
|
||||
autoChanged: state.status,
|
||||
});
|
||||
|
||||
|
||||
// render
|
||||
if (state.status === 'loading') {
|
||||
return <div className={classes.root}>
|
||||
return <div className="automation-editor loading">
|
||||
Loading...
|
||||
</div>
|
||||
}
|
||||
return <div className={classes.root}>
|
||||
return <div className="automation-editor">
|
||||
<AutoInfoBox
|
||||
className={closeInfo ? "hide" : "show"}
|
||||
metadata={state.data.metadata}
|
||||
@@ -53,17 +46,16 @@ export const AutomationEditor: FC<Props> = ({
|
||||
onUpdate={updateMetadata}
|
||||
>
|
||||
<ButtonIcon
|
||||
className={`${classes.infoIcon} automation-editor--info-icon`}
|
||||
className="automation-editor--info-box--icon"
|
||||
onClick={() => setCloseInfo(!closeInfo)}
|
||||
title={closeInfo ? "Show Metadata" : "Hide Metadata"}
|
||||
>{ArrowIcon}</ButtonIcon>
|
||||
</AutoInfoBox>
|
||||
|
||||
<div className={classes.wrapper}>
|
||||
<div className={classes.toolbar}>
|
||||
<span></span>
|
||||
<div className={["automation-editor--flow-wrapper", state.status].join(" ")}>
|
||||
<div className="automation-editor--flow-wrapper--toolbar">
|
||||
<Button
|
||||
className={classes.saveBtn}
|
||||
className={"automation-editor--flow-wrapper--toolbar--save-btn"}
|
||||
onClick={save}
|
||||
disabled={state.status !== 'changed'}
|
||||
>
|
||||
@@ -71,6 +63,7 @@ export const AutomationEditor: FC<Props> = ({
|
||||
</Button>
|
||||
</div>
|
||||
<DAGAutomationFlow
|
||||
className="automation-editor--flow-wrapper--flow"
|
||||
sequence={state.data.sequence}
|
||||
trigger={state.data.trigger}
|
||||
onSequenceUpdate={updateSequence}
|
||||
|
||||
@@ -12,7 +12,7 @@ export type EditorState = {
|
||||
export type EditorStatus = EditorState['status'];
|
||||
|
||||
export const useAutomatioEditorState = (
|
||||
automation: AutomationData,
|
||||
automation: AutomationData | undefined,
|
||||
onSave: (a: AutomationData) => void,
|
||||
) => {
|
||||
const [state, update] = useState<EditorState>({
|
||||
@@ -30,10 +30,12 @@ export const useAutomatioEditorState = (
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
update({
|
||||
status: 'unchanged',
|
||||
data: genEditorData(automation),
|
||||
})
|
||||
if (automation) {
|
||||
update({
|
||||
status: 'unchanged',
|
||||
data: genEditorData(automation),
|
||||
})
|
||||
}
|
||||
}, [automation]);
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
import { createAppUseStyles } from "styles/theme";
|
||||
|
||||
|
||||
export const useEditorStyles = createAppUseStyles<{
|
||||
closeInfo: boolean;
|
||||
horizontalMode: boolean;
|
||||
autoChanged: string;
|
||||
}>(theme => ({
|
||||
wrapper: {
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: "flex-end",
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
overflow: 'hidden',
|
||||
},
|
||||
root: ({ horizontalMode }) => ({
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
color: theme.primaryAccent,
|
||||
display: 'flex',
|
||||
flexDirection: horizontalMode ? 'column' : 'row',
|
||||
}),
|
||||
dag: {
|
||||
borderWidth: 1,
|
||||
borderStyle: 'solid',
|
||||
borderColor: theme.secondaryAccent,
|
||||
width: '100%',
|
||||
},
|
||||
infoIcon: ({ horizontalMode }) => ({
|
||||
bottom: horizontalMode ? '90%' : 10
|
||||
}),
|
||||
zoom: {
|
||||
backgroundColor: theme.secondary,
|
||||
color: theme.secondaryAccent,
|
||||
textAlign: 'center',
|
||||
maxWidth: "3em",
|
||||
},
|
||||
zoomImg: {
|
||||
|
||||
},
|
||||
toolbar: ({ autoChanged }) => ({
|
||||
width: "100%",
|
||||
height: autoChanged === 'changed' ? 'initial' : 0,
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: 'space-between',
|
||||
alignItems: "center",
|
||||
padding: "0.5em",
|
||||
borderBottom: autoChanged === 'changed' ? '1px solid var(--change)' : undefined,
|
||||
borderLeft: autoChanged === 'changed' ? '1px solid var(--change)' : undefined,
|
||||
}),
|
||||
saveBtn: ({ autoChanged }) => ({
|
||||
display: "flex",
|
||||
opacity: autoChanged === "changed" ? 1 : 0,
|
||||
height: autoChanged === "changed" ? undefined : 0,
|
||||
fontSize: autoChanged === "changed" ? undefined : 0,
|
||||
gap: '0.5em',
|
||||
maxHeight: '1em',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
borderColor: "var(--change) !important",
|
||||
color: "var(--change) !important",
|
||||
paddingTop: '1em !important',
|
||||
paddingBottom: '1em !important',
|
||||
}),
|
||||
}))
|
||||
@@ -2,8 +2,8 @@ import "styles/root.css";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { AutomationList } from ".";
|
||||
import { NODE_HEIGHT, NODE_WIDTH, ADD_HEIGHT, ADD_WIDTH, CIRCLE_SIZE, DISTANCE_FACTOR } from 'components/DAGSvgs/constants';
|
||||
import { createMockAuto } from "utils/mocks";
|
||||
import * as dgconst from 'components/DAGSvgs/constants';
|
||||
|
||||
export default {
|
||||
title: 'App/AutomationList',
|
||||
@@ -11,12 +11,14 @@ export default {
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
args: {
|
||||
dims: {
|
||||
nodeHeight: NODE_HEIGHT,
|
||||
nodeWidth: NODE_WIDTH,
|
||||
addHeight: ADD_HEIGHT,
|
||||
addWidth: ADD_WIDTH,
|
||||
circleSize: CIRCLE_SIZE,
|
||||
distanceFactor: DISTANCE_FACTOR,
|
||||
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 AutomationList>;
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
/* root elements */
|
||||
.automation-list--root {
|
||||
width : 100%;
|
||||
height : 100%;
|
||||
display : flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
overflow : hidden;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.automation-list--list {
|
||||
flex : 1;
|
||||
flex: 1;
|
||||
min-width: 400px;
|
||||
max-width: 400px;
|
||||
position : relative;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.automation-list--viewer {
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* list children: on hide */
|
||||
@@ -41,6 +42,6 @@
|
||||
|
||||
.automation-list--list-hide {
|
||||
position: absolute;
|
||||
bottom : 10px;
|
||||
right : 5px;
|
||||
}
|
||||
bottom: 0.5em;
|
||||
right: 0.5em;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { ArrowIcon } from "components/Icons";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { ApiService } from "apiService/core";
|
||||
import { AutomationListBox } from "./AutomationListBox";
|
||||
import { DAGAutomationFlowDims } from 'DAGFlow/types';
|
||||
|
||||
|
||||
interface AutomationListParams {
|
||||
@@ -15,7 +16,7 @@ interface AutomationListParams {
|
||||
onUpdate: (i: number, auto: AutomationData) => void;
|
||||
onAdd: (auto: AutomationData) => void;
|
||||
onRemove: (i: number) => void;
|
||||
dims: DAGBoardElmDims;
|
||||
dims: DAGAutomationFlowDims;
|
||||
}
|
||||
|
||||
export const AutomationList: FC<AutomationListParams> = ({
|
||||
|
||||
@@ -19,6 +19,7 @@ const nodeTypes = {
|
||||
}
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
sequence: AutomationSequenceNode[];
|
||||
trigger: AutomationTrigger[];
|
||||
dims: DAGAutomationFlowDims;
|
||||
@@ -27,6 +28,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export const DAGAutomationFlow: FC<Props> = ({
|
||||
className,
|
||||
sequence,
|
||||
trigger,
|
||||
onTriggerUpdate,
|
||||
@@ -103,6 +105,7 @@ export const DAGAutomationFlow: FC<Props> = ({
|
||||
{modalBody}
|
||||
</Modal>
|
||||
<ReactFlow
|
||||
className={className}
|
||||
nodeTypes={nodeTypes}
|
||||
snapToGrid
|
||||
onlyRenderVisibleElements
|
||||
|
||||
Reference in new issue
Block a user