standardized rendering of inputs
This commit is contained in:
1 parent
32fd7f2dff
commit
53ec0d417b
10 files changed
+77
-53
No files matched your search
@@ -28,14 +28,19 @@ export default function NewNodeModal<T extends AutomationNodeType>({
|
||||
<div className="new-node-modal--inner" onClick={e => e.preventDefault()}>
|
||||
<div className="new-node-modal--title">Create {node_type[0].toUpperCase()}{node_type.slice(1)}</div>
|
||||
<div className="new-node-modal--body">
|
||||
<InputWrapper label="Type:">
|
||||
<InputList options={typeList[node_type]} current={selectedSubType} onChange={n => setSubType(n as NodeSubType)}/>
|
||||
</InputWrapper>
|
||||
<InputList label="Type:"
|
||||
options={typeList[node_type]}
|
||||
current={selectedSubType}
|
||||
onChange={n => setSubType(n as NodeSubType)}
|
||||
/>
|
||||
{stateManager.renderOptionList()}
|
||||
</div>
|
||||
<div className="new-node-modal--footer">
|
||||
<button className="secondary" onClick={() => onClose()}>Close</button>
|
||||
<button onClick={() => onCreate({} as any)}>Create</button>
|
||||
<button onClick={() => onClose()}>Close</button>
|
||||
<button onClick={() => onCreate({} as any)}
|
||||
disabled={!stateManager.isReady}>
|
||||
Create
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { SelectHTMLAttributes } from "react";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
|
||||
|
||||
export interface Props {
|
||||
@@ -7,12 +8,15 @@ export interface Props {
|
||||
onChange: (n: string) => void;
|
||||
id?: string;
|
||||
className?: string;
|
||||
label: string;
|
||||
}
|
||||
export default function InputList({current, options, onChange, ...selattr}: Props) {
|
||||
return <select {...selattr} value={current} onChange={e => {
|
||||
e.preventDefault();
|
||||
onChange(e.currentTarget.value);
|
||||
}}>
|
||||
{options.map((t, i) => <option id={String(i)} key={i}>{t}</option>)}
|
||||
</select>
|
||||
export default function InputList({current, options, onChange, label, ...selattr}: Props) {
|
||||
return <InputWrapper label={label}>
|
||||
<select {...selattr} value={current} onChange={e => {
|
||||
e.preventDefault();
|
||||
onChange(e.currentTarget.value);
|
||||
}}>
|
||||
{options.map((t, i) => <option id={String(i)} key={i}>{t}</option>)}
|
||||
</select>
|
||||
</InputWrapper>
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import InputWrapper from "./InputWrapper";
|
||||
|
||||
|
||||
export interface Props {
|
||||
label: string;
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
}
|
||||
export default function InputText({
|
||||
label, value, onChange
|
||||
}: Props) {
|
||||
return <InputWrapper label={label}>
|
||||
<input value={value} onChange={e => {
|
||||
e.preventDefault();
|
||||
onChange(e.target.value)
|
||||
}}/>
|
||||
</InputWrapper>
|
||||
}
|
||||
@@ -16,7 +16,6 @@ export default function AutomationNode({
|
||||
onXClick = () => {},
|
||||
}: PropsWithChildren<Props>) {
|
||||
const [isOpen, setOpen] = useState(initialOpenState);
|
||||
console.log(children);
|
||||
return <div className="automation-node">
|
||||
<div className="automation-node-inner">
|
||||
<div
|
||||
|
||||
Reference in new issue
Block a user