Skip to content

Commit

Permalink
feat: add some initial layout
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Jan 14, 2022
1 parent 6223be2 commit c6e405d
Show file tree
Hide file tree
Showing 15 changed files with 326 additions and 147 deletions.
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: true,
assetPrefix: "./",
exportTrailingSlash: true,
// assetPrefix: "./",
trailingSlash: true,
};
7 changes: 5 additions & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { AppProps } from "next/app";
import { ThemeProvider } from "@mui/material/styles";
import CssBaseline from "@mui/material/CssBaseline";
import { CacheProvider, EmotionCache } from "@emotion/react";
import theme from "../src/theme";
import theme from "../src/utils/theme";
import createEmotionCache from "../src/createEmotionCache";
import "/public/fonts/inter/inter.css";
import { MainLayout } from "../src/layouts/MainLayout";

// Client-side cache, shared for the whole session of the user in the browser.
const clientSideEmotionCache = createEmotionCache();
Expand All @@ -25,7 +26,9 @@ export default function MyApp(props: MyAppProps) {
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<Component {...pageProps} />
<MainLayout>
<Component {...pageProps} />
</MainLayout>
</ThemeProvider>
</CacheProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react";
import Document, { Html, Head, Main, NextScript } from "next/document";
import createEmotionServer from "@emotion/server/create-instance";
import theme from "../src/theme";
import theme from "../src/utils/theme";
import createEmotionCache from "../src/createEmotionCache";

export default class MyDocument extends Document {
Expand Down
26 changes: 13 additions & 13 deletions pages/about.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import * as React from 'react';
import type { NextPage } from 'next';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import Link from '../src/Link';
import ProTip from '../src/ProTip';
import Copyright from '../src/Copyright';
import * as React from "react";
import type { NextPage } from "next";
import Container from "@mui/material/Container";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import { Link } from "../src/components/Link";
import ProTip from "../src/ProTip";
import Copyright from "../src/Copyright";

const About: NextPage = () => {
return (
<Container maxWidth="lg">
<Box
sx={{
my: 4,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
}}
>
<Typography variant="h4" component="h1" gutterBottom>
Expand Down
24 changes: 12 additions & 12 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import * as React from 'react';
import type { NextPage } from 'next';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import Link from '../src/Link';
import ProTip from '../src/ProTip';
import Copyright from '../src/Copyright';
import * as React from "react";
import type { NextPage } from "next";
import Container from "@mui/material/Container";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import { Link } from "../src/components/Link";
import ProTip from "../src/ProTip";
import Copyright from "../src/Copyright";

const Home: NextPage = () => {
return (
<Container maxWidth="lg">
<Box
sx={{
my: 4,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
}}
>
<Typography variant="h4" component="h1" gutterBottom>
Expand Down
3 changes: 3 additions & 0 deletions pages/markets.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Markets() {
return <div>hello</div>;
}
8 changes: 8 additions & 0 deletions pages/reserve-overview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useRouter } from "next/router";

export default function ReserveOverview() {
const router = useRouter();
const underlyingAddress = router.query.underlyingAddress;

return <div>{underlyingAddress}</div>;
}
3 changes: 3 additions & 0 deletions pages/txn-history.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function TxnHistory() {
return <div>hello</div>;
}
95 changes: 0 additions & 95 deletions src/Link.tsx

This file was deleted.

116 changes: 116 additions & 0 deletions src/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import * as React from "react";
import clsx from "clsx";
import { useRouter } from "next/router";
import NextLink, { LinkProps as NextLinkProps } from "next/link";
import MuiLink, { LinkProps as MuiLinkProps } from "@mui/material/Link";
import { styled } from "@mui/material/styles";

// Add support for the sx prop for consistency with the other branches.
const Anchor = styled("a")({});

interface NextLinkComposedProps
extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href">,
Omit<NextLinkProps, "href" | "as"> {
to: NextLinkProps["href"];
linkAs?: NextLinkProps["as"];
href?: NextLinkProps["href"];
}

export const NextLinkComposed = React.forwardRef<
HTMLAnchorElement,
NextLinkComposedProps
>(function NextLinkComposed(props, ref) {
const {
to,
linkAs,
href,
replace,
scroll,
shallow,
prefetch,
locale,
...other
} = props;

return (
<NextLink
href={to}
prefetch={prefetch}
as={linkAs}
replace={replace}
scroll={scroll}
shallow={shallow}
passHref
locale={locale}
>
<Anchor ref={ref} {...other} />
</NextLink>
);
});

export type LinkProps = {
activeClassName?: string;
as?: NextLinkProps["as"];
href: NextLinkProps["href"];
linkAs?: NextLinkProps["as"]; // Useful when the as prop is shallow by styled().
noLinkStyle?: boolean;
} & Omit<NextLinkComposedProps, "to" | "linkAs" | "href"> &
Omit<MuiLinkProps, "href">;

// A styled version of the Next.js Link component:
// https://nextjs.org/docs/#with-link
export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
function Link(props, ref) {
const {
activeClassName = "active",
as: linkAs,
className: classNameProps,
href,
noLinkStyle,
role, // Link don't have roles.
...other
} = props;

const router = useRouter();
const pathname = typeof href === "string" ? href : href.pathname;
const className = clsx(classNameProps, {
[activeClassName]: router.pathname === pathname && activeClassName,
});

const isExternal =
typeof href === "string" &&
(href.indexOf("http") === 0 || href.indexOf("mailto:") === 0);

if (isExternal) {
if (noLinkStyle) {
return (
<Anchor className={className} href={href} ref={ref} {...other} />
);
}

return <MuiLink className={className} href={href} ref={ref} {...other} />;
}

if (noLinkStyle) {
return (
<NextLinkComposed
className={className}
ref={ref}
to={href}
{...other}
/>
);
}

return (
<MuiLink
component={NextLinkComposed}
linkAs={linkAs}
className={className}
ref={ref}
to={href}
{...other}
/>
);
}
);
49 changes: 49 additions & 0 deletions src/layouts/AppHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import * as React from "react";
import { styled, alpha } from "@mui/material/styles";
import Box from "@mui/material/Box";
import Container from "@mui/material/Container";
import { Button } from "@mui/material";
import AaveLogo from "@mui/icons-material/GolfCourseSharp";
import { Link } from "../components/Link";
import MoreMenu from "./MoreMenu";

const Header = styled("header")(({ theme }) => ({
position: "sticky",
top: 0,
transition: theme.transitions.create("top"),
zIndex: theme.zIndex.appBar,
backdropFilter: "blur(20px)",
boxShadow: `inset 0px -1px 1px ${
theme.palette.mode === "dark"
? theme.palette.primaryDark[700]
: theme.palette.grey[100]
}`,
backgroundColor:
theme.palette.mode === "dark"
? alpha(theme.palette.primaryDark[900], 0.72)
: "rgba(255,255,255,0.72)",
}));

export default function AppHeader() {
return (
<Header>
<Container sx={{ display: "flex", alignItems: "center", minHeight: 64 }}>
<Box
component={Link}
href={"/"}
aria-label="Go to homepage"
sx={{ lineHeight: 0, mr: 2 }}
>
<AaveLogo width={32} />
</Box>
<Box sx={{ ml: "auto" }} />
<Box sx={{ display: { xs: "none", sm: "initial" }, mr: "12px" }}>
<Button variant="outlined">Blog</Button>
</Box>
<Box color="inherit">
<MoreMenu />
</Box>
</Container>
</Header>
);
}
Loading

0 comments on commit c6e405d

Please sign in to comment.