Skip to content

Commit 781eb1a

Browse files
committedDec 1, 2023
first commit
0 parents  commit 781eb1a

24 files changed

+5735
-0
lines changed
 

‎.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NEXT_PUBLIC_WEB3MODAL_ID=912700a50171dd26f221cab915984a73

‎.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src/generated.ts
2+
src/components/ThemeRegistry

‎.eslintrc.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"standard-with-typescript",
8+
"plugin:prettier/recommended"
9+
],
10+
"parserOptions": {
11+
"ecmaVersion": "latest",
12+
"sourceType": "module"
13+
},
14+
"plugins": [
15+
"react"
16+
],
17+
"rules": {
18+
"react/prop-types": "off"
19+
},
20+
"settings": {
21+
"react": {
22+
"version": "detect"
23+
}
24+
}
25+
}

‎.gitignore

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
# next-env.d.ts

‎.prettierrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"printWidth": 100,
5+
"tabWidth": 2,
6+
"semi": true,
7+
"jsxSingleQuote": false,
8+
"jsxBracketSameLine": false,
9+
"arrowParens": "avoid",
10+
"endOfLine": "auto"
11+
}
12+

‎.yarn/install-state.gz

424 KB
Binary file not shown.

‎.yarn/releases/yarn-4.0.2.cjs

+893
Large diffs are not rendered by default.

‎.yarnrc.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-4.0.2.cjs

