Spaces:
Sleeping
Sleeping
File size: 6,677 Bytes
76b9248 dd10606 76b9248 dd10606 24d8b3c 76b9248 dd10606 76b9248 24d8b3c 76b9248 dd10606 24d8b3c dd10606 24d8b3c dd10606 76b9248 dd10606 76b9248 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
"use client";
import {
Accordion,
ActionIcon,
SegmentedControl,
Textarea,
} from "@mantine/core";
import { useForm } from "@mantine/form";
import {
IconArrowDownRight,
IconMinus,
IconPlus,
IconRotateClockwise,
} from "@tabler/icons-react";
import React, { useEffect } from "react";
import useDebounce from "../hooks/debounce";
import FieldSet from "./FieldSet";
import Label from "./Label";
import SelectInput from "./SelectInput";
import SlideInput from "./SliderInput";
import TextInput from "./TextInput";
export const Controls = React.memo(() => {
const form = useForm({
initialValues: {
positivePrompt: "some kind of prompt",
negativePrompt: "bad hands",
steps: 1,
guidance: 0.1,
seed: 45678,
resolution: "720",
},
});
const debounce = useDebounce();
const handleChange = (event) => {
console.log(event);
};
useEffect(() => {
if (!form) return;
form.isDirty() && debounce(() => handleChange(form.values), 500);
}, [form, debounce]);
return (
<div className="flex flex-col gap-4">
<Accordion
defaultValue="prompt"
classNames={{
chevron: "w-[20px] text-indigo-500",
label: "font-medium text-zinc-900",
control: "hover:bg-zinc-50",
item: "border-zinc-200",
}}
chevron={<IconArrowDownRight size={20} stroke={2} className="block" />}
>
<Accordion.Item value="prompt" key="prompt">
<Accordion.Control value="prompt">Prompt</Accordion.Control>
<Accordion.Panel>
<FieldSet>
<div className="flex flex-col">
<div className="flex flex-row items-center gap-2 mb-2">
<IconPlus size={20} stroke={1} className="text-emerald-500" />
<span className="font-mono uppercase text-xs tracking-wider text-emerald-600">
Positive Prompt
</span>
</div>
<Textarea
autosize
className="rounded-md"
minRows={3}
defaultValue={form.getInputProps("positivePrompt").value}
onChange={(e) =>
form.setFieldValue("positivePrompt", e.target.value)
}
classNames={{
input:
"p-3 font-mono text-emerald-800 bg-emerald-600/[0.07] border-emerald-500/30 focus:border-emerald-500 focus:ring-1 focus:ring-inset focus:ring-emerald-500",
}}
/>
</div>
<div className="flex flex-col">
<div className="flex flex-row items-center gap-2 mb-2">
<IconMinus size={20} stroke={1} className="text-rose-500" />
<span className="font-mono uppercase text-xs tracking-wider text-rose-600">
Negative Prompt
</span>
</div>
<Textarea
autosize
className="rounded-md"
minRows={3}
defaultValue={form.getInputProps("negativePrompt").value}
onChange={(e) =>
form.setFieldValue("negativePrompt", e.target.value)
}
classNames={{
input:
"p-3 font-mono text-rose-800 bg-rose-600/[0.07] border-rose-500/30 focus:border-rose-500 focus:ring-1 focus:ring-inset focus:ring-rose-500",
}}
/>
</div>
</FieldSet>
</Accordion.Panel>
</Accordion.Item>
<Accordion.Item value="camera" key="camera">
<Accordion.Control value="camera">Camera</Accordion.Control>
<Accordion.Panel>
<FieldSet>
<SelectInput label="Device" />
<div>
<Label>Resolution</Label>
<SegmentedControl
fullWidth
size="sm"
radius="xl"
defaultValue={"720"}
data={[
{ label: "480P", value: "480" },
{ label: "720P", value: "720" },
{ label: "1080P", value: "1080" },
]}
onChange={(v) => form.setFieldValue("resolution", v)}
/>
</div>
</FieldSet>
</Accordion.Panel>
</Accordion.Item>
<Accordion.Item value="diffusion" key="diffusion">
<Accordion.Control value="inference">Diffusion</Accordion.Control>
<Accordion.Panel>
<div className="flex flex-col gap-4">
<TextInput
label="Seed"
type="number"
fieldProps={form.getInputProps("seed")}
>
<ActionIcon
radius="sm"
variant="subtle"
onClick={() =>
form.setFieldValue(
"seed",
Math.floor(Math.random() * 100000001)
)
}
>
<IconRotateClockwise
style={{ width: "70%", height: "70%" }}
stroke={2}
/>
</ActionIcon>
</TextInput>
<SlideInput
label="Steps"
fieldProps={form.getInputProps("steps")}
step={1}
min={1}
max={15}
marks={[
{ value: 1, label: "Low" },
{ value: 15, label: "High" },
]}
/>
<SlideInput
label="Guidance"
fieldProps={form.getInputProps("guidance")}
step={0.001}
min={0}
max={30}
marks={[
{ value: 0, label: "None" },
{ value: 2.5, label: "Low" },
{ value: 7.5, label: "Normal" },
{ value: 12.5, label: "Strict" },
{ value: 17.5, label: "Very Strict" },
{ value: 30, label: "Max" },
]}
/>
</div>
</Accordion.Panel>
</Accordion.Item>
<Accordion.Item value="cn" key="cn">
<Accordion.Control value="cn">Control Net</Accordion.Control>
<Accordion.Panel>Control net</Accordion.Panel>
</Accordion.Item>
</Accordion>
</div>
);
});
Controls.displayName = "Controls";
export default Controls;
|