editable title
This commit is contained in:
1 parent
2ea96973ad
commit
1719148c58
6 files changed
+155
-5
No files matched your search
@@ -64,9 +64,9 @@
|
||||
left: -0.5em;
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper.changed>.automation-editor--flow-wrapper--toolbar * {
|
||||
.automation-editor--flow-wrapper.changed>.automation-editor--flow-wrapper--toolbar button {
|
||||
border-color: var(--mui-success-light);
|
||||
color: var(--mui-success-light)
|
||||
color: var(--mui-success-light);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import { DAGDims } from "components/DAGGraph/elements/types";
|
||||
import { DAGAutomationGraph } from "components/DAGGraph";
|
||||
import { InputAutoComplete } from "components/Inputs/InputAutoComplete";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { InputTextView } from "components/Inputs/InputTextView";
|
||||
|
||||
interface Props {
|
||||
automation?: AutomationData;
|
||||
@@ -100,7 +101,19 @@ export const AutomationEditor: FC<Props> = ({
|
||||
<div className="automation-editor--flow-wrapper--toolbar--title">
|
||||
<span className="automation-editor--flow-wrapper--toolbar--title--text">
|
||||
<div className="id">{state.data.metadata.id}</div>
|
||||
<b>{state.data.metadata.alias}</b>
|
||||
<InputTextView
|
||||
value={state.data.metadata.alias ?? ""}
|
||||
placeholder="Name"
|
||||
onChange={(alias) =>
|
||||
updateMetadata(
|
||||
{
|
||||
...state.data.metadata,
|
||||
alias,
|
||||
},
|
||||
state.data.tags
|
||||
)
|
||||
}
|
||||
/>
|
||||
</span>
|
||||
<InputList
|
||||
fullWidth={false}
|
||||
@@ -142,7 +155,19 @@ export const AutomationEditor: FC<Props> = ({
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<small>{state.data.metadata.description}</small>
|
||||
<InputTextView
|
||||
value={state.data.metadata.description ?? ""}
|
||||
placeholder="Description"
|
||||
onChange={(description) =>
|
||||
updateMetadata(
|
||||
{
|
||||
...state.data.metadata,
|
||||
description,
|
||||
},
|
||||
state.data.tags
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{!dims.flipped && (
|
||||
<Button
|
||||
|
||||
@@ -4,7 +4,7 @@ import TextField from "@mui/material/TextField";
|
||||
|
||||
export interface Props {
|
||||
textBoxFor?: string;
|
||||
label: string | JSX.Element;
|
||||
label?: string | JSX.Element;
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
onEnter?: () => void;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
.input-text-view {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-height: 2em;
|
||||
}
|
||||
|
||||
.input-text-view.edit .MuiFilledInput-input {
|
||||
padding-top: 0.5em;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
|
||||
|
||||
.input-text-view.edit .MuiSvgIcon-root {
|
||||
color: var(--mui-primary-light);
|
||||
}
|
||||
|
||||
.input-text-view.edit .MuiSvgIcon-root:hover {
|
||||
cursor: pointer;
|
||||
color: var(--mui-primary-main);
|
||||
}
|
||||
|
||||
.input-text-view.view .input-text-view--placeholder {
|
||||
color: var(--mui-grey-500);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
.input-text-view.view {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25em;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.input-text-view.view .input-text-view--edit {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
.input-text-view.view .input-text-view--edit:hover {
|
||||
transform: rotate(15deg);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import InputText from "./InputText";
|
||||
|
||||
import { InputTextView } from "./InputTextView";
|
||||
|
||||
export default {
|
||||
title: "Inputs/InputTextView",
|
||||
component: InputTextView,
|
||||
parameters: { actions: { argTypesRegex: "^on.*" } },
|
||||
args: {
|
||||
value: "example",
|
||||
},
|
||||
} as ComponentMeta<typeof InputTextView>;
|
||||
|
||||
export const Basic: ComponentStory<typeof InputTextView> = (args) => (
|
||||
<Page>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "1em",
|
||||
padding: "1em",
|
||||
}}
|
||||
>
|
||||
<InputTextView {...args} />
|
||||
<InputText {...args} />
|
||||
</div>
|
||||
</Page>
|
||||
);
|
||||
@@ -0,0 +1,54 @@
|
||||
import "./InputTextView.css";
|
||||
|
||||
import { FC, useState } from "react";
|
||||
import CheckCircleOutlineOutlinedIcon from "@mui/icons-material/CheckCircleOutlineOutlined";
|
||||
import ModeEditOutlineOutlinedIcon from "@mui/icons-material/ModeEditOutlineOutlined";
|
||||
import TextField from "@mui/material/TextField";
|
||||
|
||||
export type InputTextViewProps = {
|
||||
className?: string;
|
||||
value: string;
|
||||
onChange: (t: string) => void;
|
||||
initialViewMode?: boolean;
|
||||
placeholder?: string;
|
||||
};
|
||||
|
||||
export const InputTextView: FC<InputTextViewProps> = (props) => {
|
||||
const [viewMode, setViewMode] = useState(props.initialViewMode ?? true);
|
||||
|
||||
const className = [
|
||||
"input-text-view",
|
||||
viewMode ? "view" : "edit",
|
||||
props.className ?? "",
|
||||
].join(" ");
|
||||
|
||||
if (viewMode) {
|
||||
return (
|
||||
<div className={className} onClick={() => setViewMode(false)}>
|
||||
{!!props.value ? (
|
||||
props.value
|
||||
) : (
|
||||
<span className="input-text-view--placeholder">
|
||||
{props.placeholder}
|
||||
</span>
|
||||
)}
|
||||
<ModeEditOutlineOutlinedIcon className="input-text-view--edit" />
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<TextField
|
||||
className={className}
|
||||
placeholder={props.placeholder}
|
||||
variant="filled"
|
||||
value={props.value}
|
||||
onChange={(e) => props.onChange(e.target.value)}
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<CheckCircleOutlineOutlinedIcon onClick={() => setViewMode(true)} />
|
||||
),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user