‎README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Material UI - Next.js App Router example in TypeScript
2+
3+
This is a [Next.js](https://nextjs.org/) project bootstrapped using [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with Material UI installed.
4+
5+
## How to use
6+
7+
Download the example [or clone the repo](https://github.com/mui/material-ui):
8+
9+
<!-- #default-branch-switch -->
10+
11+
```bash
12+
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-nextjs-ts
13+
cd material-ui-nextjs-ts
14+
```
15+
16+
Install it and run:
17+
18+
```bash
19+
npm install
20+
npm run dev
21+
```
22+
23+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
24+
25+
or:
26+
27+
<!-- #default-branch-switch -->
28+
29+
[![Edit on StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/mui/material-ui/tree/master/examples/material-ui-nextjs-ts)
30+
31+
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui/material-ui/tree/master/examples/material-ui-nextjs-ts)
32+
33+
## Learn more
34+
35+
To learn more about this example:
36+
37+
- [Next.js documentation](https://nextjs.org/docs) - learn about Next.js features and API.
38+
- [Customizing Material UI](https://mui.com/material-ui/customization/how-to-customize/) - approaches to customizing Material UI.
39+
40+
## What's next?
41+
42+
<!-- #default-branch-switch -->
43+
44+
You now have a working example project.
45+
You can head back to the documentation and continue by browsing the [templates](https://mui.com/material-ui/getting-started/templates/) section.

‎next-env.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

‎next.config.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const withBundleAnalyzer = require('@next/bundle-analyzer')({
2+
enabled: process.env.ANALYZE === 'true',
3+
})
4+
5+
const nextConfig = {
6+
reactStrictMode: true,
7+
swcMinify: true,
8+
modularizeImports: {
9+
'@mui/icons-material': {
10+
transform: '@mui/icons-material/{{member}}',
11+
},
12+
},
13+
};
14+
15+
module.exports = withBundleAnalyzer(nextConfig);

‎package.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "material-ui-nextjs-ts",
3+
"version": "5.0.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
10+
"post-update": "echo \"codesandbox preview only, need an update\" && yarn upgrade --latest"
11+
},
12+
"dependencies": {
13+
"@emotion/cache": "latest",
14+
"@emotion/react": "latest",
15+
"@emotion/styled": "latest",
16+
"@mui/icons-material": "^5.14.16",
17+
"@mui/material": "latest",
18+
"next": "^14.0.1",
19+
"next-plausible": "^3.11.3",
20+
"react": "^18.2.0"
21+
},
22+
"devDependencies": {
23+
"@next/bundle-analyzer": "^14.0.1",
24+
"@types/node": "latest",
25+
"@types/react": "latest",
26+
"@types/react-dom": "latest",
27+
"@typescript-eslint/eslint-plugin": "^6.13.1",
28+
"@typescript-eslint/parser": "^6.13.1",
29+
"eslint": "^8.54.0",
30+
"eslint-config-next": "^14.0.1",
31+
"eslint-config-prettier": "^9.0.0",
32+
"eslint-config-standard-with-typescript": "^40.0.0",
33+
"eslint-plugin-n": "^16.3.1",
34+
"eslint-plugin-prettier": "^5.0.1",
35+
"eslint-plugin-promise": "^6.1.1",
36+
"eslint-plugin-react": "^7.33.2",
37+
"prettier": "^3.1.0",
38+
"typescript": "latest"
39+
},
40+
"packageManager": "yarn@4.0.2"
41+
}

‎public/.gitkeep

Whitespace-only changes.

‎public/WorkSans-SemiBold.ttf

187 KB
Binary file not shown.

‎public/robots.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Allow all crawlers
2+
User-agent: *
3+
Allow: /

‎src/app/favicon.ico

15 KB
Binary file not shown.

‎src/app/layout.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import ThemeRegistry from '@/components/ThemeRegistry/ThemeRegistry';
3+
import { Work_Sans } from 'next/font/google';
4+
import PlausibleProvider from 'next-plausible';
5+
import type { Metadata } from 'next';
6+
7+
export const metadata: Metadata = {
8+
title: `Your title here`,
9+
};
10+
11+
const workSans = Work_Sans({
12+
weight: ['300', '400', '500', '600', '700', '800'],
13+
style: ['normal', 'italic'],
14+
subsets: ['latin'],
15+
});
16+
17+
export default function RootLayout({ children }: { children: React.ReactNode }): JSX.Element {
18+
return (
19+
<html lang="en">
20+
<head>
21+
<PlausibleProvider domain="your.domain" />
22+
</head>
23+
<body className={workSans.className}>
24+
<ThemeRegistry>
25+
{children}
26+
</ThemeRegistry>
27+
</body>
28+
</html>
29+
);
30+
}

‎src/app/page.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react';
2+
import { Typography } from '@mui/material';
3+
4+
export default function Home(): JSX.Element {
5+
return <Typography variant="h1">Add content here</Typography>;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
'use client';
2+
import * as React from 'react';
3+
import createCache from '@emotion/cache';
4+
import { useServerInsertedHTML } from 'next/navigation';
5+
import { CacheProvider as DefaultCacheProvider } from '@emotion/react';
6+
import type { EmotionCache, Options as OptionsOfCreateCache } from '@emotion/cache';
7+
8+
export interface NextAppDirEmotionCacheProviderProps {
9+
/** This is the options passed to createCache() from 'import createCache from "@emotion/cache"' */
10+
options: Omit<OptionsOfCreateCache, 'insertionPoint'>;
11+
/** By default <CacheProvider /> from 'import { CacheProvider } from "@emotion/react"' */
12+
CacheProvider?: (props: {
13+
value: EmotionCache;
14+
children: React.ReactNode;
15+
}) => React.JSX.Element | null;
16+
children: React.ReactNode;
17+
}
18+
19+
// Adapted from https://github.com/garronej/tss-react/blob/main/src/next/appDir.tsx
20+
export default function NextAppDirEmotionCacheProvider(props: NextAppDirEmotionCacheProviderProps) {
21+
const { options, CacheProvider = DefaultCacheProvider, children } = props;
22+
23+
const [registry] = React.useState(() => {
24+
const cache = createCache(options);
25+
cache.compat = true;
26+
const prevInsert = cache.insert;
27+
let inserted: Array<{ name: string; isGlobal: boolean }> = [];
28+
cache.insert = (...args) => {
29+
const [selector, serialized] = args;
30+
if (cache.inserted[serialized.name] === undefined) {
31+
inserted.push({
32+
name: serialized.name,
33+
isGlobal: !selector,
34+
});
35+
}
36+
return prevInsert(...args);
37+
};
38+
const flush = () => {
39+
const prevInserted = inserted;
40+
inserted = [];
41+
return prevInserted;
42+
};
43+
return { cache, flush };
44+
});
45+
46+
useServerInsertedHTML(() => {
47+
const inserted = registry.flush();
48+
if (inserted.length === 0) {
49+
return null;
50+
}
51+
let styles = '';
52+
let dataEmotionAttribute = registry.cache.key;
53+
54+
const globals: Array<{
55+
name: string;
56+
style: string;
57+
}> = [];
58+
59+
inserted.forEach(({ name, isGlobal }) => {
60+
const style = registry.cache.inserted[name];
61+
62+
if (typeof style !== 'boolean') {
63+
if (isGlobal) {
64+
globals.push({ name, style });
65+
} else {
66+
styles += style;
67+
dataEmotionAttribute += ` ${name}`;
68+
}
69+
}
70+
});
71+
72+
return (
73+
<React.Fragment>
74+
{globals.map(({ name, style }) => (
75+
<style
76+
key={name}
77+
data-emotion={`${registry.cache.key}-global ${name}`}
78+
// eslint-disable-next-line react/no-danger
79+
dangerouslySetInnerHTML={{ __html: style }}
80+
/>
81+
))}
82+
{styles && (
83+
<style
84+
data-emotion={dataEmotionAttribute}
85+
// eslint-disable-next-line react/no-danger
86+
dangerouslySetInnerHTML={{ __html: styles }}
87+
/>
88+
)}
89+
</React.Fragment>
90+
);
91+
});
92+
93+
return <CacheProvider value={registry.cache}>{children}</CacheProvider>;
94+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use client';
2+
import * as React from 'react';
3+
import { ThemeProvider } from '@mui/material/styles';
4+
import CssBaseline from '@mui/material/CssBaseline';
5+
import NextAppDirEmotionCacheProvider from './EmotionCache';
6+
import theme from './theme';
7+
8+
export default function ThemeRegistry({ children }: { children: React.ReactNode }) {
9+
return (
10+
<NextAppDirEmotionCacheProvider options={{ key: 'mui' }}>
11+
<ThemeProvider theme={theme}>
12+
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
13+
<CssBaseline />
14+
{children}
15+
</ThemeProvider>
16+
</NextAppDirEmotionCacheProvider>
17+
);
18+
}

‎src/components/ThemeRegistry/theme.ts

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import { createTheme, type ThemeOptions, lighten } from '@mui/material/styles';
2+
3+
const themeOptions: ThemeOptions = {
4+
palette: {
5+
mode: 'dark',
6+
primary: {
7+
main: '#CDEAF7',
8+
contrastText: '#292C34',
9+
light: '#E0F2FA',
10+
dark: '#7DCAEE',
11+
},
12+
secondary: {
13+
main: '#105C7E',
14+
contrastText: '#F1FAFD',
15+
light: '#198DC2',
16+
dark: '#082E3F',
17+
},
18+
background: {
19+
default: '#22242b',
20+
paper: '#292C34',
21+
},
22+
text: {
23+
primary: '#FAFDFF',
24+
secondary: '#A7ACB9',
25+
disabled: '#C6C9D2',
26+
},
27+
divider: '#3f4350',
28+
error: {
29+
main: '#ff666a',
30+
contrastText: '#FFA3A6',
31+
},
32+
success: {
33+
main: '#80ffa2',
34+
contrastText: '#292C34',
35+
},
36+
},
37+
typography: {
38+
fontFamily: 'inherit',
39+
fontWeightBold: 800,
40+
fontWeightMedium: 600,
41+
fontWeightRegular: 500,
42+
fontWeightLight: 300,
43+
h1: {
44+
fontWeight: 700,
45+
},
46+
h2: {
47+
fontWeight: 700,
48+
'@media (max-width:600px)': {
49+
fontSize: '2.4rem',
50+
},
51+
},
52+
h3: {
53+
fontWeight: 600,
54+
'@media (max-width:600px)': {
55+
fontSize: '2rem',
56+
},
57+
},
58+
h4: {
59+
fontWeight: 600,
60+
'@media (max-width:600px)': {
61+
fontSize: '1.7rem',
62+
},
63+
},
64+
button: {
65+
fontWeight: 600,
66+
},
67+
h5: {
68+
fontWeight: 400,
69+
'@media (max-width:600px)': {
70+
fontSize: '1.4rem',
71+
},
72+
},
73+
h6: {
74+
'@media (max-width:600px)': {
75+
fontSize: '1.1rem',
76+
},
77+
},
78+
body1: {
79+
'@media (max-width:600px)': {
80+
fontSize: '0.9rem',
81+
},
82+
},
83+
body2: {
84+
'@media (max-width:600px)': {
85+
fontSize: '0.8rem',
86+
},
87+
},
88+
},
89+
shape: {
90+
borderRadius: 10,
91+
},
92+
components: {
93+
MuiButton: {
94+
defaultProps: {
95+
sx: {
96+
textTransform: 'none',
97+
'&:hover': {
98+
backgroundColor: 'primary.light',
99+
},
100+
'&:active': {
101+
backgroundColor: 'primary.light',
102+
},
103+
fontWeight: 700,
104+
},
105+
},
106+
styleOverrides: {
107+
root: {
108+
'&.MuiButton-containedSuccess:hover': {
109+
backgroundColor: '#B3FFC7',
110+
},
111+
},
112+
},
113+
},
114+
MuiInputBase: {
115+
styleOverrides: {
116+
root: {
117+
fontSize: 'inherit !important',
118+
},
119+
},
120+
},
121+
},
122+
};
123+
124+
const theme = createTheme(themeOptions);
125+
126+
export default theme;
127+
128+
export const moreColors = {
129+
lightPaperBackground: lighten(theme.palette.background.paper, 0.05),
130+
lighterPaperBackground: lighten(theme.palette.background.paper, 0.5),
131+
lighterPrimary: lighten(theme.palette.primary.light, 0.5),
132+
lightSuccess: '#B3FFC7',
133+
lighterSuccess: lighten(theme.palette.success.light, 0.5),
134+
};

‎tsconfig.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es6",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"noEmit": true,
10+
"esModuleInterop": true,
11+
"module": "esnext",
12+
"moduleResolution": "node",
13+
"resolveJsonModule": true,
14+
"isolatedModules": true,
15+
"jsx": "preserve",
16+
"incremental": true,
17+
"plugins": [
18+
{
19+
"name": "next"
20+
}
21+
],
22+
"baseUrl": ".",
23+
"paths": {
24+
"@/*": ["./src/*"]
25+
}
26+
},
27+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
28+
"exclude": ["node_modules"]
29+
}

‎typings.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module "*.svg" {
2+
import React = require("react");
3+
export const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>;
4+
const src: string;
5+
export default src;
6+
}

‎yarn.lock

+4,337
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.