Skip to content

Commit

Permalink
[examples] Move Copyright into its own component (#20383)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaNdTriX authored Apr 2, 2020
1 parent 79c6dfd commit 7bb8c2c
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 128 deletions.
22 changes: 12 additions & 10 deletions docs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import 'docs/src/modules/components/bootstrap';
// --- Post bootstrap -----
import React from 'react';
import App from 'next/app';
import find from 'lodash/find';
import { Provider as ReduxProvider, useDispatch, useSelector } from 'react-redux';
import { loadCSS } from 'fg-loadcss/src/loadCSS';
Expand Down Expand Up @@ -328,18 +327,21 @@ AppWrapper.propTypes = {
pageProps: PropTypes.object.isRequired,
};

export default class MyApp extends App {
render() {
const { Component, pageProps } = this.props;
export default function MyApp(props) {
const { Component, pageProps } = props;

return (
<AppWrapper pageProps={pageProps}>
<Component {...pageProps} />
</AppWrapper>
);
}
return (
<AppWrapper pageProps={pageProps}>
<Component {...pageProps} />
</AppWrapper>
);
}

MyApp.propTypes = {
Component: PropTypes.func.isRequired,
pageProps: PropTypes.object.isRequired,
};

MyApp.getInitialProps = async ({ ctx, Component }) => {
let pageProps = {};

Expand Down
16 changes: 16 additions & 0 deletions examples/gatsby-theme/src/components/Copyright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';
import { Link } from 'gatsby-theme-material-ui';

export default function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://material-ui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
14 changes: 1 addition & 13 deletions examples/gatsby-theme/src/pages/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,7 @@ import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
import { Link } from 'gatsby-theme-material-ui';
import ProTip from '../components/ProTip';

function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://material-ui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
import Copyright from '../components/Copyright';

export default function About() {
return (
Expand Down
14 changes: 1 addition & 13 deletions examples/gatsby-theme/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,7 @@ import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
import { Link } from 'gatsby-theme-material-ui';
import ProTip from '../components/ProTip';

function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://material-ui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
import Copyright from '../components/Copyright';

export default function Index() {
return (
Expand Down
16 changes: 16 additions & 0 deletions examples/gatsby/src/components/Copyright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';
import MuiLink from '@material-ui/core/Link';

export default function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://material-ui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
15 changes: 1 addition & 14 deletions examples/gatsby/src/pages/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@ import React from 'react';
import Container from '@material-ui/core/Container';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
import MuiLink from '@material-ui/core/Link';
import ProTip from '../components/ProTip';
import Link from '../components/Link';

function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://material-ui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
import Copyright from '../components/Copyright';

export default function About() {
return (
Expand Down
15 changes: 1 addition & 14 deletions examples/gatsby/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@ import React from 'react';
import Container from '@material-ui/core/Container';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
import MuiLink from '@material-ui/core/Link';
import ProTip from '../components/ProTip';
import Link from '../components/Link';

function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://material-ui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
import Copyright from '../components/Copyright';

export default function Index() {
return (
Expand Down
10 changes: 6 additions & 4 deletions examples/nextjs-with-typescript/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React, { useEffect } from 'react';
import React from 'react';
import Head from 'next/head';
import { AppProps } from 'next/app';
import { ThemeProvider } from '@material-ui/core/styles';
import CssBaseline from '@material-ui/core/CssBaseline';
import theme from '../src/theme';

export default function MyApp({ Component, pageProps }: AppProps) {
useEffect(() => {
export default function MyApp(props: AppProps) {
const { Component, pageProps } = props;

React.useEffect(() => {
// Remove the server-side injected CSS.
const jssStyles = document.getElementById('jss-server-side');
const jssStyles = document.querySelector('#jss-server-side');
if (jssStyles) {
jssStyles.parentElement!.removeChild(jssStyles);
}
Expand Down
15 changes: 1 addition & 14 deletions examples/nextjs-with-typescript/pages/about.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@ import React from 'react';
import Container from '@material-ui/core/Container';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
import MuiLink from '@material-ui/core/Link';
import ProTip from '../src/ProTip';
import Link from '../src/Link';

function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://material-ui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
import Copyright from '../src/Copyright';

export default function About() {
return (
Expand Down
15 changes: 1 addition & 14 deletions examples/nextjs-with-typescript/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@ import React from 'react';
import Container from '@material-ui/core/Container';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
import MuiLink from '@material-ui/core/Link';
import ProTip from '../src/ProTip';
import Link from '../src/Link';

function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://material-ui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
import Copyright from '../src/Copyright';

export default function Index() {
return (
Expand Down
16 changes: 16 additions & 0 deletions examples/nextjs-with-typescript/src/Copyright.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';
import MuiLink from '@material-ui/core/Link';

export default function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://material-ui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
10 changes: 6 additions & 4 deletions examples/nextjs/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React, { useEffect } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import Head from 'next/head';
import { ThemeProvider } from '@material-ui/core/styles';
import CssBaseline from '@material-ui/core/CssBaseline';
import theme from '../src/theme';

export default function MyApp({ Component, pageProps }) {
useEffect(() => {
export default function MyApp(props) {
const { Component, pageProps } = props;

React.useEffect(() => {
// Remove the server-side injected CSS.
const jssStyles = document.getElementById('jss-server-side');
const jssStyles = document.querySelector('#jss-server-side');
if (jssStyles) {
jssStyles.parentElement.removeChild(jssStyles);
}
Expand Down
15 changes: 1 addition & 14 deletions examples/nextjs/pages/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,10 @@ import React from 'react';
import Container from '@material-ui/core/Container';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
import MuiLink from '@material-ui/core/Link';
import Button from '@material-ui/core/Button';
import ProTip from '../src/ProTip';
import Link from '../src/Link';

function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://material-ui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
import Copyright from '../src/Copyright';

export default function About() {
return (
Expand Down
15 changes: 1 addition & 14 deletions examples/nextjs/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@ import React from 'react';
import Container from '@material-ui/core/Container';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
import MuiLink from '@material-ui/core/Link';
import ProTip from '../src/ProTip';
import Link from '../src/Link';

function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://material-ui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
import Copyright from '../src/Copyright';

export default function Index() {
return (
Expand Down
16 changes: 16 additions & 0 deletions examples/nextjs/src/Copyright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';
import MuiLink from '@material-ui/core/Link';

export default function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://material-ui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}

0 comments on commit 7bb8c2c

Please sign in to comment.