Skip to content

Commit

Permalink
continue improving the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 23, 2021
1 parent 88a00a6 commit c0dbba9
Show file tree
Hide file tree
Showing 39 changed files with 59 additions and 111 deletions.
1 change: 1 addition & 0 deletions docs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ function AppWrapper(props) {
return (
<React.Fragment>
<NextHead>
<meta name="viewport" content="initial-scale=1, width=device-width" />
{fonts.map((font) => (
<link rel="stylesheet" href={font} key={font} />
))}
Expand Down
1 change: 0 additions & 1 deletion docs/src/modules/components/Head.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default function Head(props) {
const preview = card.startsWith('http') ? card : `${HOST}${card}`;
return (
<NextHead>
<meta name="viewport" content="initial-scale=1, width=device-width" />
<title>{title}</title>
<meta name="description" content={description} />
{/* Twitter */}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useUserLanguage } from 'docs/src/modules/utils/i18n';
*
* - /docs/src/modules/components/Link.tsx
* - /examples/nextjs/src/Link.tsx
* - /examples/nextjs-with-typescript/src/components/Link.tsx
* - /examples/nextjs-with-typescript/src/Link.tsx
*/

// Add support for the sx prop for consistency with the other branches.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/guides/routing/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const LinkBehavior = React.forwardRef((props, ref) => (
Next.js has [a custom Link component](https://nextjs.org/docs/api-reference/next/link).
The [example folder](https://github.com/mui-org/material-ui/tree/HEAD/examples/nextjs-with-typescript) provides adapters for usage with MUI.

- The first version of the adapter is the [`NextLinkComposed`](https://github.com/mui-org/material-ui/blob/HEAD/examples/nextjs-with-typescript/src/components/Link.tsx) component.
- The first version of the adapter is the [`NextLinkComposed`](https://github.com/mui-org/material-ui/blob/HEAD/examples/nextjs-with-typescript/src/Link.tsx) component.
This component is unstyled and only responsible for handling the navigation.
The prop `href` was renamed `to` to avoid a naming conflict.
This is similar to react-router's Link component.
Expand Down
4 changes: 4 additions & 0 deletions examples/create-react-app-with-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ or:

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/create-react-app-with-typescript)

<!-- #default-branch-switch -->

[![Edit on StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/mui-org/material-ui/tree/master/examples/create-react-app-with-typescript)

## The idea behind the example

This example demonstrates how you can use [Create React App](https://github.com/facebookincubator/create-react-app) with [TypeScript](https://github.com/Microsoft/TypeScript).
Expand Down
4 changes: 4 additions & 0 deletions examples/create-react-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ or:

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/create-react-app)

<!-- #default-branch-switch -->

[![Edit on StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/mui-org/material-ui/tree/master/examples/create-react-app)

## The idea behind the example

<!-- #default-branch-switch -->
Expand Down
6 changes: 0 additions & 6 deletions examples/gatsby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ npm install
npm run develop
```

or:

<!-- #default-branch-switch -->

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/gatsby)

## The idea behind the example

The project uses [Gatsby](https://github.com/gatsbyjs/gatsby), which is a static site generator for React.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/prefer-default-export */
import * as React from 'react';
import { CacheProvider } from '@emotion/react';
import createEmotionServer from '@emotion/server/create-instance';
Expand Down
5 changes: 0 additions & 5 deletions examples/gatsby/sandbox.config.json

This file was deleted.

2 changes: 2 additions & 0 deletions examples/joy-cra-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ or:

<!-- #default-branch-switch -->

[![Edit on StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/mui-org/material-ui/tree/master/examples/joy-cra-typescript)

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/joy-cra-typescript)
23 changes: 0 additions & 23 deletions examples/nextjs-with-typescript/.editorconfig

This file was deleted.

5 changes: 0 additions & 5 deletions examples/nextjs-with-typescript/.eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions examples/nextjs-with-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ or:

<!-- #default-branch-switch -->

[![Edit on StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/mui-org/material-ui/tree/master/examples/nextjs-with-typescript)

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/nextjs-with-typescript)

## The idea behind the example
Expand Down
1 change: 0 additions & 1 deletion examples/nextjs-with-typescript/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
Expand Down
3 changes: 2 additions & 1 deletion examples/nextjs-with-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"post-update": "echo \"codesandbox preview only, need an update\" && yarn upgrade --latest"
},
"dependencies": {
"@emotion/cache": "latest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ 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 '../styles/theme';
import createEmotionCache from '../utils/createEmotionCache';
import theme from '../src/theme';
import createEmotionCache from '../src/createEmotionCache';

// Client-side cache, shared for the whole session of the user in the browser.
const clientSideEmotionCache = createEmotionCache();
Expand All @@ -19,7 +19,6 @@ export default function MyApp(props: MyAppProps) {
return (
<CacheProvider value={emotionCache}>
<Head>
<title>Change title in _app.tsx</title>
<meta name="viewport" content="initial-scale=1, width=device-width" />
</Head>
<ThemeProvider theme={theme}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import Document, { Html, Head, Main, NextScript } from 'next/document';
import createEmotionServer from '@emotion/server/create-instance';
import theme from '../styles/theme';
import createEmotionCache from '../utils/createEmotionCache';
import theme from '../src/theme';
import createEmotionCache from '../src/createEmotionCache';

export default class MyDocument extends Document {
render() {
Expand All @@ -11,11 +11,13 @@ export default class MyDocument extends Document {
<Head>
{/* PWA primary color */}
<meta name="theme-color" content={theme.palette.primary.main} />
<link rel="shortcut icon" href="/static/favicon.ico" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
{/* Inject MUI styles first to match with the prepend: true configuration. */}
{(this.props as any).emotionStyleTags}
</Head>
<body>
<Main />
Expand Down Expand Up @@ -81,7 +83,6 @@ MyDocument.getInitialProps = async (ctx) => {

return {
...initialProps,
// Inject MUI styles first to match with the prepend: true configuration.
styles: [...emotionStyleTags, ...React.Children.toArray(initialProps.styles)],
emotionStyleTags,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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 '../components/Link';
import ProTip from '../components/ProTip';
import Copyright from '../components/Copyright';
import Link from '../src/Link';
import ProTip from '../src/ProTip';
import Copyright from '../src/Copyright';

const About: NextPage = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ 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 '../components/Link';
import ProTip from '../components/ProTip';
import Copyright from '../components/Copyright';
import Link from '../src/Link';
import ProTip from '../src/ProTip';
import Copyright from '../src/Copyright';

const Home: NextPage = () => {
return (
Expand Down
4 changes: 0 additions & 4 deletions examples/nextjs-with-typescript/public/vercel.svg

This file was deleted.

5 changes: 0 additions & 5 deletions examples/nextjs-with-typescript/sandbox.config.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ 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
// https://nextjs.org/docs/api-reference/next/link
const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(function Link(props, ref) {
const {
activeClassName = 'active',
Expand Down
10 changes: 0 additions & 10 deletions examples/nextjs-with-typescript/src/pages/api/hello.ts

This file was deleted.

2 changes: 2 additions & 0 deletions examples/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ or:

<!-- #default-branch-switch -->

[![Edit on StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/mui-org/material-ui/tree/master/examples/nextjs)

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/nextjs)

## The idea behind the example
Expand Down
3 changes: 3 additions & 0 deletions examples/nextjs/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
reactStrictMode: true,
};
19 changes: 12 additions & 7 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@
"name": "nextjs",
"version": "5.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"post-update": "echo \"codesandbox preview only, need an update\" && yarn upgrade --latest"
},
"dependencies": {
"@emotion/cache": "latest",
"@emotion/react": "latest",
"@emotion/styled": "latest",
"@emotion/server": "latest",
"@emotion/styled": "latest",
"@mui/icons-material": "latest",
"@mui/material": "latest",
"clsx": "latest",
"next": "latest",
"prop-types": "latest",
"react": "latest",
"react-dom": "latest"
},
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"post-update": "echo \"codesandbox preview only, need an update\" && yarn upgrade --latest"
"devDependencies": {
"eslint": "latest",
"eslint-config-next": "latest"
}
}
1 change: 0 additions & 1 deletion examples/nextjs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default function MyApp(props) {
return (
<CacheProvider value={emotionCache}>
<Head>
<title>My page</title>
<meta name="viewport" content="initial-scale=1, width=device-width" />
</Head>
<ThemeProvider theme={theme}>
Expand Down
6 changes: 4 additions & 2 deletions examples/nextjs/pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ export default class MyDocument extends Document {
<Head>
{/* PWA primary color */}
<meta name="theme-color" content={theme.palette.primary.main} />
<link rel="shortcut icon" href="/static/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.emotionStyleTags}
</Head>
<body>
<Main />
Expand Down Expand Up @@ -80,7 +83,6 @@ MyDocument.getInitialProps = async (ctx) => {

return {
...initialProps,
// Inject MUI styles first to match with the prepend: true configuration.
styles: [...emotionStyleTags, ...React.Children.toArray(initialProps.styles)],
emotionStyleTags,
};
};
Binary file added examples/nextjs/public/favicon.ico
Binary file not shown.
5 changes: 0 additions & 5 deletions examples/nextjs/sandbox.config.json

This file was deleted.

6 changes: 0 additions & 6 deletions examples/preact/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ npm install
npm run start
```

or:

<!-- #default-branch-switch -->

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/preact)

## The idea behind the example

The project uses [Preact](https://github.com/developit/preact), which is a fast 3kB alternative to React with the same modern API.
Expand Down
3 changes: 3 additions & 0 deletions examples/remix-with-typescript/.stackblitzrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"startCommand": "npm run dev"
}
2 changes: 2 additions & 0 deletions examples/remix-with-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ or:

<!-- #default-branch-switch -->

[![Edit on StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/mui-org/material-ui/tree/master/examples/remix-with-typescript)

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/remix-with-typescript)

## The idea behind the example
Expand Down
6 changes: 0 additions & 6 deletions examples/ssr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ npm install
npm run start
```

or:

<!-- #default-branch-switch -->

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/ssr)

## The idea behind the example

This is the reference implementation of the [Server Rendering tutorial](https://mui.com/guides/server-rendering/).
Expand Down
5 changes: 0 additions & 5 deletions examples/ssr/sandbox.config.json

This file was deleted.

0 comments on commit c0dbba9

Please sign in to comment.