Spaces:
Sleeping
Sleeping
set in storage current html after clicking login button
Browse filesFiles changed (4)
2 unmodified lines345678911 unmodified lines2122232425262 unmodified lines2930313233343536 unmodified lines7273747576772 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 { toast } from "react-toastify";import Header from "./header/header";11 unmodified linesfunction App() {const breakpoint = useBreakpoint();const preview = useRef<HTMLDivElement>(null);const editor = useRef<HTMLDivElement>(null);2 unmodified linesconst [isResizing, setIsResizing] = useState(false);const [error, setError] = useState(false);const [html, setHtml] = useState(defaultHTML);const [isAiWorking, setisAiWorking] = useState(false);const [auth, setAuth] = useState<Auth | undefined>(undefined);36 unmodified linesuseMount(() => {fetchMe();if (!editor.current || !preview.current) return;if (breakpoint === "lg") {2 unmodified lines345678910111213141511 unmodified lines27282930313233342 unmodified lines3738394041424336 unmodified lines808182838485868788892 unmodified linesimport Editor from "@monaco-editor/react";import classNames from "classnames";import { editor } from "monaco-editor";import {useMount,useUnmount,useEvent,createBreakpoint,useLocalStorage,} from "react-use";import { toast } from "react-toastify";import Header from "./header/header";11 unmodified linesfunction App() {const breakpoint = useBreakpoint();// eslint-disable-next-line @typescript-eslint/no-unused-varsconst [htmlStorage, _, removeHtmlStorage] = useLocalStorage("html_content");const preview = useRef<HTMLDivElement>(null);const editor = useRef<HTMLDivElement>(null);2 unmodified linesconst [isResizing, setIsResizing] = useState(false);const [error, setError] = useState(false);const [html, setHtml] = useState((htmlStorage as string) ?? defaultHTML);const [isAiWorking, setisAiWorking] = useState(false);const [auth, setAuth] = useState<Auth | undefined>(undefined);36 unmodified linesuseMount(() => {fetchMe();if (htmlStorage) {removeHtmlStorage();toast.warn("Previous HTML content restored from local storage.");}if (!editor.current || !preview.current) return;if (breakpoint === "lg") {
136 unmodified lines137138139140141142143136 unmodified lines})}><Login><p className="text-gray-500 text-sm mb-3">You reached the limit of free AI usage. Please login to continue.</p>136 unmodified lines137138139140141142143136 unmodified lines})}><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 lines101102103104105106107100 unmodified lines)}>{!auth ? (<Login />) : (<><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">100 unmodified lines101102103104105106107100 unmodified lines)}>{!auth ? (<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">
12344 unmodified lines9101112131415function Login({ children }: { children?: React.ReactNode }) {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"><imgsrc="https://huggingface.co/datasets/huggingface/badges/resolve/main/sign-in-with-huggingface-lg-dark.svg"alt="Sign in with Hugging Face"12345678910111213141516171819202122234 unmodified lines28293031323334import { 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-varsconst [_, 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" onClick={handleClick}><imgsrc="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