-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add main layout and routing system (#72)
* Add main layout and routing system * Fix comments --------- Co-authored-by: Diana Fulga <[email protected]>
- Loading branch information
1 parent
fe4c099
commit 707d855
Showing
17 changed files
with
522 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { useMemo } from 'react' | ||
import { Link, useLocation } from 'react-router-dom' | ||
import { runtime } from 'webextension-polyfill' | ||
|
||
import { ArrowBack, Settings } from '../icons' | ||
import { ROUTES } from '../router-provider' | ||
|
||
const Logo = runtime.getURL('assets/images/logo.svg') | ||
|
||
const NavigationButton = () => { | ||
const location = useLocation() | ||
|
||
const component = useMemo( | ||
() => | ||
location.pathname === `/${ROUTES.SETTINGS}` ? ( | ||
<Link to={ROUTES.INDEX}> | ||
<ArrowBack className="h-6" /> | ||
</Link> | ||
) : ( | ||
<Link to={ROUTES.SETTINGS}> | ||
<Settings className="h-6" /> | ||
</Link> | ||
), | ||
|
||
[location], | ||
) | ||
|
||
return component | ||
} | ||
|
||
export const Header = () => { | ||
return ( | ||
<div className="flex flex-row items-center justify-between py-8"> | ||
<div className="flex flex-row items-center"> | ||
<img src={Logo} alt="Web Monetization Logo" className="h-6" /> | ||
<p className="ml-3 text-strong text-xl">Web Monetization</p> | ||
</div> | ||
<div className="flex flex-row items-center"> | ||
<NavigationButton /> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
import { Outlet } from 'react-router-dom' | ||
|
||
import { Header } from './header' | ||
|
||
const Divider = () => { | ||
return <div className="mb-8 bg-divider-gradient w-100 h-1" /> | ||
} | ||
|
||
export const MainLayout = () => { | ||
return ( | ||
<div className="flex flex-col w-popup h-popup border-base px-6"> | ||
<Header /> | ||
<Divider /> | ||
<main> | ||
<Outlet /> | ||
</main> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-disable simple-import-sort/imports */ | ||
import React from 'react' | ||
import { MemoryRouter, Routes, Route } from 'react-router-dom' | ||
import { Home } from '@/popup/pages/Home' | ||
import { Settings } from '@/popup/pages/Settings' | ||
import { MainLayout } from './layout/main-layout' | ||
|
||
export const ROUTES = { | ||
INDEX: 'index', | ||
SETTINGS: 'settings', | ||
} | ||
|
||
export const RouterProvider = () => ( | ||
<MemoryRouter basename="popup" initialEntries={['/popup/index']}> | ||
<Routes> | ||
<Route path="" element={<MainLayout />}> | ||
<Route path={ROUTES.SETTINGS} element={<Settings />} /> | ||
<Route path={ROUTES.INDEX} element={<Home />} /> | ||
</Route> | ||
</Routes> | ||
</MemoryRouter> | ||
) |
Oops, something went wrong.