-
Notifications
You must be signed in to change notification settings - Fork 888
/
index.tsx
80 lines (72 loc) · 1.87 KB
/
index.tsx
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
import { Editor } from "~/Editor";
import { Generation } from "~/Generation";
import { Box } from "./Box";
import { Choose } from "./Choose";
import { Create } from "./Create";
import { Pagination } from "./Pagination";
import { Render } from "./Render";
import { Results } from "./Results";
export * from "./Dreams";
export type Dream = Editor.Entity.Definition<{
type: "dream";
outputID?: ID;
choicesPage?: number;
lastMode?: Editor.Canvas.Render.RenderMode;
}>;
export function Dream({ id }: { id: ID }) {
const [size, setSize] = useState({ width: 0, height: 0 });
const { input } = Generation.Image.Input.use(id);
return (
<Editor.Entity
id={id}
showBorder={false}
showHandles={false}
onSizeChange={setSize}
resizable={false}
sizeClamp={{
min: { width: 512, height: 512 },
max: input?.model.includes("xl")
? { width: 512, height: 512 }
: { width: 1024, height: 1024 },
}}
>
{Editor.Floating.use({
id,
...size,
content: <Box id={id} />,
})}
{Editor.Floating.use({
id: id + "pagination",
...size,
content: <Pagination id={id} />,
})}
{Editor.Floating.use({
id: id + "results",
...size,
content: <Results id={id} />,
})}
</Editor.Entity>
);
}
export declare namespace Dream {
export { Choose, Create, Pagination, Render, Results };
}
export namespace Dream {
Dream.Choose = Choose;
Dream.Create = Create;
Dream.Pagination = Pagination;
Dream.Render = Render;
Dream.Results = Results;
export const preset = (): Omit<Dream, "index"> => ({
id: ID.create(),
type: "dream",
x: 0,
y: 0,
width: 512,
height: 512,
locked: false,
visible: true,
outputID: undefined,
});
export const use = (id: string) => Editor.Entity.useType(id, "dream");
}