Spaces:
Running
Running
responsive issue
Browse files
components/editor/footer/index.tsx
CHANGED
|
@@ -64,7 +64,7 @@ export function Footer({
|
|
| 64 |
{user && <p className="text-neutral-700">|</p>}
|
| 65 |
<Button size="sm" variant="secondary" onClick={onReset}>
|
| 66 |
<MdAdd className="text-sm" />
|
| 67 |
-
<span>
|
| 68 |
</Button>
|
| 69 |
{htmlHistory && htmlHistory.length > 0 && (
|
| 70 |
<>
|
|
|
|
| 64 |
{user && <p className="text-neutral-700">|</p>}
|
| 65 |
<Button size="sm" variant="secondary" onClick={onReset}>
|
| 66 |
<MdAdd className="text-sm" />
|
| 67 |
+
New <span className="max-lg:hidden">Project</span>
|
| 68 |
</Button>
|
| 69 |
{htmlHistory && htmlHistory.length > 0 && (
|
| 70 |
<>
|
components/editor/index.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { useRef, useState } from "react";
|
|
| 3 |
import { toast } from "sonner";
|
| 4 |
import { editor } from "monaco-editor";
|
| 5 |
import Editor from "@monaco-editor/react";
|
| 6 |
-
import { CopyIcon
|
| 7 |
import {
|
| 8 |
useCopyToClipboard,
|
| 9 |
useEvent,
|
|
@@ -24,13 +24,11 @@ import { AskAI } from "@/components/editor/ask-ai";
|
|
| 24 |
import { DeployButton } from "./deploy-button";
|
| 25 |
import { Project } from "@/types";
|
| 26 |
import { SaveButton } from "./save-button";
|
| 27 |
-
import {
|
| 28 |
-
import { useUser } from "@/hooks/useUser";
|
| 29 |
|
| 30 |
export const AppEditor = ({ project }: { project?: Project | null }) => {
|
| 31 |
const [htmlStorage, , removeHtmlStorage] = useLocalStorage("html_content");
|
| 32 |
const [, copyToClipboard] = useCopyToClipboard();
|
| 33 |
-
const { user, openLoginWindow } = useUser();
|
| 34 |
const { html, setHtml, htmlHistory, setHtmlHistory, prompts, setPrompts } =
|
| 35 |
useEditor(project?.html ?? (htmlStorage as string) ?? defaultHTML);
|
| 36 |
// get query params from URL
|
|
@@ -176,16 +174,11 @@ export const AppEditor = ({ project }: { project?: Project | null }) => {
|
|
| 176 |
return (
|
| 177 |
<section className="h-[100dvh] bg-neutral-950 flex flex-col">
|
| 178 |
<Header tab={currentTab} onNewTab={setCurrentTab}>
|
| 179 |
-
<
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
if (user?.id) router.push("/projects");
|
| 183 |
-
else openLoginWindow();
|
| 184 |
}}
|
| 185 |
-
|
| 186 |
-
<Import className="size-4 mr-1.5" />
|
| 187 |
-
Load Project
|
| 188 |
-
</Button>
|
| 189 |
{project?._id ? (
|
| 190 |
<SaveButton html={html} prompts={prompts} />
|
| 191 |
) : (
|
|
|
|
| 3 |
import { toast } from "sonner";
|
| 4 |
import { editor } from "monaco-editor";
|
| 5 |
import Editor from "@monaco-editor/react";
|
| 6 |
+
import { CopyIcon } from "lucide-react";
|
| 7 |
import {
|
| 8 |
useCopyToClipboard,
|
| 9 |
useEvent,
|
|
|
|
| 24 |
import { DeployButton } from "./deploy-button";
|
| 25 |
import { Project } from "@/types";
|
| 26 |
import { SaveButton } from "./save-button";
|
| 27 |
+
import { LoadProject } from "../my-projects/load-project";
|
|
|
|
| 28 |
|
| 29 |
export const AppEditor = ({ project }: { project?: Project | null }) => {
|
| 30 |
const [htmlStorage, , removeHtmlStorage] = useLocalStorage("html_content");
|
| 31 |
const [, copyToClipboard] = useCopyToClipboard();
|
|
|
|
| 32 |
const { html, setHtml, htmlHistory, setHtmlHistory, prompts, setPrompts } =
|
| 33 |
useEditor(project?.html ?? (htmlStorage as string) ?? defaultHTML);
|
| 34 |
// get query params from URL
|
|
|
|
| 174 |
return (
|
| 175 |
<section className="h-[100dvh] bg-neutral-950 flex flex-col">
|
| 176 |
<Header tab={currentTab} onNewTab={setCurrentTab}>
|
| 177 |
+
<LoadProject
|
| 178 |
+
onSuccess={(project: Project) => {
|
| 179 |
+
router.push(`/projects/${project.space_id}`);
|
|
|
|
|
|
|
| 180 |
}}
|
| 181 |
+
/>
|
|
|
|
|
|
|
|
|
|
| 182 |
{project?._id ? (
|
| 183 |
<SaveButton html={html} prompts={prompts} />
|
| 184 |
) : (
|
components/login-modal/index.tsx
CHANGED
|
@@ -12,7 +12,7 @@ export const LoginModal = ({
|
|
| 12 |
description = "Log In through your Hugging Face account to continue using DeepSite and increase your monthly free limit.",
|
| 13 |
}: {
|
| 14 |
open: boolean;
|
| 15 |
-
html
|
| 16 |
onClose: React.Dispatch<React.SetStateAction<boolean>>;
|
| 17 |
title?: string;
|
| 18 |
description?: string;
|
|
@@ -20,7 +20,7 @@ export const LoginModal = ({
|
|
| 20 |
const { openLoginWindow } = useUser();
|
| 21 |
const [, setStorage] = useLocalStorage("html_content");
|
| 22 |
const handleClick = async () => {
|
| 23 |
-
if (html !== defaultHTML) {
|
| 24 |
setStorage(html);
|
| 25 |
}
|
| 26 |
openLoginWindow();
|
|
|
|
| 12 |
description = "Log In through your Hugging Face account to continue using DeepSite and increase your monthly free limit.",
|
| 13 |
}: {
|
| 14 |
open: boolean;
|
| 15 |
+
html?: string;
|
| 16 |
onClose: React.Dispatch<React.SetStateAction<boolean>>;
|
| 17 |
title?: string;
|
| 18 |
description?: string;
|
|
|
|
| 20 |
const { openLoginWindow } = useUser();
|
| 21 |
const [, setStorage] = useLocalStorage("html_content");
|
| 22 |
const handleClick = async () => {
|
| 23 |
+
if (html && html !== defaultHTML) {
|
| 24 |
setStorage(html);
|
| 25 |
}
|
| 26 |
openLoginWindow();
|
components/my-projects/index.tsx
CHANGED
|
@@ -22,7 +22,7 @@ export function MyProjects({
|
|
| 22 |
return (
|
| 23 |
<>
|
| 24 |
<section className="max-w-[86rem] py-12 px-4 mx-auto">
|
| 25 |
-
<header className="flex items-center justify-between">
|
| 26 |
<div className="text-left">
|
| 27 |
<h1 className="text-3xl font-bold text-white">
|
| 28 |
<span className="capitalize">{user.fullname}</span>'s
|
|
@@ -33,7 +33,8 @@ export function MyProjects({
|
|
| 33 |
</p>
|
| 34 |
</div>
|
| 35 |
<LoadProject
|
| 36 |
-
|
|
|
|
| 37 |
setProjects((prev) => [...prev, project]);
|
| 38 |
}}
|
| 39 |
/>
|
|
|
|
| 22 |
return (
|
| 23 |
<>
|
| 24 |
<section className="max-w-[86rem] py-12 px-4 mx-auto">
|
| 25 |
+
<header className="flex items-center justify-between max-lg:flex-col gap-4">
|
| 26 |
<div className="text-left">
|
| 27 |
<h1 className="text-3xl font-bold text-white">
|
| 28 |
<span className="capitalize">{user.fullname}</span>'s
|
|
|
|
| 33 |
</p>
|
| 34 |
</div>
|
| 35 |
<LoadProject
|
| 36 |
+
fullXsBtn
|
| 37 |
+
onSuccess={(project: Project) => {
|
| 38 |
setProjects((prev) => [...prev, project]);
|
| 39 |
}}
|
| 40 |
/>
|
components/my-projects/load-project.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import { useState } from "react";
|
| 2 |
import { Import } from "lucide-react";
|
| 3 |
|
|
@@ -13,12 +14,19 @@ import Loading from "@/components/loading";
|
|
| 13 |
import { Input } from "../ui/input";
|
| 14 |
import { toast } from "sonner";
|
| 15 |
import { api } from "@/lib/api";
|
|
|
|
|
|
|
| 16 |
|
| 17 |
export const LoadProject = ({
|
| 18 |
-
|
|
|
|
| 19 |
}: {
|
| 20 |
-
|
|
|
|
| 21 |
}) => {
|
|
|
|
|
|
|
|
|
|
| 22 |
const [open, setOpen] = useState(false);
|
| 23 |
const [url, setUrl] = useState<string>("");
|
| 24 |
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -55,7 +63,7 @@ export const LoadProject = ({
|
|
| 55 |
toast.success("Project imported successfully!");
|
| 56 |
setOpen(false);
|
| 57 |
setUrl("");
|
| 58 |
-
|
| 59 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 60 |
} catch (error: any) {
|
| 61 |
toast.error(
|
|
@@ -67,84 +75,122 @@ export const LoadProject = ({
|
|
| 67 |
};
|
| 68 |
|
| 69 |
return (
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
<
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
<
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
</div>
|
| 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 |
};
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
import { useState } from "react";
|
| 3 |
import { Import } from "lucide-react";
|
| 4 |
|
|
|
|
| 14 |
import { Input } from "../ui/input";
|
| 15 |
import { toast } from "sonner";
|
| 16 |
import { api } from "@/lib/api";
|
| 17 |
+
import { useUser } from "@/hooks/useUser";
|
| 18 |
+
import { LoginModal } from "../login-modal";
|
| 19 |
|
| 20 |
export const LoadProject = ({
|
| 21 |
+
fullXsBtn = false,
|
| 22 |
+
onSuccess,
|
| 23 |
}: {
|
| 24 |
+
fullXsBtn?: boolean;
|
| 25 |
+
onSuccess: (project: Project) => void;
|
| 26 |
}) => {
|
| 27 |
+
const { user } = useUser();
|
| 28 |
+
|
| 29 |
+
const [openLoginModal, setOpenLoginModal] = useState(false);
|
| 30 |
const [open, setOpen] = useState(false);
|
| 31 |
const [url, setUrl] = useState<string>("");
|
| 32 |
const [isLoading, setIsLoading] = useState(false);
|
|
|
|
| 63 |
toast.success("Project imported successfully!");
|
| 64 |
setOpen(false);
|
| 65 |
setUrl("");
|
| 66 |
+
onSuccess(response.data.project);
|
| 67 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 68 |
} catch (error: any) {
|
| 69 |
toast.error(
|
|
|
|
| 75 |
};
|
| 76 |
|
| 77 |
return (
|
| 78 |
+
<>
|
| 79 |
+
{!user ? (
|
| 80 |
+
<>
|
| 81 |
+
<Button
|
| 82 |
+
variant="outline"
|
| 83 |
+
className="max-lg:hidden"
|
| 84 |
+
onClick={() => setOpenLoginModal(true)}
|
| 85 |
+
>
|
| 86 |
+
<Import className="size-4 mr-1.5" />
|
| 87 |
+
Load existing Project
|
| 88 |
+
</Button>
|
| 89 |
+
<Button
|
| 90 |
+
variant="outline"
|
| 91 |
+
size="sm"
|
| 92 |
+
className="lg:hidden"
|
| 93 |
+
onClick={() => setOpenLoginModal(true)}
|
| 94 |
+
>
|
| 95 |
+
{fullXsBtn && <Import className="size-3.5 mr-1" />}
|
| 96 |
+
Load
|
| 97 |
+
{fullXsBtn && " existing Project"}
|
| 98 |
+
</Button>
|
| 99 |
+
<LoginModal
|
| 100 |
+
open={openLoginModal}
|
| 101 |
+
onClose={setOpenLoginModal}
|
| 102 |
+
title="Log In to load your Project"
|
| 103 |
+
description="Log In through Hugging Face to load an existing project and increase your free limit!"
|
| 104 |
+
/>
|
| 105 |
+
</>
|
| 106 |
+
) : (
|
| 107 |
+
<Dialog open={open} onOpenChange={setOpen}>
|
| 108 |
+
<DialogTrigger asChild>
|
| 109 |
+
<div>
|
| 110 |
+
<Button variant="outline" className="max-lg:hidden">
|
| 111 |
+
<Import className="size-4 mr-1.5" />
|
| 112 |
+
Load existing Project
|
| 113 |
+
</Button>
|
| 114 |
+
<Button variant="outline" size="sm" className="lg:hidden">
|
| 115 |
+
{fullXsBtn && <Import className="size-3.5 mr-1" />}
|
| 116 |
+
Load
|
| 117 |
+
{fullXsBtn && " existing Project"}
|
| 118 |
+
</Button>
|
| 119 |
</div>
|
| 120 |
+
</DialogTrigger>
|
| 121 |
+
<DialogContent className="sm:max-w-md !p-0 !rounded-3xl !bg-white !border-neutral-100 overflow-hidden text-center">
|
| 122 |
+
<DialogTitle className="hidden" />
|
| 123 |
+
<header className="bg-neutral-50 p-6 border-b border-neutral-200/60">
|
| 124 |
+
<div className="flex items-center justify-center -space-x-4 mb-3">
|
| 125 |
+
<div className="size-11 rounded-full bg-pink-200 shadow-2xs flex items-center justify-center text-2xl opacity-50">
|
| 126 |
+
🎨
|
| 127 |
+
</div>
|
| 128 |
+
<div className="size-13 rounded-full bg-amber-200 shadow-2xl flex items-center justify-center text-3xl z-2">
|
| 129 |
+
🥳
|
| 130 |
+
</div>
|
| 131 |
+
<div className="size-11 rounded-full bg-sky-200 shadow-2xs flex items-center justify-center text-2xl opacity-50">
|
| 132 |
+
💎
|
| 133 |
+
</div>
|
| 134 |
+
</div>
|
| 135 |
+
<p className="text-2xl font-semibold text-neutral-950">
|
| 136 |
+
Import a Project
|
| 137 |
+
</p>
|
| 138 |
+
<p className="text-base text-neutral-500 mt-1.5">
|
| 139 |
+
Enter the URL of your Hugging Face Space to import an existing
|
| 140 |
+
project.
|
| 141 |
+
</p>
|
| 142 |
+
</header>
|
| 143 |
+
<main className="space-y-4 px-9 pb-9 pt-2">
|
| 144 |
+
<div>
|
| 145 |
+
<p className="text-sm text-neutral-700 mb-2">
|
| 146 |
+
Enter your Hugging Face Space
|
| 147 |
+
</p>
|
| 148 |
+
<Input
|
| 149 |
+
type="text"
|
| 150 |
+
placeholder="https://huggingface.com/spaces/username/project"
|
| 151 |
+
value={url}
|
| 152 |
+
onChange={(e) => setUrl(e.target.value)}
|
| 153 |
+
onBlur={(e) => {
|
| 154 |
+
const inputUrl = e.target.value.trim();
|
| 155 |
+
if (!inputUrl) {
|
| 156 |
+
setUrl("");
|
| 157 |
+
return;
|
| 158 |
+
}
|
| 159 |
+
if (!checkIfUrlIsValid(inputUrl)) {
|
| 160 |
+
toast.error("Please enter a valid URL.");
|
| 161 |
+
return;
|
| 162 |
+
}
|
| 163 |
+
setUrl(inputUrl);
|
| 164 |
+
}}
|
| 165 |
+
className="!bg-white !border-neutral-300 !text-neutral-800 !placeholder:text-neutral-400 selection:!bg-blue-100"
|
| 166 |
+
/>
|
| 167 |
+
</div>
|
| 168 |
+
<div>
|
| 169 |
+
<p className="text-sm text-neutral-700 mb-2">
|
| 170 |
+
Then, let's import it!
|
| 171 |
+
</p>
|
| 172 |
+
<Button
|
| 173 |
+
variant="black"
|
| 174 |
+
onClick={handleClick}
|
| 175 |
+
className="relative w-full"
|
| 176 |
+
>
|
| 177 |
+
{isLoading ? (
|
| 178 |
+
<>
|
| 179 |
+
<Loading
|
| 180 |
+
overlay={false}
|
| 181 |
+
className="ml-2 size-4 animate-spin"
|
| 182 |
+
/>
|
| 183 |
+
Fetching your Space...
|
| 184 |
+
</>
|
| 185 |
+
) : (
|
| 186 |
+
<>Import your Space</>
|
| 187 |
+
)}
|
| 188 |
+
</Button>
|
| 189 |
+
</div>
|
| 190 |
+
</main>
|
| 191 |
+
</DialogContent>
|
| 192 |
+
</Dialog>
|
| 193 |
+
)}
|
| 194 |
+
</>
|
| 195 |
);
|
| 196 |
};
|