Spaces:
Runtime error
Runtime error
Esteves Enzo
commited on
Commit
·
81969cf
1
Parent(s):
99680d5
open modal once img has been generated
Browse files
components/header.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
import Image from "next/image";
|
| 3 |
|
| 4 |
import HeaderImage from "@/assets/images/header.svg";
|
|
|
|
| 5 |
|
| 6 |
import { useInputGeneration } from "@/components/main/hooks/useInputGeneration";
|
| 7 |
import classNames from "classnames";
|
|
@@ -12,20 +13,18 @@ export const Header = () => {
|
|
| 12 |
return (
|
| 13 |
<header
|
| 14 |
className={classNames(
|
| 15 |
-
"
|
| 16 |
{
|
| 17 |
"!max-h-[0px]": hasMadeFirstGeneration,
|
| 18 |
"max-h-[450px]": !hasMadeFirstGeneration,
|
| 19 |
}
|
| 20 |
)}
|
| 21 |
>
|
| 22 |
-
<div className="relative bg-cover bg-fixed
|
| 23 |
-
<div className="flex items-start px-6 mx-auto max-w-[1722px] relative
|
| 24 |
<div className="w-full lg:w-1/2 relative z-10">
|
| 25 |
<h1 className="font-bold text-5xl lg:text-7xl text-white text-center lg:text-left">
|
| 26 |
-
Fast Stable
|
| 27 |
-
Diffusion XL <br className="hidden lg:block" />
|
| 28 |
-
on TPU v5e ⚡
|
| 29 |
</h1>
|
| 30 |
</div>
|
| 31 |
<Image
|
|
|
|
| 2 |
import Image from "next/image";
|
| 3 |
|
| 4 |
import HeaderImage from "@/assets/images/header.svg";
|
| 5 |
+
import HeaderImageMesh from "@/assets/images/header-mesh.png";
|
| 6 |
|
| 7 |
import { useInputGeneration } from "@/components/main/hooks/useInputGeneration";
|
| 8 |
import classNames from "classnames";
|
|
|
|
| 13 |
return (
|
| 14 |
<header
|
| 15 |
className={classNames(
|
| 16 |
+
"z-[1] transition-all duration-1000 overflow-hidden",
|
| 17 |
{
|
| 18 |
"!max-h-[0px]": hasMadeFirstGeneration,
|
| 19 |
"max-h-[450px]": !hasMadeFirstGeneration,
|
| 20 |
}
|
| 21 |
)}
|
| 22 |
>
|
| 23 |
+
<div className="relative bg-cover bg-fixed z-[1]">
|
| 24 |
+
<div className="flex items-start px-6 mx-auto max-w-[1722px] relative py-32">
|
| 25 |
<div className="w-full lg:w-1/2 relative z-10">
|
| 26 |
<h1 className="font-bold text-5xl lg:text-7xl text-white text-center lg:text-left">
|
| 27 |
+
Fast Stable Diffusion XL on TPU v5e ⚡
|
|
|
|
|
|
|
| 28 |
</h1>
|
| 29 |
</div>
|
| 30 |
<Image
|
components/main/collections/index.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import classNames from "classnames";
|
| 2 |
import { createBreakpoint } from "react-use";
|
| 3 |
import { AnimatePresence } from "framer-motion";
|
|
@@ -7,12 +8,12 @@ import { useCollections } from "@/components/main/hooks/useCollections";
|
|
| 7 |
import { Modal } from "@/components/modal/modal";
|
| 8 |
import { Collection } from "./collection";
|
| 9 |
import { CollectionLoading } from "./loading";
|
| 10 |
-
import {
|
| 11 |
|
| 12 |
const useBreakpoint = createBreakpoint({ XL: 1280, L: 1024, S: 768, XS: 640 });
|
| 13 |
|
| 14 |
export const Collections: React.FC<{ category: string }> = ({ category }) => {
|
| 15 |
-
const
|
| 16 |
const { collections, loading } = useCollections(category);
|
| 17 |
const breakpoint = useBreakpoint();
|
| 18 |
|
|
|
|
| 1 |
+
import { useState } from "react";
|
| 2 |
import classNames from "classnames";
|
| 3 |
import { createBreakpoint } from "react-use";
|
| 4 |
import { AnimatePresence } from "framer-motion";
|
|
|
|
| 8 |
import { Modal } from "@/components/modal/modal";
|
| 9 |
import { Collection } from "./collection";
|
| 10 |
import { CollectionLoading } from "./loading";
|
| 11 |
+
import { useCollection } from "@/components/modal/useCollection";
|
| 12 |
|
| 13 |
const useBreakpoint = createBreakpoint({ XL: 1280, L: 1024, S: 768, XS: 640 });
|
| 14 |
|
| 15 |
export const Collections: React.FC<{ category: string }> = ({ category }) => {
|
| 16 |
+
const { open, setOpen } = useCollection();
|
| 17 |
const { collections, loading } = useCollections(category);
|
| 18 |
const breakpoint = useBreakpoint();
|
| 19 |
|
components/main/hooks/useInputGeneration.ts
CHANGED
|
@@ -4,8 +4,10 @@ import { useLocalStorage } from 'react-use';
|
|
| 4 |
|
| 5 |
import { Collection } from "@/utils/type"
|
| 6 |
import list_styles from "@/assets/list_styles.json"
|
|
|
|
| 7 |
|
| 8 |
export const useInputGeneration = () => {
|
|
|
|
| 9 |
const [myGenerationsId, setGenerationsId] = useLocalStorage<any>('my-own-generations', []);
|
| 10 |
const [style, setStyle] = useState<string>(list_styles[0].name)
|
| 11 |
|
|
@@ -61,7 +63,7 @@ export const useInputGeneration = () => {
|
|
| 61 |
})
|
| 62 |
|
| 63 |
setGenerationsId(myGenerationsId?.length ? [...myGenerationsId, data?.blob?.id] : [data?.blob?.id])
|
| 64 |
-
|
| 65 |
return data ?? {}
|
| 66 |
},
|
| 67 |
)
|
|
|
|
| 4 |
|
| 5 |
import { Collection } from "@/utils/type"
|
| 6 |
import list_styles from "@/assets/list_styles.json"
|
| 7 |
+
import { useCollection } from "@/components/modal/useCollection";
|
| 8 |
|
| 9 |
export const useInputGeneration = () => {
|
| 10 |
+
const { setOpen } = useCollection();
|
| 11 |
const [myGenerationsId, setGenerationsId] = useLocalStorage<any>('my-own-generations', []);
|
| 12 |
const [style, setStyle] = useState<string>(list_styles[0].name)
|
| 13 |
|
|
|
|
| 63 |
})
|
| 64 |
|
| 65 |
setGenerationsId(myGenerationsId?.length ? [...myGenerationsId, data?.blob?.id] : [data?.blob?.id])
|
| 66 |
+
setOpen(data?.blob?.id)
|
| 67 |
return data ?? {}
|
| 68 |
},
|
| 69 |
)
|
components/modal/modal.tsx
CHANGED
|
@@ -31,7 +31,7 @@ const dropIn = {
|
|
| 31 |
};
|
| 32 |
|
| 33 |
export const Modal: React.FC<Props> = ({ id, onClose }) => {
|
| 34 |
-
const collection = useCollection(id);
|
| 35 |
|
| 36 |
if (!collection) return null;
|
| 37 |
|
|
|
|
| 31 |
};
|
| 32 |
|
| 33 |
export const Modal: React.FC<Props> = ({ id, onClose }) => {
|
| 34 |
+
const { collection } = useCollection(id);
|
| 35 |
|
| 36 |
if (!collection) return null;
|
| 37 |
|
components/modal/useCollection.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
| 1 |
import { useMemo, useState } from "react"
|
| 2 |
-
import { useQueryClient } from "@tanstack/react-query"
|
| 3 |
|
| 4 |
import { Collection } from "@/utils/type"
|
| 5 |
|
| 6 |
-
export const useCollection = (id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
const client = useQueryClient()
|
| 8 |
|
| 9 |
const collection = useMemo(() => {
|
|
@@ -13,5 +23,9 @@ export const useCollection = (id: number) => {
|
|
| 13 |
return collections.find((collection) => collection.id === id)
|
| 14 |
}, [id])
|
| 15 |
|
| 16 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
}
|
|
|
|
| 1 |
import { useMemo, useState } from "react"
|
| 2 |
+
import { useQuery, useQueryClient } from "@tanstack/react-query"
|
| 3 |
|
| 4 |
import { Collection } from "@/utils/type"
|
| 5 |
|
| 6 |
+
export const useCollection = (id?: number) => {
|
| 7 |
+
const { data: open } = useQuery(["modal"], () => {
|
| 8 |
+
return null
|
| 9 |
+
}, {
|
| 10 |
+
refetchOnWindowFocus: false,
|
| 11 |
+
refetchOnMount: false,
|
| 12 |
+
refetchOnReconnect: false,
|
| 13 |
+
initialData: null
|
| 14 |
+
})
|
| 15 |
+
const setOpen = (id: number | null) => client.setQueryData(["modal"], () => id)
|
| 16 |
+
|
| 17 |
const client = useQueryClient()
|
| 18 |
|
| 19 |
const collection = useMemo(() => {
|
|
|
|
| 23 |
return collections.find((collection) => collection.id === id)
|
| 24 |
}, [id])
|
| 25 |
|
| 26 |
+
return {
|
| 27 |
+
collection,
|
| 28 |
+
open,
|
| 29 |
+
setOpen
|
| 30 |
+
}
|
| 31 |
}
|
prisma/schema.prisma
CHANGED
|
@@ -4,7 +4,7 @@ generator client {
|
|
| 4 |
|
| 5 |
datasource db {
|
| 6 |
provider = "sqlite"
|
| 7 |
-
url = "file
|
| 8 |
}
|
| 9 |
|
| 10 |
model Image {
|
|
|
|
| 4 |
|
| 5 |
datasource db {
|
| 6 |
provider = "sqlite"
|
| 7 |
+
url = "file:../data/dev.db"
|
| 8 |
}
|
| 9 |
|
| 10 |
model Image {
|