From 055176d83b60936ba57d56f342e9c1e3ca088d8b Mon Sep 17 00:00:00 2001 From: Quinta <0pietroquintavalle0@gmail.com> Date: Wed, 19 Jun 2024 23:36:48 +0200 Subject: [PATCH] Basic code editor --- app/_app.tsx | 16 ++++++++ app/editor.tsx | 10 ----- app/editor/page.tsx | 7 ++++ app/globals.css | 2 + app/layout.tsx | 68 ++++++++++++++++++++++++--------- app/page.tsx | 93 +++++++++++---------------------------------- 6 files changed, 99 insertions(+), 97 deletions(-) create mode 100644 app/_app.tsx delete mode 100644 app/editor.tsx create mode 100644 app/editor/page.tsx diff --git a/app/_app.tsx b/app/_app.tsx new file mode 100644 index 0000000..a2c2de9 --- /dev/null +++ b/app/_app.tsx @@ -0,0 +1,16 @@ +import { AppProps } from 'next/app' +import Head from 'next/head' +import '../globals.css' + +function MyApp({ Component, pageProps }: AppProps) { + return ( + <> + + + + + + ) +} + +export default MyApp diff --git a/app/editor.tsx b/app/editor.tsx deleted file mode 100644 index 64c0b8c..0000000 --- a/app/editor.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import Layout from "./layout" -import CodeEditor from "../components/codeeditor" - -export default function JavaCodeEditor() { - return ( - - - - ) -} diff --git a/app/editor/page.tsx b/app/editor/page.tsx new file mode 100644 index 0000000..ba53751 --- /dev/null +++ b/app/editor/page.tsx @@ -0,0 +1,7 @@ +import CodeEditor from "../../components/codeeditor" + +export default function JavaCodeEditor() { + return ( + + ) +} diff --git a/app/globals.css b/app/globals.css index 8b663d5..45357ed 100644 --- a/app/globals.css +++ b/app/globals.css @@ -72,5 +72,7 @@ } body { @apply bg-background text-foreground; + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; } } \ No newline at end of file diff --git a/app/layout.tsx b/app/layout.tsx index f82b1ed..e836e92 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,25 +1,59 @@ -import { Work_Sans } from 'next/font/google' -import './globals.css' -import Navigation from '@/components/navigation'; -import Footer from '@/components/footer'; +"use client"; +import { useState, useEffect } from "react" +import Navigation from "../components/navigation" +import Footer from "../components/footer" +import "./globals.css" -const work_sans = Work_Sans({ - subsets: ['latin'], - display: 'swap', - variable: '--font-work_sans', -}) +export default function RootLayout({ children }: { children: React.ReactNode }) { + const [showButton, setShowButton] = useState(false) + + useEffect(() => { + const handleScroll = () => { + if (window.scrollY > 300) { + setShowButton(true) + } else { + setShowButton(false) + } + } + + window.addEventListener("scroll", handleScroll) + + return () => { + window.removeEventListener("scroll", handleScroll) + } + }, []) + + const scrollToTop = () => { + window.scrollTo({ + top: 0, + behavior: "smooth" + }) + } -// @ts-ignore -export default function Layout({ children }) { return ( - - - + + + + + +
{children} -
- - +
+ {showButton && ( + + )} +