Skip to content

Commit

Permalink
continuation
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jun 22, 2019
1 parent ee5cc16 commit db12bb3
Show file tree
Hide file tree
Showing 39 changed files with 249 additions and 1,474 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ module.exports = {
},
},
],
}
};
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ typings/
# Lib folder
lib

.DS_Store
.DS_Store

2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
semi: true,
singleQuote: true,
singleQuote: false,
tabWidth: 2,
trailingComma: "all",
};
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
# gatsby-plugin-material-ui

> A [Gatsby](https://github.com/gatsbyjs/gatsby) plugin for
> [@material-ui/styles](https://github.com/mui-org/material-ui) with
> built-in server-side rendering support.
> A [Gatsby](https://github.com/gatsbyjs/gatsby) plugin for [@material-ui/styles](https://github.com/mui-org/material-ui) with built-in server-side rendering support.
This is the plugin for Material-UI v4. The plugin for v3 can be found [here](https://github.com/hupe1980/gatsby-plugin-material-ui/tree/v1.2.5).

## Install

`npm install --save gatsby-plugin-material-ui @material-ui/styles`

## Documentation

[The documentation](/gatsby-plugin-material-ui/README.md)

## Examples

You can find an official integration example of this plugin [on Material-UI side](https://github.com/mui-org/material-ui/tree/master/examples/gatsby), then you can pick one of the [Page Layout Examples](https://material-ui.com/getting-started/page-layout-examples/).

If you want to save time with a more opinionated solution. You can start with [a premade theme](https://github.com/hupe1980/gatsby-theme-material-ui).
[Read the documentation](/gatsby-plugin-material-ui/README.md).
2 changes: 1 addition & 1 deletion e2e-tests/development-runtime/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'cypress-testing-library/add-commands';
import "cypress-testing-library/add-commands";

Cypress.Commands.add(`lifecycleCallCount`, action =>
cy
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/development-runtime/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import 'gatsby-cypress';
import './commands';
import "gatsby-cypress";
import "./commands";
5 changes: 1 addition & 4 deletions e2e-tests/development-runtime/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ module.exports = {
`gatsby-plugin-top-layout`,
{
resolve: `gatsby-plugin-material-ui`,
// If you want to use styled components you should change the injection order.
options: {
pathToStylesProvider: `src/utils/styles-provider-props`,
pathToStylesProvider: `src/styles-provider-props`,
},
},
// If you want to use styled components you should add the plugin here.
`gatsby-plugin-styled-components`,
`gatsby-plugin-react-helmet`,
],
siteMetadata: {
Expand Down
5 changes: 1 addition & 4 deletions e2e-tests/development-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
"@material-ui/core": "latest",
"@material-ui/styles": "latest",
"gatsby": "latest",
"gatsby-plugin-material-ui": "^2.0.1",
"gatsby-plugin-react-helmet": "latest",
"gatsby-plugin-styled-components": "^3.0.7",
"react": "latest",
"react-dom": "latest",
"react-helmet": "latest",
"styled-components": "^4.3.1"
"react-helmet": "latest"
},
"license": "MIT",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import TopLayout from './top-layout';
import React from "react";
import TopLayout from "./top-layout";

export const wrapRootElement = ({ element }) => {
return <TopLayout>{element}</TopLayout>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import TopLayout from './top-layout';
import React from "react";
import TopLayout from "./top-layout";

export const wrapRootElement = ({ element }) => {
return <TopLayout>{element}</TopLayout>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Helmet } from 'react-helmet';
import CssBaseline from '@material-ui/core/CssBaseline';
import { ThemeProvider } from '@material-ui/styles';
import theme from '../../src/theme';
import React from "react";
import PropTypes from "prop-types";
import { Helmet } from "react-helmet";
import CssBaseline from "@material-ui/core/CssBaseline";
import { ThemeProvider } from "@material-ui/styles";
import theme from "../../src/theme";

let injectFirstNode;

export default function TopLayout(props) {
if (typeof window !== `undefined` && !injectFirstNode) {
const head = document.head;
injectFirstNode = document.createComment(`mui-inject-first`);
head.insertBefore(injectFirstNode, head.firstChild);
}

return (
<>
<Helmet>
Expand Down
6 changes: 3 additions & 3 deletions e2e-tests/development-runtime/src/components/link.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import MuiLink from '@material-ui/core/Link';
import { Link as GastsbyLink } from 'gatsby';
import React from "react";
import MuiLink from "@material-ui/core/Link";
import { Link as GastsbyLink } from "gatsby";

function Link(props) {
return <MuiLink component={GastsbyLink} {...props} />;
Expand Down
10 changes: 5 additions & 5 deletions e2e-tests/development-runtime/src/components/pro-tip.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Link from '@material-ui/core/Link';
import SvgIcon from '@material-ui/core/SvgIcon';
import Typography from '@material-ui/core/Typography';
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import Link from "@material-ui/core/Link";
import SvgIcon from "@material-ui/core/SvgIcon";
import Typography from "@material-ui/core/Typography";

function LightBulbIcon(props) {
return (
Expand Down
14 changes: 7 additions & 7 deletions e2e-tests/development-runtime/src/pages/about.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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 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/pro-tip';
import Link from '../components/link';
import ProTip from "../components/pro-tip";
import Link from "../components/link";

function MadeWithLove() {
return (
Expand Down
36 changes: 14 additions & 22 deletions e2e-tests/development-runtime/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
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 styled from 'styled-components';
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/pro-tip';
import Link from '../components/link';

const StyledH2 = styled(Typography)`
color: red;
`;
import ProTip from "../components/pro-tip";
import Link from "../components/link";

function MadeWithLove() {
return (
<>
<Typography variant="body2" color="textSecondary" align="center">
`Built with love by the `
<MuiLink color="inherit" href="https://material-ui.com/">
Material-UI
</MuiLink>
{` team.`}
</Typography>
<StyledH2 color="textSecondary">StyledH2, should be red</StyledH2>
</>
<Typography variant="body2" color="textSecondary" align="center">
{`Built with love by the `}
<MuiLink color="inherit" href="https://material-ui.com/">
Material-UI
</MuiLink>
{` team.`}
</Typography>
);
}

Expand Down
8 changes: 8 additions & 0 deletions e2e-tests/development-runtime/src/styles-provider-props.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { jssPreset } from "@material-ui/styles";
import { create } from "jss";

const stylesProviderProps = {
jss: create({ ...jssPreset(), insertionPoint: `mui-inject-first` }),
};

export default stylesProviderProps;
4 changes: 2 additions & 2 deletions e2e-tests/development-runtime/src/theme.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import red from '@material-ui/core/colors/red';
import { createMuiTheme } from '@material-ui/core/styles';
import red from "@material-ui/core/colors/red";
import { createMuiTheme } from "@material-ui/core/styles";

// A custom theme for this app
const theme = createMuiTheme({
Expand Down
17 changes: 0 additions & 17 deletions e2e-tests/development-runtime/src/utils/styles-provider-props.js

This file was deleted.

2 changes: 1 addition & 1 deletion e2e-tests/production-runtime/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'cypress-testing-library/add-commands';
import "cypress-testing-library/add-commands";

Cypress.Commands.add(`lifecycleCallCount`, action =>
cy
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/production-runtime/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import 'gatsby-cypress';
import './commands';
import "gatsby-cypress";
import "./commands";
7 changes: 1 addition & 6 deletions e2e-tests/production-runtime/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ module.exports = {
`gatsby-plugin-top-layout`,
{
resolve: `gatsby-plugin-material-ui`,
// If you want to use styled components you should change the injection order.
options: {
stylesProvider: {
// injectFirst: true,
},
pathToStylesProvider: `src/styles-provider-props`,
},
},
// If you want to use styled components you should add the plugin here.
`gatsby-plugin-styled-components`,
`gatsby-plugin-react-helmet`,
],
siteMetadata: {
Expand Down
3 changes: 1 addition & 2 deletions e2e-tests/production-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
"@material-ui/core": "latest",
"@material-ui/styles": "latest",
"gatsby": "latest",
"gatsby-plugin-material-ui": "^2.0.1",
"gatsby-plugin-react-helmet": "latest",
"react": "latest",
"react-dom": "latest",
"react-helmet": "latest",
"cross-env": "^5.2.0"
"cross-env": "latest"
},
"license": "MIT",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import TopLayout from './top-layout';
import React from "react";
import TopLayout from "./top-layout";

export const wrapRootElement = ({ element }) => {
return <TopLayout>{element}</TopLayout>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import TopLayout from './top-layout';
import React from "react";
import TopLayout from "./top-layout";

export const wrapRootElement = ({ element }) => {
return <TopLayout>{element}</TopLayout>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Helmet } from 'react-helmet';
import CssBaseline from '@material-ui/core/CssBaseline';
import { ThemeProvider } from '@material-ui/styles';
import theme from '../../src/theme';
import React from "react";
import PropTypes from "prop-types";
import { Helmet } from "react-helmet";
import CssBaseline from "@material-ui/core/CssBaseline";
import { ThemeProvider } from "@material-ui/styles";
import theme from "../../src/theme";

let injectFirstNode;

export default function TopLayout(props) {
if (typeof window !== `undefined` && !injectFirstNode) {
const head = document.head;
injectFirstNode = document.createComment(`mui-inject-first`);
head.insertBefore(injectFirstNode, head.firstChild);
}

return (
<>
<Helmet>
Expand Down
6 changes: 3 additions & 3 deletions e2e-tests/production-runtime/src/components/link.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import MuiLink from '@material-ui/core/Link';
import { Link as GastsbyLink } from 'gatsby';
import React from "react";
import MuiLink from "@material-ui/core/Link";
import { Link as GastsbyLink } from "gatsby";

function Link(props) {
return <MuiLink component={GastsbyLink} {...props} />;
Expand Down
10 changes: 5 additions & 5 deletions e2e-tests/production-runtime/src/components/pro-tip.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Link from '@material-ui/core/Link';
import SvgIcon from '@material-ui/core/SvgIcon';
import Typography from '@material-ui/core/Typography';
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import Link from "@material-ui/core/Link";
import SvgIcon from "@material-ui/core/SvgIcon";
import Typography from "@material-ui/core/Typography";

function LightBulbIcon(props) {
return (
Expand Down
14 changes: 7 additions & 7 deletions e2e-tests/production-runtime/src/pages/about.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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 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/pro-tip';
import Link from '../components/link';
import ProTip from "../components/pro-tip";
import Link from "../components/link";

function MadeWithLove() {
return (
Expand Down
14 changes: 7 additions & 7 deletions e2e-tests/production-runtime/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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 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/pro-tip';
import Link from '../components/link';
import ProTip from "../components/pro-tip";
import Link from "../components/link";

function MadeWithLove() {
return (
Expand Down
Loading

0 comments on commit db12bb3

Please sign in to comment.