-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: root app layout and styles #33
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import { useState } from 'react'; | ||
import ConnectWalletButton from 'components/ConnectWalletButton'; | ||
import NetworkDropdown from 'components/NetworkDropdown'; | ||
import OfferSignerBridge from 'components/OfferSignerBridge'; | ||
import { ToastContainer } from 'react-toastify'; | ||
import { createBrowserRouter, RouterProvider } from 'react-router-dom'; | ||
|
@@ -14,12 +12,21 @@ import { makeLeader } from '@agoric/casting'; | |
|
||
import 'react-toastify/dist/ReactToastify.css'; | ||
import 'styles/globals.css'; | ||
import Root from 'views/Root'; | ||
|
||
const router = createBrowserRouter([ | ||
{ | ||
path: '/', | ||
element: <Vaults />, | ||
element: <Root />, | ||
errorElement: <ErrorPage />, | ||
children: [ | ||
{ | ||
index: true, | ||
element: <Vaults />, | ||
errorElement: <ErrorPage />, | ||
path: '/vaults', | ||
}, | ||
], | ||
}, | ||
]); | ||
|
||
|
@@ -50,34 +57,26 @@ const App = () => { | |
}, [setError, leader, netConfig, setLeader]); | ||
|
||
return ( | ||
<> | ||
<div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to make sure I understand, was this necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah nope. |
||
<ToastContainer | ||
position={'bottom-right'} | ||
closeOnClick={false} | ||
newestOnTop={true} | ||
hideProgressBar={true} | ||
autoClose={false} | ||
></ToastContainer> | ||
<OfferSignerBridge /> | ||
<div className="w-screen max-w-7xl m-auto"> | ||
<div className="flex w-full justify-end p-4"> | ||
<div className="flex flex-row space-x-2"> | ||
<NetworkDropdown /> | ||
<ConnectWalletButton /> | ||
<OfferSignerBridge /> | ||
</div> | ||
</div> | ||
<div className="w-full"> | ||
{error ? ( | ||
<> | ||
<div>Error connecting to chain</div> | ||
<details>{error.toString()}</details> | ||
</> | ||
) : ( | ||
<RouterProvider router={router} /> | ||
)} | ||
</div> | ||
{error ? ( | ||
<> | ||
<div>Error connecting to chain</div> | ||
<details>{error.toString()}</details> | ||
</> | ||
) : ( | ||
<RouterProvider router={router} /> | ||
)} | ||
</div> | ||
</> | ||
</div> | ||
); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { PropsWithChildren, ReactNode } from 'react'; | ||
|
||
type Props = PropsWithChildren<{ header?: ReactNode; subheader?: ReactNode }>; | ||
|
||
const MainContentCard = ({ children, header, subheader }: Props) => { | ||
return ( | ||
<div className="w-full bg-gradient-to-br from-[#fffcf2] to-[#ffffff] rounded-t-3xl rounded-b-xl shadow-[0px_34px_50px_0px_#ff7a1a]"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with this brackets in className syntax. Is some part of the build chain making classes on the fly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I could also define a custom class but just went with this method because these values are quite bespoke. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<div className="bg-interYellow h-12 rounded-t-3xl">{header}</div> | ||
<div className="w-full h-[1px] bg-[#f4cd0c]" /> | ||
<div className="w-full h-[1px] bg-[#ffe252]" /> | ||
<div className="bg-interYellow h-12">{subheader}</div> | ||
<div className="p-8">{children}</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MainContentCard; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,7 @@ | |
* { | ||
border-color: #e5e7eb; | ||
} | ||
html { | ||
@apply text-mineShaft; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
@import 'base.css'; | ||
@import 'utilities.css'; | ||
@import 'components.css'; | ||
@import url('https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@400;500;600;700&display=swap'); | ||
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600;700&display=swap'); | ||
|
||
:root { | ||
--color-glow: #fed7aa; | ||
|
@@ -10,5 +12,9 @@ | |
--color-alternative-bright: #fafafa; | ||
--color-primary: #c084fc; | ||
--color-primary-dark: #a855f7; | ||
--color-mineShaft: #484848; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this name is so specific as to not be a variable. Please name it for a role (e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered that but this color is referred to as "mine shaft" in the figma. It's also used a couple places not as text. I figured it would be easier for maintainers referring to the figma to reference it in the code as the same name. I could maybe add an alias for it in tailwind.config.cjs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get why the Figma would use it, because they're designing a screen that doesn't have to be maintained. In code we should not name literal colors. If there were more time I'd say to work with the designers to understand how they use "mine shaft" and ask them to give it a semantic name. But I won't block on this. |
||
--currentColor: #d1d5db; | ||
--inter-yellow: #ffd81a; | ||
--inter-orange: #ff7a1a; | ||
--inter-purple: #b787f5; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { NavLink, Outlet, useLocation, Navigate } from 'react-router-dom'; | ||
import NetworkDropdown from '../components/NetworkDropdown'; | ||
import ConnectWalletButton from '../components/ConnectWalletButton'; | ||
|
||
type NavItemProps = { | ||
label: string; | ||
href: string; | ||
}; | ||
|
||
const NavItem = ({ label, href }: NavItemProps) => { | ||
return ( | ||
<li> | ||
<NavLink | ||
className="h-full justify-between flex flex-col font-serif" | ||
to={href} | ||
> | ||
{({ isActive }) => ( | ||
<> | ||
<div className="h-1.5"></div> | ||
<span className="m-2 font-bold">{label}</span> | ||
<div | ||
className={ | ||
isActive | ||
? 'h-1.5 bg-mineShaft w-full rounded-t-[3px] shadow-[0_-1px_8px_0px_#484848]' | ||
: 'h-1.5' | ||
} | ||
></div> | ||
</> | ||
)} | ||
</NavLink> | ||
</li> | ||
); | ||
}; | ||
|
||
const Root = () => { | ||
const { pathname } = useLocation(); | ||
const shouldRedirectToVaults = pathname === '/'; | ||
|
||
return ( | ||
<> | ||
<div className="flex w-full justify-between h-24"> | ||
<div className="flex flex-row space-x-10"> | ||
<img | ||
src="/inter-protocol-logo.svg" | ||
alt="Inter Protocol Logo" | ||
height="48" | ||
width="174" | ||
/> | ||
<nav> | ||
<ul className="h-full flex flex-row space-x-12"> | ||
<NavItem label="Vaults" href="/vaults" /> | ||
<NavItem label="Liquidations" href="/liquidations" /> | ||
</ul> | ||
</nav> | ||
</div> | ||
<div className="flex flex-row space-x-2 items-center mr-6"> | ||
<NetworkDropdown /> | ||
<ConnectWalletButton /> | ||
</div> | ||
</div> | ||
{shouldRedirectToVaults && <Navigate to="/vaults"></Navigate>} | ||
<Outlet /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Root; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why class the
<html>
instead of<body>
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the background color, I want it to affect the entire page even if there's no content. This way we don't have to artificially stretch the body out to fill the whole screen just to apply the background.