Spaces:
Running
Running
fix mobile
Browse files
components/editor/ask-ai/fake-ask.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import { useState } from "react";
|
| 2 |
import { useLocalStorage } from "react-use";
|
| 3 |
-
import { ArrowUp } from "lucide-react";
|
| 4 |
import { useRouter } from "next/navigation";
|
| 5 |
|
| 6 |
import { Button } from "@/components/ui/button";
|
|
@@ -8,6 +8,26 @@ import { useLoginModal } from "@/components/contexts/login-context";
|
|
| 8 |
import { PromptBuilder } from "./prompt-builder";
|
| 9 |
import { EnhancedSettings } from "@/types";
|
| 10 |
import { Settings } from "./settings";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
export const FakeAskAi = () => {
|
| 13 |
const router = useRouter();
|
|
@@ -21,20 +41,27 @@ export const FakeAskAi = () => {
|
|
| 21 |
theme: undefined,
|
| 22 |
});
|
| 23 |
const [, setPromptStorage] = useLocalStorage("prompt", "");
|
|
|
|
| 24 |
|
| 25 |
const callAi = async () => {
|
| 26 |
setPromptStorage(prompt);
|
| 27 |
router.push("/projects/new");
|
| 28 |
};
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
return (
|
| 33 |
<div className="p-3 w-full max-w-xl mx-auto">
|
| 34 |
<div className="relative bg-neutral-800 border border-neutral-700 rounded-2xl ring-[4px] focus-within:ring-neutral-500/30 focus-within:border-neutral-600 ring-transparent z-20 w-full group">
|
| 35 |
-
<div className="w-full relative flex items-
|
| 36 |
<textarea
|
| 37 |
-
className="w-full bg-transparent text-sm outline-none text-white placeholder:text-neutral-400
|
| 38 |
placeholder="Ask DeepSite anything..."
|
| 39 |
value={prompt}
|
| 40 |
onChange={(e) => setPrompt(e.target.value)}
|
|
@@ -44,6 +71,18 @@ export const FakeAskAi = () => {
|
|
| 44 |
}
|
| 45 |
}}
|
| 46 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
</div>
|
| 48 |
<div className="flex items-center justify-between gap-2 px-4 pb-3 mt-2">
|
| 49 |
<div className="flex-1 flex items-center justify-start gap-1.5 flex-wrap">
|
|
|
|
| 1 |
import { useState } from "react";
|
| 2 |
import { useLocalStorage } from "react-use";
|
| 3 |
+
import { ArrowUp, Dice1, Dice6 } from "lucide-react";
|
| 4 |
import { useRouter } from "next/navigation";
|
| 5 |
|
| 6 |
import { Button } from "@/components/ui/button";
|
|
|
|
| 8 |
import { PromptBuilder } from "./prompt-builder";
|
| 9 |
import { EnhancedSettings } from "@/types";
|
| 10 |
import { Settings } from "./settings";
|
| 11 |
+
import classNames from "classnames";
|
| 12 |
+
|
| 13 |
+
const prompts = [
|
| 14 |
+
"Create a landing page for a SaaS product, with a hero section, a features section, a pricing section, and a call to action section.",
|
| 15 |
+
"Create a portfolio website for a designer, with a hero section, a projects section, a about section, and a contact section.",
|
| 16 |
+
"Create a blog website for a writer, with a hero section, a blog section, a about section, and a contact section.",
|
| 17 |
+
"Create a Tic Tac Toe game, with a game board, a history section, and a score section.",
|
| 18 |
+
"Create a Weather App, with a search bar, a weather section, and a forecast section.",
|
| 19 |
+
"Create a Calculator, with a calculator section, and a history section.",
|
| 20 |
+
"Create a Todo List, with a todo list section, and a history section.",
|
| 21 |
+
"Create a Calendar, with a calendar section, and a history section.",
|
| 22 |
+
"Create a Music Player, with a music player section, and a history section.",
|
| 23 |
+
"Create a Quiz App, with a quiz section, and a history section.",
|
| 24 |
+
"Create a Pomodoro Timer, with a timer section, and a history section.",
|
| 25 |
+
"Create a Notes App, with a notes section, and a history section.",
|
| 26 |
+
"Create a Task Manager, with a task list section, and a history section.",
|
| 27 |
+
"Create a Password Generator, with a password generator section, and a history section.",
|
| 28 |
+
"Create a Currency Converter, with a currency converter section, and a history section.",
|
| 29 |
+
"Create a Dictionary, with a dictionary section, and a history section.",
|
| 30 |
+
];
|
| 31 |
|
| 32 |
export const FakeAskAi = () => {
|
| 33 |
const router = useRouter();
|
|
|
|
| 41 |
theme: undefined,
|
| 42 |
});
|
| 43 |
const [, setPromptStorage] = useLocalStorage("prompt", "");
|
| 44 |
+
const [randomPromptLoading, setRandomPromptLoading] = useState(false);
|
| 45 |
|
| 46 |
const callAi = async () => {
|
| 47 |
setPromptStorage(prompt);
|
| 48 |
router.push("/projects/new");
|
| 49 |
};
|
| 50 |
|
| 51 |
+
const randomPrompt = () => {
|
| 52 |
+
setRandomPromptLoading(true);
|
| 53 |
+
setTimeout(() => {
|
| 54 |
+
setPrompt(prompts[Math.floor(Math.random() * prompts.length)]);
|
| 55 |
+
setRandomPromptLoading(false);
|
| 56 |
+
}, 400);
|
| 57 |
+
};
|
| 58 |
|
| 59 |
return (
|
| 60 |
<div className="p-3 w-full max-w-xl mx-auto">
|
| 61 |
<div className="relative bg-neutral-800 border border-neutral-700 rounded-2xl ring-[4px] focus-within:ring-neutral-500/30 focus-within:border-neutral-600 ring-transparent z-20 w-full group">
|
| 62 |
+
<div className="w-full relative flex items-start justify-between pr-4 pt-4">
|
| 63 |
<textarea
|
| 64 |
+
className="w-full bg-transparent text-sm outline-none text-white placeholder:text-neutral-400 px-4 pb-4 resize-none"
|
| 65 |
placeholder="Ask DeepSite anything..."
|
| 66 |
value={prompt}
|
| 67 |
onChange={(e) => setPrompt(e.target.value)}
|
|
|
|
| 71 |
}
|
| 72 |
}}
|
| 73 |
/>
|
| 74 |
+
<Button
|
| 75 |
+
size="iconXs"
|
| 76 |
+
variant="outline"
|
| 77 |
+
className="!rounded-md"
|
| 78 |
+
onClick={() => randomPrompt()}
|
| 79 |
+
>
|
| 80 |
+
<Dice6
|
| 81 |
+
className={classNames("size-4", {
|
| 82 |
+
"animate-spin animation-duration-500": randomPromptLoading,
|
| 83 |
+
})}
|
| 84 |
+
/>
|
| 85 |
+
</Button>
|
| 86 |
</div>
|
| 87 |
<div className="flex items-center justify-between gap-2 px-4 pb-3 mt-2">
|
| 88 |
<div className="flex-1 flex items-center justify-start gap-1.5 flex-wrap">
|
components/editor/header/index.tsx
CHANGED
|
@@ -101,7 +101,8 @@ export function Header() {
|
|
| 101 |
<UserMenu className="!pl-1 !pr-3 !py-1 !h-auto" />
|
| 102 |
) : (
|
| 103 |
<Button size="sm" onClick={openLoginWindow}>
|
| 104 |
-
Start Vibe Coding
|
|
|
|
| 105 |
<ArrowRight className="size-4" />
|
| 106 |
</Button>
|
| 107 |
)}
|
|
|
|
| 101 |
<UserMenu className="!pl-1 !pr-3 !py-1 !h-auto" />
|
| 102 |
) : (
|
| 103 |
<Button size="sm" onClick={openLoginWindow}>
|
| 104 |
+
<span className="max-lg:hidden">Start Vibe Coding</span>
|
| 105 |
+
<span className="lg:hidden">Log In</span>
|
| 106 |
<ArrowRight className="size-4" />
|
| 107 |
</Button>
|
| 108 |
)}
|
components/editor/index.tsx
CHANGED
|
@@ -51,8 +51,8 @@ export const AppEditor = ({
|
|
| 51 |
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
|
| 52 |
|
| 53 |
useMount(() => {
|
| 54 |
-
if (isNew) {
|
| 55 |
-
setPages(pagesStorage
|
| 56 |
removePagesStorage();
|
| 57 |
}
|
| 58 |
});
|
|
|
|
| 51 |
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
|
| 52 |
|
| 53 |
useMount(() => {
|
| 54 |
+
if (isNew && pagesStorage) {
|
| 55 |
+
setPages(pagesStorage);
|
| 56 |
removePagesStorage();
|
| 57 |
}
|
| 58 |
});
|
components/editor/live-preview/index.tsx
CHANGED
|
@@ -118,7 +118,7 @@ export const LivePreview = forwardRef<LivePreviewRef, LivePreviewProps>(
|
|
| 118 |
<div
|
| 119 |
className={classNames(
|
| 120 |
"flex flex-col animate-in fade-in duration-300",
|
| 121 |
-
isMaximized ? "w-[60dvw] h-[80dvh]" : "w-80 h-96"
|
| 122 |
)}
|
| 123 |
>
|
| 124 |
<div className="flex items-center justify-between p-3 border-b border-neutral-200">
|
|
|
|
| 118 |
<div
|
| 119 |
className={classNames(
|
| 120 |
"flex flex-col animate-in fade-in duration-300",
|
| 121 |
+
isMaximized ? "w-[90dvw] lg:w-[60dvw] h-[80dvh]" : "w-80 h-96"
|
| 122 |
)}
|
| 123 |
>
|
| 124 |
<div className="flex items-center justify-between p-3 border-b border-neutral-200">
|
components/editor/preview/index.tsx
CHANGED
|
@@ -212,7 +212,7 @@ export const Preview = forwardRef<LivePreviewRef, { isNew: boolean }>(
|
|
| 212 |
className={classNames(
|
| 213 |
"bg-neutral-900/30 w-full h-[calc(100dvh-57px)] flex flex-col items-center justify-center relative z-1 lg:border-l border-neutral-800",
|
| 214 |
{
|
| 215 |
-
"max-lg:h-0": currentTab === "chat",
|
| 216 |
"max-lg:h-full": currentTab === "preview",
|
| 217 |
}
|
| 218 |
)}
|
|
|
|
| 212 |
className={classNames(
|
| 213 |
"bg-neutral-900/30 w-full h-[calc(100dvh-57px)] flex flex-col items-center justify-center relative z-1 lg:border-l border-neutral-800",
|
| 214 |
{
|
| 215 |
+
"max-lg:h-0 overflow-hidden": currentTab === "chat",
|
| 216 |
"max-lg:h-full": currentTab === "preview",
|
| 217 |
}
|
| 218 |
)}
|