Spaces:
Sleeping
Sleeping
Jon Taylor
commited on
Commit
·
24d8b3c
1
Parent(s):
dd10606
ui complete
Browse files- frontend/app/components/Card.js +1 -1
- frontend/app/components/Controls.js +19 -7
- frontend/app/hooks/debounce.js +31 -0
- frontend/app/layout.js +10 -10
- frontend/app/test/page.js +7 -7
frontend/app/components/Card.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
export default function Card({ children }) {
|
| 2 |
return (
|
| 3 |
<div className="rounded-xl bg-white border border-zinc-200 p-2 w-full max-w-3xl aspect-video">
|
| 4 |
-
<div className="overflow-hidden flex-1 h-full bg-zinc-50 rounded-md flex items-center justify-center">
|
| 5 |
{children}
|
| 6 |
</div>
|
| 7 |
</div>
|
|
|
|
| 1 |
export default function Card({ children }) {
|
| 2 |
return (
|
| 3 |
<div className="rounded-xl bg-white border border-zinc-200 p-2 w-full max-w-3xl aspect-video">
|
| 4 |
+
<div className="relative overflow-hidden flex-1 h-full bg-zinc-50 rounded-md flex items-center justify-center">
|
| 5 |
{children}
|
| 6 |
</div>
|
| 7 |
</div>
|
frontend/app/components/Controls.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
| 3 |
import {
|
| 4 |
Accordion,
|
| 5 |
ActionIcon,
|
| 6 |
-
Button,
|
| 7 |
SegmentedControl,
|
| 8 |
Textarea,
|
| 9 |
} from "@mantine/core";
|
|
@@ -14,7 +13,8 @@ import {
|
|
| 14 |
IconPlus,
|
| 15 |
IconRotateClockwise,
|
| 16 |
} from "@tabler/icons-react";
|
| 17 |
-
import React from "react";
|
|
|
|
| 18 |
import FieldSet from "./FieldSet";
|
| 19 |
import Label from "./Label";
|
| 20 |
import SelectInput from "./SelectInput";
|
|
@@ -33,6 +33,17 @@ export const Controls = React.memo(() => {
|
|
| 33 |
},
|
| 34 |
});
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
return (
|
| 37 |
<div className="flex flex-col gap-4">
|
| 38 |
<Accordion
|
|
@@ -61,7 +72,9 @@ export const Controls = React.memo(() => {
|
|
| 61 |
className="rounded-md"
|
| 62 |
minRows={3}
|
| 63 |
defaultValue={form.getInputProps("positivePrompt").value}
|
| 64 |
-
onChange={(
|
|
|
|
|
|
|
| 65 |
classNames={{
|
| 66 |
input:
|
| 67 |
"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",
|
|
@@ -80,7 +93,9 @@ export const Controls = React.memo(() => {
|
|
| 80 |
className="rounded-md"
|
| 81 |
minRows={3}
|
| 82 |
defaultValue={form.getInputProps("negativePrompt").value}
|
| 83 |
-
onChange={(
|
|
|
|
|
|
|
| 84 |
classNames={{
|
| 85 |
input:
|
| 86 |
"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",
|
|
@@ -173,9 +188,6 @@ export const Controls = React.memo(() => {
|
|
| 173 |
<Accordion.Panel>Control net</Accordion.Panel>
|
| 174 |
</Accordion.Item>
|
| 175 |
</Accordion>
|
| 176 |
-
<Button className="rounded-full" onClick={() => console.log(form.values)}>
|
| 177 |
-
Submit
|
| 178 |
-
</Button>
|
| 179 |
</div>
|
| 180 |
);
|
| 181 |
});
|
|
|
|
| 3 |
import {
|
| 4 |
Accordion,
|
| 5 |
ActionIcon,
|
|
|
|
| 6 |
SegmentedControl,
|
| 7 |
Textarea,
|
| 8 |
} from "@mantine/core";
|
|
|
|
| 13 |
IconPlus,
|
| 14 |
IconRotateClockwise,
|
| 15 |
} from "@tabler/icons-react";
|
| 16 |
+
import React, { useEffect } from "react";
|
| 17 |
+
import useDebounce from "../hooks/debounce";
|
| 18 |
import FieldSet from "./FieldSet";
|
| 19 |
import Label from "./Label";
|
| 20 |
import SelectInput from "./SelectInput";
|
|
|
|
| 33 |
},
|
| 34 |
});
|
| 35 |
|
| 36 |
+
const debounce = useDebounce();
|
| 37 |
+
|
| 38 |
+
const handleChange = (event) => {
|
| 39 |
+
console.log(event);
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
useEffect(() => {
|
| 43 |
+
if (!form) return;
|
| 44 |
+
form.isDirty() && debounce(() => handleChange(form.values), 500);
|
| 45 |
+
}, [form, debounce]);
|
| 46 |
+
|
| 47 |
return (
|
| 48 |
<div className="flex flex-col gap-4">
|
| 49 |
<Accordion
|
|
|
|
| 72 |
className="rounded-md"
|
| 73 |
minRows={3}
|
| 74 |
defaultValue={form.getInputProps("positivePrompt").value}
|
| 75 |
+
onChange={(e) =>
|
| 76 |
+
form.setFieldValue("positivePrompt", e.target.value)
|
| 77 |
+
}
|
| 78 |
classNames={{
|
| 79 |
input:
|
| 80 |
"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",
|
|
|
|
| 93 |
className="rounded-md"
|
| 94 |
minRows={3}
|
| 95 |
defaultValue={form.getInputProps("negativePrompt").value}
|
| 96 |
+
onChange={(e) =>
|
| 97 |
+
form.setFieldValue("negativePrompt", e.target.value)
|
| 98 |
+
}
|
| 99 |
classNames={{
|
| 100 |
input:
|
| 101 |
"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",
|
|
|
|
| 188 |
<Accordion.Panel>Control net</Accordion.Panel>
|
| 189 |
</Accordion.Item>
|
| 190 |
</Accordion>
|
|
|
|
|
|
|
|
|
|
| 191 |
</div>
|
| 192 |
);
|
| 193 |
});
|
frontend/app/hooks/debounce.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useCallback, useEffect, useRef } from "react";
|
| 2 |
+
|
| 3 |
+
export default function useDebounce() {
|
| 4 |
+
// Using a ref to store the current timeout identifier
|
| 5 |
+
// This is to ensure it persists across renders without causing re-renders
|
| 6 |
+
const timeoutRef = useRef(null);
|
| 7 |
+
|
| 8 |
+
// The debounce function
|
| 9 |
+
const debounce = useCallback((func, wait) => {
|
| 10 |
+
// Clear any existing timeout to ensure only the latest call is executed
|
| 11 |
+
if (timeoutRef.current) {
|
| 12 |
+
clearTimeout(timeoutRef.current);
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
// Set the new timeout
|
| 16 |
+
timeoutRef.current = setTimeout(() => {
|
| 17 |
+
func();
|
| 18 |
+
}, wait);
|
| 19 |
+
}, []);
|
| 20 |
+
|
| 21 |
+
// Cleanup function to clear the timeout when the component is unmounted
|
| 22 |
+
useEffect(() => {
|
| 23 |
+
return () => {
|
| 24 |
+
if (timeoutRef.current) {
|
| 25 |
+
clearTimeout(timeoutRef.current);
|
| 26 |
+
}
|
| 27 |
+
};
|
| 28 |
+
}, []);
|
| 29 |
+
|
| 30 |
+
return debounce;
|
| 31 |
+
}
|
frontend/app/layout.js
CHANGED
|
@@ -25,16 +25,16 @@ const theme = createTheme({
|
|
| 25 |
defaultRadius: "md",
|
| 26 |
colors: {
|
| 27 |
darkIndigo: [
|
| 28 |
-
"#
|
| 29 |
-
"#
|
| 30 |
-
"#
|
| 31 |
-
"#
|
| 32 |
-
"#
|
| 33 |
-
"#
|
| 34 |
-
"#
|
| 35 |
-
"#
|
| 36 |
-
"#
|
| 37 |
-
"#
|
| 38 |
],
|
| 39 |
},
|
| 40 |
primaryColor: "darkIndigo",
|
|
|
|
| 25 |
defaultRadius: "md",
|
| 26 |
colors: {
|
| 27 |
darkIndigo: [
|
| 28 |
+
"#e0e7ff",
|
| 29 |
+
"#c7d2fe",
|
| 30 |
+
"#a5b4fc",
|
| 31 |
+
"#818cf8",
|
| 32 |
+
"#6366f1",
|
| 33 |
+
"#4f46e5",
|
| 34 |
+
"#4338ca",
|
| 35 |
+
"#3730a3",
|
| 36 |
+
"#312e81",
|
| 37 |
+
"#1e1b4b",
|
| 38 |
],
|
| 39 |
},
|
| 40 |
primaryColor: "darkIndigo",
|
frontend/app/test/page.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
"use client";
|
| 2 |
|
| 3 |
-
import { ActionIcon } from "@mantine/core";
|
| 4 |
import {
|
| 5 |
IconDoorExit,
|
| 6 |
IconInfoSquareRoundedFilled,
|
|
@@ -57,14 +57,14 @@ export default function Test() {
|
|
| 57 |
|
| 58 |
<main className="w-full h-full flex flex-col max-w-lg xl:max-w-2xl 2xl:max-w-full 2xl:flex-row items-center justify-center p-6 gap-3">
|
| 59 |
<Card>
|
| 60 |
-
<
|
| 61 |
-
class="w-full aspect-video"
|
| 62 |
-
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
|
| 63 |
-
allowFullScreen
|
| 64 |
-
></iframe>
|
| 65 |
</Card>
|
| 66 |
<Card>
|
| 67 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
</Card>
|
| 69 |
</main>
|
| 70 |
|
|
|
|
| 1 |
"use client";
|
| 2 |
|
| 3 |
+
import { ActionIcon, LoadingOverlay } from "@mantine/core";
|
| 4 |
import {
|
| 5 |
IconDoorExit,
|
| 6 |
IconInfoSquareRoundedFilled,
|
|
|
|
| 57 |
|
| 58 |
<main className="w-full h-full flex flex-col max-w-lg xl:max-w-2xl 2xl:max-w-full 2xl:flex-row items-center justify-center p-6 gap-3">
|
| 59 |
<Card>
|
| 60 |
+
<Avatar />
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
</Card>
|
| 62 |
<Card>
|
| 63 |
+
<LoadingOverlay
|
| 64 |
+
visible={true}
|
| 65 |
+
zIndex={1000}
|
| 66 |
+
className="bg-zinc-300"
|
| 67 |
+
/>
|
| 68 |
</Card>
|
| 69 |
</main>
|
| 70 |
|