diff --git a/app/components/AuthButton.tsx b/app/components/AuthButton.tsx new file mode 100644 index 0000000..b13a76f --- /dev/null +++ b/app/components/AuthButton.tsx @@ -0,0 +1,26 @@ +import { Link as RemixLink, useRouteLoaderData } from "@remix-run/react"; +import { PiUserCircle, PiUserCircleFill } from "react-icons/pi"; +import { User } from "~/types/User"; + +export function AuthButton() { + const user = useRouteLoaderData("root"); + + let authImage:JSX.Element = ; + if (user) { + if (user.avatar) { + authImage = {user.displayName} + } else { + authImage = ; + } + } + + console.log('authbutton', JSON.stringify(user)); + return ( + <> + + { authImage } + + + ) +} + diff --git a/app/components/Footer.tsx b/app/components/Footer.tsx index a936900..cdd55f9 100644 --- a/app/components/Footer.tsx +++ b/app/components/Footer.tsx @@ -1,10 +1,10 @@ import { ColorSchemeToggle } from "~/components/ColorSchemeToggle"; const links = [ - { link: 'https://github.com/regexplanet/regex-zone/issues', label: 'Feedback' }, + //{ link: 'https://github.com/regexplanet/regex-zone/issues', label: 'Feedback' }, { link: 'https://github.com/regexplanet/regex-zone?tab=readme-ov-file#credits', label: 'Credits'}, { link: 'https://github.com/regexplanet/regex-zone', label: 'Source' }, - { link: 'https://github.com/regexplanet/regex-zone?tab=readme-ov-file#other-libraries-of-regex-patterns', label: 'Alternatives' }, + //{ link: 'https://github.com/regexplanet/regex-zone?tab=readme-ov-file#other-libraries-of-regex-patterns', label: 'Alternatives' }, ]; export function Footer() { @@ -15,7 +15,7 @@ export function Footer() { {link.label} ); if (index < links.length - 1) { - initial.push(|); + initial.push(|); } } ); @@ -27,7 +27,7 @@ export function Footer() { { initial } - + ) diff --git a/app/components/Navbar.tsx b/app/components/Navbar.tsx index 823f9bf..3377879 100644 --- a/app/components/Navbar.tsx +++ b/app/components/Navbar.tsx @@ -2,7 +2,8 @@ import { PiBlueprint, PiBlueprintBold, PiLink, PiMagnifyingGlass, PiMagnifyingGl import { Link as RemixLink } from "@remix-run/react"; import RegexZoneSvg from './RegexZoneSvg'; -import { NavbarLink, NavbarLinkItem } from '~/components/NavbarLink'; +import { NavbarLink, NavbarLinkItem } from './NavbarLink'; +import { AuthButton } from './AuthButton'; const links:NavbarLinkItem[] = [ { link: '/patterns/', label: 'Patterns', icon: , icon_bold: }, @@ -19,14 +20,15 @@ export function Navbar() { return ( <> diff --git a/app/root.tsx b/app/root.tsx index 67c2bdb..a0c9f14 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -9,6 +9,13 @@ import { } from "@remix-run/react"; import { Navbar } from "~/components/Navbar"; import { Footer } from "~/components/Footer"; +import { LoaderFunctionArgs } from "@remix-run/node"; + +import { authenticator } from "~/services/auth.server"; + +export async function loader({ request }: LoaderFunctionArgs) { + return await authenticator.isAuthenticated(request); +} export function Layout({ children }: { children: React.ReactNode }) { return ( @@ -16,12 +23,12 @@ export function Layout({ children }: { children: React.ReactNode }) { - +