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.
Merge pull request #10 from williamquintas/feature/#9-migrate-project…
…-to-use-nextjs #9: Migrate project to use Next.js
- Loading branch information
Showing
37 changed files
with
699 additions
and
210 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 |
---|---|---|
@@ -1 +1 @@ | ||
REACT_APP_GOOGLE_API_KEY = "string" | ||
NEXT_PUBLIC_GOOGLE_API_KEY = "string" |
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
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,123 @@ | ||
import MuiLink, { LinkProps as MuiLinkProps } from "@mui/material/Link"; | ||
import { styled } from "@mui/material/styles"; | ||
import clsx from "clsx"; | ||
import NextLink, { LinkProps as NextLinkProps } from "next/link"; | ||
import { useRouter } from "next/router"; | ||
import * as React from "react"; | ||
|
||
// 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" | "onClick" | "onMouseEnter"> { | ||
to: NextLinkProps["href"]; | ||
linkAs?: NextLinkProps["as"]; | ||
} | ||
|
||
export const NextLinkComposed = React.forwardRef< | ||
HTMLAnchorElement, | ||
NextLinkComposedProps | ||
>(function NextLinkComposed(props, ref) { | ||
const { to, linkAs, 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/api-reference/next/link | ||
const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(function Link( | ||
props, | ||
ref | ||
) { | ||
const { | ||
activeClassName = "active", | ||
as, | ||
className: classNameProps, | ||
href, | ||
linkAs: linkAsProp, | ||
locale, | ||
noLinkStyle, | ||
prefetch, | ||
replace, | ||
role, // Link don't have roles. | ||
scroll, | ||
shallow, | ||
...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} />; | ||
} | ||
|
||
const linkAs = linkAsProp || as; | ||
const nextjsProps = { | ||
to: href, | ||
linkAs, | ||
replace, | ||
scroll, | ||
shallow, | ||
prefetch, | ||
locale, | ||
}; | ||
|
||
if (noLinkStyle) { | ||
return ( | ||
<NextLinkComposed | ||
className={className} | ||
ref={ref} | ||
{...nextjsProps} | ||
{...other} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<MuiLink | ||
component={NextLinkComposed} | ||
className={className} | ||
ref={ref} | ||
{...nextjsProps} | ||
{...other} | ||
/> | ||
); | ||
}); | ||
|
||
export default Link; |
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
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 @@ | ||
import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux"; | ||
import type { AppDispatch, AppState } from "./store"; | ||
|
||
export const useAppDispatch = () => useDispatch<AppDispatch>(); | ||
|
||
export const useAppSelector: TypedUseSelectorHook<AppState> = useSelector; |
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,23 @@ | ||
import { Action, configureStore, ThunkAction } from "@reduxjs/toolkit"; | ||
import filesReducer from "../features/files/slice"; | ||
|
||
export function makeStore() { | ||
return configureStore({ | ||
reducer: { files: filesReducer }, | ||
}); | ||
} | ||
|
||
const store = makeStore(); | ||
|
||
export type AppState = ReturnType<typeof store.getState>; | ||
|
||
export type AppDispatch = typeof store.dispatch; | ||
|
||
export type AppThunk<ReturnType = void> = ThunkAction< | ||
ReturnType, | ||
AppState, | ||
unknown, | ||
Action<string> | ||
>; | ||
|
||
export default store; |
File renamed without changes.
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,43 @@ | ||
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; | ||
import type { AppState } from "../../config/store"; | ||
import { IFile } from "../../pages/_app"; | ||
|
||
export interface FilesState { | ||
files: IFile[]; | ||
} | ||
|
||
const initialState: FilesState = { | ||
files: [], | ||
}; | ||
|
||
export const filesSlice = createSlice({ | ||
name: "files", | ||
initialState, | ||
reducers: { | ||
add: (state, action: PayloadAction<IFile>) => { | ||
const currentFiles = [...state.files]; | ||
currentFiles.push(action.payload); | ||
state.files = currentFiles; | ||
}, | ||
remove: (state, action: PayloadAction<number>) => { | ||
const currentFiles = [...state.files]; | ||
currentFiles.splice(action.payload); | ||
state.files = currentFiles; | ||
}, | ||
changeColor: ( | ||
state, | ||
action: PayloadAction<{ index: number; color: string }> | ||
) => { | ||
const currentFiles = [...state.files]; | ||
const { index, color } = action.payload; | ||
currentFiles[index].color = color; | ||
state.files = currentFiles; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { add, remove, changeColor } = filesSlice.actions; | ||
|
||
export const selectFiles = (state: AppState) => state.files.files; | ||
|
||
export default filesSlice.reducer; |
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 |
Oops, something went wrong.