Spaces:
Sleeping
Sleeping
set in storage current html after clicking login button
Browse filesFiles changed (4)
2 unmodified lines3456678910111213141511 unmodified lines27282930313233342 unmodified lines373839324041424336 unmodified lines808182838485868788892 unmodified linesimport Editor from "@monaco-editor/react";import classNames from "classnames";import { editor } from "monaco-editor";import { useMount, useUnmount, useEvent, createBreakpoint } from "react-use";import { useMount, useUnmount, useEvent, createBreakpoint, useLocalStorage,} from "react-use";import { toast } from "react-toastify";
import Header from "./header/header";11 unmodified lines
function App() { const breakpoint = useBreakpoint(); // eslint-disable-next-line @typescript-eslint/no-unused-vars const [htmlStorage, _, removeHtmlStorage] = useLocalStorage("html_content");
const preview = useRef<HTMLDivElement>(null); const editor = useRef<HTMLDivElement>(null);2 unmodified lines
const [isResizing, setIsResizing] = useState(false); const [error, setError] = useState(false); const [html, setHtml] = useState(defaultHTML); const [html, setHtml] = useState((htmlStorage as string) ?? defaultHTML); const [isAiWorking, setisAiWorking] = useState(false); const [auth, setAuth] = useState<Auth | undefined>(undefined);
36 unmodified lines
useMount(() => { fetchMe(); if (htmlStorage) { removeHtmlStorage(); toast.warn("Previous HTML content restored from local storage."); } if (!editor.current || !preview.current) return;
if (breakpoint === "lg") {136 unmodified lines137138139140140141142143136 unmodified lines } )} > <Login> <Login html={html}> <p className="text-gray-500 text-sm mb-3"> You reached the limit of free AI usage. Please login to continue. </p>100 unmodified lines101102103104104105106107100 unmodified lines )} > {!auth ? ( <Login /> <Login html={html} /> ) : ( <> <header className="flex items-center text-sm px-4 py-2 border-b border-gray-200 gap-2 bg-gray-100 font-semibold text-gray-700">112345678910111213141516171819202122234 unmodified lines2829301231323334function Login({ children }: { children?: React.ReactNode }) {import { useLocalStorage } from "react-use";import { defaultHTML } from "../../utils/consts";
function Login({ html, children,}: { html?: string; children?: React.ReactNode;}) { // eslint-disable-next-line @typescript-eslint/no-unused-vars const [_, setStorage] = useLocalStorage("html_content");
const handleClick = () => { if (html !== defaultHTML) { setStorage(html); } console.log("store current HTML in local storage"); };
return ( <> <header className="flex items-center text-sm px-4 py-2 border-b border-gray-200 gap-2 bg-gray-100 font-semibold text-gray-700">4 unmodified lines </header> <main className="px-4 py-4 space-y-3"> {children} <a href="/api/login"> <a href="/api/login" onClick={handleClick}> <img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/sign-in-with-huggingface-lg-dark.svg" alt="Sign in with Hugging Face"src/components/App.tsx+14-2
src/components/ask-ai/ask-ai.tsx+1-1
src/components/deploy-button/deploy-button.tsx+1-1
src/components/login/login.tsx+21-2