diff --git a/src/layouts/modal/index.tsx b/src/layouts/modal/index.tsx new file mode 100644 index 0000000..0feec3b --- /dev/null +++ b/src/layouts/modal/index.tsx @@ -0,0 +1,77 @@ +import { Box, Button, Modal as ModalMui, Typography } from '@mui/material' +import { + Link, + matchPath, + Outlet, + useLocation, + useNavigate +} from 'react-router-dom' +import styles from './style.module.scss' +import { appPublicRoutes } from '../../routes' + +function useRouteMatch(patterns: readonly string[]) { + const { pathname } = useLocation() + + for (let i = 0; i < patterns.length; i += 1) { + const pattern = patterns[i] + const possibleMatch = matchPath(pattern, pathname) + if (possibleMatch !== null) { + return possibleMatch + } + } + + return null +} + +export const Modal = () => { + const navigate = useNavigate() + const tabs = [ + { to: appPublicRoutes.login, title: 'Login', label: 'Login' }, + { to: appPublicRoutes.register, title: 'Register', label: 'Register' }, + { to: appPublicRoutes.nostr, title: 'Login', label: <>Ostrich } + ] + const routeMatch = useRouteMatch(tabs.map((t) => t.to)) + const activeTab = routeMatch?.pattern?.path + const handleClose = () => { + navigate(appPublicRoutes.landingPage) + } + + return ( + + + + Login + + + + {tabs.map((t) => { + return ( + + + + ) + })} + + + + + + Welcome to Sigit + + + + ) +} diff --git a/src/layouts/modal/style.module.scss b/src/layouts/modal/style.module.scss new file mode 100644 index 0000000..a8348e2 --- /dev/null +++ b/src/layouts/modal/style.module.scss @@ -0,0 +1,14 @@ +.modal { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + + background-color: white; + padding: 4px; + + width: 100%; + max-width: 500px; + display: flex; + flex-direction: column; +} diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index 6fad8c3..08e2e18 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -1,4 +1,4 @@ -import { Box, Button, Container, TextField, Typography } from '@mui/material' +import { Box, Button, TextField } from '@mui/material' import { getPublicKey, nip19 } from 'nostr-tools' import { useEffect, useState } from 'react' import { useDispatch } from 'react-redux' @@ -22,6 +22,7 @@ import { npubToHex, queryNip05 } from '../../utils' import styles from './style.module.scss' import { hexToBytes } from '@noble/hashes/utils' import { NIP05_REGEX } from '../../constants' +import { appPublicRoutes } from '../../routes' export const Login = () => { const [searchParams] = useSearchParams() @@ -352,29 +353,31 @@ export const Login = () => { } return ( - + <> {isLoading && } -
- Welcome to Sigit - setInputValue(e.target.value)} - sx={{ width: '100%', mt: 2 }} - /> - {isNostrExtensionAvailable && ( - - )} - - - -
-
+ +
+ setInputValue(e.target.value)} + sx={{ width: '100%', mt: 2 }} + /> + {isNostrExtensionAvailable && ( + + )} + + + + +
+
+ ) } diff --git a/src/pages/nostr/index.tsx b/src/pages/nostr/index.tsx new file mode 100644 index 0000000..6b800c3 --- /dev/null +++ b/src/pages/nostr/index.tsx @@ -0,0 +1,3 @@ +export const Nostr = () => { + return <>Nostr +} diff --git a/src/pages/register/index.tsx b/src/pages/register/index.tsx new file mode 100644 index 0000000..7af51db --- /dev/null +++ b/src/pages/register/index.tsx @@ -0,0 +1,3 @@ +export const Register = () => { + return <>Register +} diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 9a2a905..56c5970 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,8 +1,11 @@ +import { Modal } from '../layouts/modal' import { CreatePage } from '../pages/create' import { HomePage } from '../pages/home' import { LandingPage } from '../pages/landing' import { Login } from '../pages/login' +import { Nostr } from '../pages/nostr' import { ProfilePage } from '../pages/profile' +import { Register } from '../pages/register' import { SettingsPage } from '../pages/settings/Settings' import { CacheSettingsPage } from '../pages/settings/cache' import { ProfileSettingsPage } from '../pages/settings/profile' @@ -26,6 +29,8 @@ export const appPublicRoutes = { profile: '/profile/:npub', landingPage: '/', login: '/login', + register: '/login/register', + nostr: '/login/nostr', verify: '/verify', source: 'https://git.sigit.io/sig/it' } @@ -79,9 +84,24 @@ export const publicRoutes: PublicRouteProps[] = [ element: , children: [ { - path: appPublicRoutes.login, - hiddenWhenLoggedIn: true, - element: + element: , + children: [ + { + path: appPublicRoutes.login, + hiddenWhenLoggedIn: true, + element: + }, + { + path: appPublicRoutes.register, + hiddenWhenLoggedIn: true, + element: + }, + { + path: appPublicRoutes.nostr, + hiddenWhenLoggedIn: true, + element: + } + ] } ] }, diff --git a/src/theme/index.ts b/src/theme/index.ts index dcc3d9f..07e43ba 100644 --- a/src/theme/index.ts +++ b/src/theme/index.ts @@ -21,6 +21,14 @@ export const theme = extendTheme({ } }, components: { + MuiModal: { + styleOverrides: { + root: { + insetBlock: '25px', + insetInline: '20px' + } + } + }, MuiButton: { styleOverrides: { root: {