forked from intrig-unicamp/paths-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#9: Add next, moves pages, CSS and components
- Loading branch information
1 parent
5721b28
commit 47c2e0a
Showing
32 changed files
with
406 additions
and
150 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
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 |
---|---|---|
|
@@ -5,6 +5,10 @@ | |
/.pnp | ||
.pnp.js | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# testing | ||
/coverage | ||
|
||
|
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
1 change: 0 additions & 1 deletion
1
...nts/FileUploadButton/FileUploadButton.tsx → ...nts/FileUploadButton/FileUploadButton.tsx
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
1 change: 0 additions & 1 deletion
1
src/components/Footer/Footer.tsx → components/Footer/Footer.tsx
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
1 change: 0 additions & 1 deletion
1
src/components/Header/Header.tsx → components/Header/Header.tsx
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,7 @@ | ||
body { | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, | ||
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} |
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,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
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,6 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
} | ||
|
||
module.exports = nextConfig |
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,66 @@ | ||
import { CacheProvider, EmotionCache } from "@emotion/react"; | ||
import { Box, CssBaseline, ThemeProvider } from "@mui/material"; | ||
import { AppProps } from "next/app"; | ||
import Head from "next/head"; | ||
import { useState } from "react"; | ||
import Footer from "../components/Footer/Footer"; | ||
import Header from "../components/Header/Header"; | ||
import theme from "../config/theme"; | ||
import "../css/ColorPicker.css"; | ||
import "../css/FilesSelectionContainer.css"; | ||
import "../css/FileUploadButton.css"; | ||
import "../css/Footer.css"; | ||
import "../css/Header.css"; | ||
import { createEmotionCache } from "./_document"; | ||
|
||
export interface ICoordinatesData { | ||
date?: string; | ||
time?: string; | ||
id?: string; | ||
line?: string; | ||
latitude?: string; | ||
longitude?: string; | ||
speed?: string; | ||
} | ||
|
||
export interface IFile { | ||
filename: string; | ||
color: string; | ||
data?: ICoordinatesData[]; | ||
} | ||
|
||
interface AppWithCacheProps extends AppProps { | ||
emotionCache?: EmotionCache; | ||
} | ||
|
||
const clientSideEmotionCache = createEmotionCache(); | ||
|
||
export default function App({ | ||
Component, | ||
emotionCache = clientSideEmotionCache, | ||
pageProps, | ||
}: AppWithCacheProps) { | ||
const [files, setFiles] = useState<IFile[]>([]); | ||
|
||
return ( | ||
<CacheProvider value={emotionCache}> | ||
<Head> | ||
<meta name="viewport" content="initial-scale=1, width=device-width" /> | ||
</Head> | ||
<ThemeProvider theme={theme}> | ||
<CssBaseline /> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
minHeight: "100vh", | ||
}} | ||
> | ||
<Header /> | ||
<Component {...pageProps} /> | ||
<Footer /> | ||
</Box> | ||
</ThemeProvider> | ||
</CacheProvider> | ||
); | ||
} |
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,94 @@ | ||
import createCache from "@emotion/cache"; | ||
import createEmotionServer from "@emotion/server/create-instance"; | ||
import Document, { Head, Html, Main, NextScript } from "next/document"; | ||
import * as React from "react"; | ||
import theme from "../config/theme"; | ||
|
||
export default class MyDocument extends Document { | ||
render() { | ||
return ( | ||
<Html lang="en"> | ||
<Head> | ||
{/* PWA primary color */} | ||
<meta name="theme-color" content={theme.palette.primary.main} /> | ||
<link rel="shortcut icon" href="/favicon.ico" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" | ||
/> | ||
{/* Inject MUI styles first to match with the prepend: true configuration. */} | ||
{(this.props as any).emotionStyleTags} | ||
</Head> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
); | ||
} | ||
} | ||
|
||
// `getInitialProps` belongs to `_document` (instead of `_app`), | ||
// it's compatible with static-site generation (SSG). | ||
MyDocument.getInitialProps = async (ctx) => { | ||
// Resolution order | ||
// | ||
// On the server: | ||
// 1. app.getInitialProps | ||
// 2. page.getInitialProps | ||
// 3. document.getInitialProps | ||
// 4. app.render | ||
// 5. page.render | ||
// 6. document.render | ||
// | ||
// On the server with error: | ||
// 1. document.getInitialProps | ||
// 2. app.render | ||
// 3. page.render | ||
// 4. document.render | ||
// | ||
// On the client | ||
// 1. app.getInitialProps | ||
// 2. page.getInitialProps | ||
// 3. app.render | ||
// 4. page.render | ||
|
||
const originalRenderPage = ctx.renderPage; | ||
|
||
// You can consider sharing the same emotion cache between all the SSR requests to speed up performance. | ||
// However, be aware that it can have global side effects. | ||
const cache = createEmotionCache(); | ||
const { extractCriticalToChunks } = createEmotionServer(cache); | ||
|
||
ctx.renderPage = () => | ||
originalRenderPage({ | ||
enhanceApp: (App: any) => | ||
function EnhanceApp(props) { | ||
return <App emotionCache={cache} {...props} />; | ||
}, | ||
}); | ||
|
||
const initialProps = await Document.getInitialProps(ctx); | ||
// This is important. It prevents emotion to render invalid HTML. | ||
// See https://github.com/mui/material-ui/issues/26561#issuecomment-855286153 | ||
const emotionStyles = extractCriticalToChunks(initialProps.html); | ||
const emotionStyleTags = emotionStyles.styles.map((style) => ( | ||
<style | ||
data-emotion={`${style.key} ${style.ids.join(" ")}`} | ||
key={style.key} | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ __html: style.css }} | ||
/> | ||
)); | ||
|
||
return { | ||
...initialProps, | ||
emotionStyleTags, | ||
}; | ||
}; | ||
|
||
// prepend: true moves MUI styles to the top of the <head> so they're loaded first. | ||
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules. | ||
export function createEmotionCache() { | ||
return createCache({ key: "css", prepend: true }); | ||
} |
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,10 @@ | ||
import { FunctionComponent, useState } from "react"; | ||
import FilesSelectionContainer from "../components/FilesSelectionContainer/FilesSelectionContainer"; | ||
import { IFile } from "./_app"; | ||
|
||
const FilesSelectionPage: FunctionComponent = () => { | ||
const [files, setFiles] = useState<IFile[]>([]); | ||
return <FilesSelectionContainer files={files} setFiles={setFiles} />; | ||
}; | ||
|
||
export default FilesSelectionPage; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.