diff --git a/examples/using-wordpress/gatsby-node.js b/examples/using-wordpress/gatsby-node.js index 2d6f1e17024b6..b4e92f11b230f 100644 --- a/examples/using-wordpress/gatsby-node.js +++ b/examples/using-wordpress/gatsby-node.js @@ -2,22 +2,22 @@ const _ = require(`lodash`) const Promise = require(`bluebird`) const path = require(`path`) const slash = require(`slash`) - -// Implement the Gatsby API “createPages”. This is -// called after the Gatsby bootstrap is finished so you have -// access to any information necessary to programatically -// create pages. -// Will create pages for Wordpress pages (route : /{slug}) -// Will create pages for Wordpress posts (route : /post/{slug}) + +// Implement the Gatsby API “createPages”. This is +// called after the Gatsby bootstrap is finished so you have +// access to any information necessary to programatically +// create pages. +// Will create pages for Wordpress pages (route : /{slug}) +// Will create pages for Wordpress posts (route : /post/{slug}) exports.createPages = ({ graphql, boundActionCreators }) => { const { createPage } = boundActionCreators return new Promise((resolve, reject) => { - // The “graphql” function allows us to run arbitrary - // queries against the local Wordpress graphql schema. Think of - // it like the site has a built-in database constructed - // from the fetched data that you can run queries against. - - // ==== PAGES (WORDPRESS NATIVE) ==== + // The “graphql” function allows us to run arbitrary + // queries against the local Wordpress graphql schema. Think of + // it like the site has a built-in database constructed + // from the fetched data that you can run queries against. + + // ==== PAGES (WORDPRESS NATIVE) ==== graphql( ` { @@ -41,21 +41,21 @@ exports.createPages = ({ graphql, boundActionCreators }) => { console.log(result.errors) reject(result.errors) } - - // Create Page pages. - const pageTemplate = path.resolve('./src/templates/page.js') - // We want to create a detailed page for each - // page node. We'll just use the Wordpress Slug for the slug. - // The Page ID is prefixed with 'PAGE_' + + // Create Page pages. + const pageTemplate = path.resolve(`./src/templates/page.js`) + // We want to create a detailed page for each + // page node. We'll just use the Wordpress Slug for the slug. + // The Page ID is prefixed with 'PAGE_' _.each(result.data.allWordpressPage.edges, edge => { - // Gatsby uses Redux to manage its internal state. - // Plugins and sites can use functions like "createPage" - // to interact with Gatsby. + // Gatsby uses Redux to manage its internal state. + // Plugins and sites can use functions like "createPage" + // to interact with Gatsby. createPage({ - // Each page is required to have a `path` as well - // as a template component. The `context` is - // optional but is often necessary so the template - // can query data specific to each page. + // Each page is required to have a `path` as well + // as a template component. The `context` is + // optional but is often necessary so the template + // can query data specific to each page. path: `/${edge.node.slug}/`, component: slash(pageTemplate), context: { @@ -64,9 +64,9 @@ exports.createPages = ({ graphql, boundActionCreators }) => { }) }) }) - // ==== END PAGES ==== - - // ==== POSTS (WORDPRESS NATIVE AND ACF) ==== + // ==== END PAGES ==== + + // ==== POSTS (WORDPRESS NATIVE AND ACF) ==== .then(() => { graphql( `{ @@ -89,10 +89,10 @@ exports.createPages = ({ graphql, boundActionCreators }) => { console.log(result.errors) reject(result.errors) } - const postTemplate = path.resolve('./src/templates/post.js') - // We want to create a detailed page for each - // post node. We'll just use the Wordpress Slug for the slug. - // The Post ID is prefixed with 'POST_' + const postTemplate = path.resolve(`./src/templates/post.js`) + // We want to create a detailed page for each + // post node. We'll just use the Wordpress Slug for the slug. + // The Post ID is prefixed with 'POST_' _.each(result.data.allWordpressPost.edges, edge => { createPage({ path: `/post/${edge.node.slug}/`, @@ -104,8 +104,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => { }) resolve() }) - }) - // ==== END POSTS ==== - + }) + // ==== END POSTS ==== }) -} \ No newline at end of file +} diff --git a/examples/using-wordpress/src/components/Footer.js b/examples/using-wordpress/src/components/Footer.js index b265c759c9e2e..4aae11cbcbfaf 100644 --- a/examples/using-wordpress/src/components/Footer.js +++ b/examples/using-wordpress/src/components/Footer.js @@ -1,13 +1,11 @@ -import React from 'react'; -import { Page, Row } from './styled'; +import React from "react" +import { Page, Row } from "./styled" const Footer = props => -export default Footer; \ No newline at end of file +export default Footer diff --git a/examples/using-wordpress/src/components/Header.js b/examples/using-wordpress/src/components/Header.js index 2dcc2d4bc0919..9b17b67e66300 100644 --- a/examples/using-wordpress/src/components/Header.js +++ b/examples/using-wordpress/src/components/Header.js @@ -1,39 +1,49 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import Link from 'gatsby-link'; -import { H1, H2, H3, H4 } from '../components/styled'; -import { Row, Page, Column } from './styled'; - -const Header = ({ title, subtitle, pages }) => { +import React from "react" +import PropTypes from "prop-types" +import Link from "gatsby-link" +import { H1, H2, H3, H4 } from "../components/styled" +import { Row, Page, Column } from "./styled" +const Header = ({ title, subtitle, pages }) => // TODO : Sort order of menu based on field menu_order - return ( + ( -

{title}

+

+ {title} +

-

{subtitle}

+

+ {subtitle} +

- Home - + + Home -{` `} + {pages.edges.map((p, i) => { - if (p.node.slug == 'blog') return - if (p.node.slug == 'home') return - return {i !== 0 ? ' - ' : ''}{unescape(p.node.title)} + if (p.node.slug == `blog`) return + if (p.node.slug == `home`) return + return ( + + {i !== 0 ? ` - ` : ``} + + {unescape(p.node.title)} + + + ) })}
) -} Header.propTypes = { title: PropTypes.string, pages: PropTypes.object.isRequired, } - -export default Header; \ No newline at end of file +export default Header diff --git a/examples/using-wordpress/src/components/PostPreview.js b/examples/using-wordpress/src/components/PostPreview.js index 47bf4b5bd226d..b4b51ebc29407 100644 --- a/examples/using-wordpress/src/components/PostPreview.js +++ b/examples/using-wordpress/src/components/PostPreview.js @@ -1,21 +1,34 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { Row, Page, Column, BlockLink, P2, P4 } from './styled'; -import styled from 'styled-components'; -import theme from './styled/theme'; +import React from "react" +import PropTypes from "prop-types" +import { Row, Page, Column, BlockLink, P2, P4 } from "./styled" +import styled from "styled-components" +import theme from "./styled/theme" -const BlogPreviewImg = styled.img` - width: 100%; -`; +const BlogPreviewImg = styled.img`width: 100%;` const PostPreview = ({ article, id }) => { - console.log('article is', article) + console.log(`article is`, article) return ( - - - - + + + + Read More @@ -27,4 +40,4 @@ PostPreview.propType = { id: PropTypes.string, } -export default PostPreview; \ No newline at end of file +export default PostPreview diff --git a/examples/using-wordpress/src/components/PostsListSearchable.js b/examples/using-wordpress/src/components/PostsListSearchable.js index 3e795d391f423..8aad87947fbd9 100644 --- a/examples/using-wordpress/src/components/PostsListSearchable.js +++ b/examples/using-wordpress/src/components/PostsListSearchable.js @@ -1,68 +1,63 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { H3, Row, Page, Column } from './styled'; -import PostPreview from './PostPreview' +import React, { Component } from "react" +import PropTypes from "prop-types" +import { H3, Row, Page, Column } from "./styled" +import PostPreview from "./PostPreview" class PostsListSearchable extends Component { - // Put the props in the state constructor(props) { super(props) this.state = { - data: this.props.propsData.allWordpressPost.edges + data: this.props.propsData.allWordpressPost.edges, } } handleFilter = id => { this.setState({ - data: this.props.propsData.allWordpressPost.edges.filter(p => { - return p.node.categories.includes(id.replace('CATEGORY_', '')) - }) + data: this.props.propsData.allWordpressPost.edges.filter(p => p.node.categories.includes(id.replace(`CATEGORY_`, ``))), }) } - resetFilter = () => this.setState({ data: this.props.propsData.allWordpressPost.edges }) + resetFilter = () => + this.setState({ data: this.props.propsData.allWordpressPost.edges }) render() { - return (

The latests blog posts

- Filter by category: + Filter by category: this.resetFilter()}>All - - { - this.props.propsData.allWordpressCategory.edges.map((cat, i) => { - - return ( this.handleFilter(cat.node.id)} - > - {i !== 0 ? ' - ':''}{cat.node.name} - ) - }) - } + {this.props.propsData.allWordpressCategory.edges.map((cat, i) => ( + this.handleFilter(cat.node.id)} + > + {i !== 0 ? ` - ` : ``} + {cat.node.name} + + ))} this.resetFilter()}> - Reset filter - { - this.state.data.map(article => - )} - - + {this.state.data.map(article => + + )} +
) } - - } - PostsListSearchable.propTypes = { propsData: PropTypes.object.isRequired, } -export default PostsListSearchable; \ No newline at end of file +export default PostsListSearchable diff --git a/examples/using-wordpress/src/components/styled/index.js b/examples/using-wordpress/src/components/styled/index.js index c59ea262212d7..d8d1375e3da93 100644 --- a/examples/using-wordpress/src/components/styled/index.js +++ b/examples/using-wordpress/src/components/styled/index.js @@ -1,131 +1,134 @@ -import React from 'react'; -import styled, { injectGlobal, extend } from 'styled-components'; -import Link from 'gatsby-link'; -import * as PR from './propReceivers'; -import theme from './theme'; -import { fontFaceHelper } from '../../utils/fontFaceHelper'; -export { - Page, - Row, - Column -} from './layout'; - - -const { ftz, color } = theme; - +import React from "react" +import styled, { injectGlobal, extend } from "styled-components" +import Link from "gatsby-link" +import * as PR from "./propReceivers" +import theme from "./theme" +import { fontFaceHelper } from "../../utils/fontFaceHelper" +export { Page, Row, Column } from "./layout" +const { ftz, color } = theme /* Global Styles */ injectGlobal` - ${fontFaceHelper('butler', 'butler_black-webfont')} - ${fontFaceHelper('butler', 'butler_black_stencil-webfont', 'normal')} - ${fontFaceHelper('butler', 'butler_regular-webfont')} + ${fontFaceHelper(`butler`, `butler_black-webfont`)} + ${fontFaceHelper(`butler`, `butler_black_stencil-webfont`, `normal`)} + ${fontFaceHelper(`butler`, `butler_regular-webfont`)} body { font-family: 'butler', sans-serif; margin: 0; background-color: ${color.lightGray}; } -`; - +` /* Global Tags */ export const H1 = styled.h1` - ${props => PR.ftzProps(props, ftz.h1)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.h1)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const H2 = styled.h2` - ${props => PR.ftzProps(props, ftz.h2)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.h2)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const H3 = styled.h3` - ${props => PR.ftzProps(props, ftz.h3)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.h3)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const H4 = styled.h4` - ${props => PR.ftzProps(props, ftz.h4)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.h4)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const H5 = styled.h5` - ${props => PR.ftzProps(props, ftz.h5)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.h5)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const H6 = styled.h6` - ${props => PR.ftzProps(props, ftz.h6)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.h6)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const H7 = styled.h6` - ${props => PR.ftzProps(props, ftz.h6)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.h6)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const P1 = styled.p` - ${props => PR.ftzProps(props, ftz.p1)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.p1)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const P2 = styled.p` - ${props => PR.ftzProps(props, ftz.p2)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.p2)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const P3 = styled.p` - ${props => PR.ftzProps(props, ftz.p3)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.p3)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const P4 = styled.p` - ${props => PR.ftzProps(props, ftz.p4)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; + ${props => PR.ftzProps(props, ftz.p4)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` export const P5 = styled.p` - ${props => PR.ftzProps(props, ftz.p5)} - ${props => PR.colorProps(props)} - ${PR.marginProps} -`; - + ${props => PR.ftzProps(props, ftz.p5)} ${props => + PR.colorProps(props)} ${PR.marginProps}; +` /* Links */ -export const DefaultLink = styled(({ - h1, h2, h3, h4, h5, h6, h7, p1, p2, p3, p4, p5, ftz, - marginBottom, marginTop, marginLeft, marginRight, margin, marginVertical, marginHorizontal, - paddingBottom, paddingTop, paddingLeft, paddingRight, padding, paddingVertical, paddingHorizontal, - color, - colorHover, - underline, - block, - ...rest -}) => )` +export const DefaultLink = styled( + ({ + h1, + h2, + h3, + h4, + h5, + h6, + h7, + p1, + p2, + p3, + p4, + p5, + ftz, + marginBottom, + marginTop, + marginLeft, + marginRight, + margin, + marginVertical, + marginHorizontal, + paddingBottom, + paddingTop, + paddingLeft, + paddingRight, + padding, + paddingVertical, + paddingHorizontal, + color, + colorHover, + underline, + block, + ...rest + }) => +)` ${props => PR.ftzProps(props)} ${props => PR.colorProps(props, color.link)} - text-decoration: ${props => props.underline ? 'underline' : 'none'}; + text-decoration: ${props => (props.underline ? `underline` : `none`)}; &:hover { - ${props => PR.colorHoverProps(props, 'blue')} - ${props => props.block && typeof(props.block) === 'boolean' && `background-color: ${color.white}`} + ${props => PR.colorHoverProps(props, `blue`)} + ${props => + props.block && + typeof props.block === `boolean` && + `background-color: ${color.white}`} } -`; +` -export const StyledLink = DefaultLink.extend` - ${PR.marginProps} -`; +export const StyledLink = DefaultLink.extend`${PR.marginProps};` export const BlockLink = DefaultLink.extend` - ${PR.paddingProps} - display: block; + ${PR.paddingProps} display: block; &:hover { - background-color: ${color.white} + background-color: ${color.white}; } -`; +` export const Div = styled.footer` ${PR.backgroundProps}; ${PR.heightProps}; -`; - - +` diff --git a/examples/using-wordpress/src/components/styled/layout.js b/examples/using-wordpress/src/components/styled/layout.js index ee7a43fc0f482..6cb5ae34c5012 100644 --- a/examples/using-wordpress/src/components/styled/layout.js +++ b/examples/using-wordpress/src/components/styled/layout.js @@ -1,14 +1,14 @@ -import React from 'react'; -import styled, { css } from 'styled-components'; -import { compute, ifDefined } from '../../utils/hedron'; -import * as PR from './propReceivers'; +import React from "react" +import styled, { css } from "styled-components" +import { compute, ifDefined } from "../../utils/hedron" +import * as PR from "./propReceivers" import { Page as HedronPage, Row as HedronRow, - Column as HedronColumn -} from 'hedron'; -import theme from './theme'; -const { sizes, color } = theme; + Column as HedronColumn, +} from "hedron" +import theme from "./theme" +const { sizes, color } = theme /* * Media Queries @@ -18,7 +18,6 @@ const { sizes, color } = theme; * lg: 992 and beyound */ - // const media = { // tablet: (...args) => css` // @media (min-width: 420px) { @@ -29,12 +28,12 @@ const { sizes, color } = theme; // Iterate through the sizes and create a media template export const media = Object.keys(sizes).reduce((acc, label) => { - acc[label] = (...args) => css` + acc[label] = (...args) => css` @media (max-width: ${sizes[label] / 16}em) { ${css(...args)} } ` - return acc + return acc }, {}) /* @@ -43,30 +42,24 @@ export const media = Object.keys(sizes).reduce((acc, label) => { export const Page = styled(HedronPage)` ${props => props.fluid - ? 'width: 100%;' + ? `width: 100%;` : ` margin: 0 auto; max-width: 100%; - ${props.width - ? `width: ${props.width};` - : `width: ${sizes.max};` - } - ` - } -`; - + ${props.width ? `width: ${props.width};` : `width: ${sizes.max};`} + `} +` export const RowHedron = styled(HedronRow)` display: flex; flex-direction: row; flex-wrap: wrap; - ${ifDefined('alignContent', 'align-content')} - ${ifDefined('alignItems', 'align-items')} - ${ifDefined('alignSelf', 'align-self')} - ${ifDefined('justifyContent', 'justify-content')} - ${ifDefined('order')} -`; - + ${ifDefined(`alignContent`, `align-content`)} + ${ifDefined(`alignItems`, `align-items`)} + ${ifDefined(`alignSelf`, `align-self`)} + ${ifDefined(`justifyContent`, `justify-content`)} + ${ifDefined(`order`)} +` export const gutter = props => css` padding-right: 40px; @@ -75,41 +68,47 @@ export const gutter = props => css` padding-right: 15px; padding-left: 15px; `} -`; - +` -export const Row = styled(({ - gutter, - gutterWhite, - height, - borderBottom, borderTop, borderLeft, borderRight, - outline, - ...rest - }) => )` +export const Row = styled( + ({ + gutter, + gutterWhite, + height, + borderBottom, + borderTop, + borderLeft, + borderRight, + outline, + ...rest + }) => +)` - ${props => props.gutter && gutter }; - ${props => css` background-color: ${props.gutterWhite ? color.white : color.lightGray}`}; + ${props => props.gutter && gutter}; + ${props => + css` background-color: ${props.gutterWhite + ? color.white + : color.lightGray}`}; ${PR.heightProps}; ${PR.borderProps}; ${PR.outlineProps}; -`; - +` -export const Column = styled(({ - outline, ...rest - }) => )` +export const Column = styled(({ outline, ...rest }) => + +)` display: block; - ${props => props.debug - ? `background-color: rgba(50, 50, 255, .1); + ${props => + props.debug + ? `background-color: rgba(50, 50, 255, .1); outline: 1px solid #fff;` - : '' - } + : ``} box-sizing: border-box; padding: 0; width: 100%; - ${compute('xs')} - ${compute('sm')} - ${compute('md')} - ${compute('lg')} + ${compute(`xs`)} + ${compute(`sm`)} + ${compute(`md`)} + ${compute(`lg`)} ${PR.outlineProps} -`; \ No newline at end of file +` diff --git a/examples/using-wordpress/src/components/styled/propReceivers.js b/examples/using-wordpress/src/components/styled/propReceivers.js index 90ed50fd49332..41b12408678d5 100644 --- a/examples/using-wordpress/src/components/styled/propReceivers.js +++ b/examples/using-wordpress/src/components/styled/propReceivers.js @@ -1,94 +1,229 @@ -import { css } from 'styled-components'; -import theme from './theme'; -const { ftz, color, goldenRatio } = theme; +import { css } from "styled-components" +import theme from "./theme" +const { ftz, color, goldenRatio } = theme -// FONT SIZES +// FONT SIZES const ftzMap = p => { - if(p.h1) { return css`font-size: ${ftz.h1};`; } - if(p.h2) { return css`font-size: ${ftz.h2};`; } - if(p.h3) { return css`font-size: ${ftz.h3};`; } - if(p.h4) { return css`font-size: ${ftz.h4};`; } - if(p.h5) { return css`font-size: ${ftz.h5};`; } - if(p.h6) { return css`font-size: ${ftz.h6};`; } - if(p.h7) { return css`font-size: ${ftz.h7};`; } - if(p.p1) { return css`font-size: ${ftz.p1};`; } - if(p.p2) { return css`font-size: ${ftz.p2};`; } - if(p.p3) { return css`font-size: ${ftz.p3};`; } - if(p.p4) { return css`font-size: ${ftz.p4};`; } - if(p.p5) { return css`font-size: ${ftz.p5};`; } + if (p.h1) { + return css`font-size: ${ftz.h1};` + } + if (p.h2) { + return css`font-size: ${ftz.h2};` + } + if (p.h3) { + return css`font-size: ${ftz.h3};` + } + if (p.h4) { + return css`font-size: ${ftz.h4};` + } + if (p.h5) { + return css`font-size: ${ftz.h5};` + } + if (p.h6) { + return css`font-size: ${ftz.h6};` + } + if (p.h7) { + return css`font-size: ${ftz.h7};` + } + if (p.p1) { + return css`font-size: ${ftz.p1};` + } + if (p.p2) { + return css`font-size: ${ftz.p2};` + } + if (p.p3) { + return css`font-size: ${ftz.p3};` + } + if (p.p4) { + return css`font-size: ${ftz.p4};` + } + if (p.p5) { + return css`font-size: ${ftz.p5};` + } } -export const ftzPropsVar = { h1: 'h1', h2: 'h2', h3: 'h3', h4: 'h4', h5: 'h5', h6: 'h6', h7: 'h7', p1: 'p1', p2: 'p2', p3: 'p3', p4: 'p4', p5: 'p5', ftz: 'ftz' }; -export const ftzProps = (props, def='inherit') => { - if (props.h1 || props.h2 || props.h3 || props.h4 || props.h5 || props.h6 || props.h7 || props.p1 || props.p2 || props.p3 || props.p4 || props.p5){ - return ftzMap(props); - } else if(props.ftz) { - return css`font-size: ${props.ftz};`; +export const ftzPropsVar = { + h1: `h1`, + h2: `h2`, + h3: `h3`, + h4: `h4`, + h5: `h5`, + h6: `h6`, + h7: `h7`, + p1: `p1`, + p2: `p2`, + p3: `p3`, + p4: `p4`, + p5: `p5`, + ftz: `ftz`, +} +export const ftzProps = (props, def = `inherit`) => { + if ( + props.h1 || + props.h2 || + props.h3 || + props.h4 || + props.h5 || + props.h6 || + props.h7 || + props.p1 || + props.p2 || + props.p3 || + props.p4 || + props.p5 + ) { + return ftzMap(props) + } else if (props.ftz) { + return css`font-size: ${props.ftz};` } else { - return css`font-size: ${def};`; + return css`font-size: ${def};` } } // COLOR -export const colorProps = (props, def='inherit') => css` - color: ${props.color && typeof(props.color === 'string') ? props.color : def}; -`; -export const colorHoverProps = (props, def='inherit') => css` - color: ${props.colorHover && typeof(props.colorHover === 'string') ? props.colorHover : def}; -`; +export const colorProps = (props, def = `inherit`) => css` + color: ${props.color && typeof (props.color === `string`) + ? props.color + : def}; +` +export const colorHoverProps = (props, def = `inherit`) => css` + color: ${props.colorHover && typeof (props.colorHover === `string`) + ? props.colorHover + : def}; +` // MARGIN -export const marginPropsVar = { marginBottom: 'marginBottom', marginTop: 'marginTop', marginLeft: 'marginLeft', marginRight: 'marginRight', margin: 'margin', marginVertical: 'marginVertical', marginHorizontal: 'marginHorizontal' }; +export const marginPropsVar = { + marginBottom: `marginBottom`, + marginTop: `marginTop`, + marginLeft: `marginLeft`, + marginRight: `marginRight`, + margin: `margin`, + marginVertical: `marginVertical`, + marginHorizontal: `marginHorizontal`, +} export const marginProps = props => css` - ${props.marginBottom && `margin-bottom: ${typeof (props.marginBottom) === 'string' ? props.marginBottom : `${(props.marginBottom * goldenRatio)}px` || '1em'}`}; - ${props.marginTop && `margin-top: ${typeof (props.marginTop) === 'string' ? props.marginTop : `${(props.marginTop * goldenRatio)}px` || '1em'}`}; - ${props.marginLeft && `margin-left: ${typeof (props.marginLeft) === 'string' ? props.marginLeft : `${(props.marginLeft * goldenRatio)}px` || '1em'}`}; - ${props.marginRight && `margin-right: ${typeof (props.marginRight) === 'string' ? props.marginRight : `${(props.marginRight * goldenRatio)}px` || '1em'}`}; - ${props.margin && `margin: ${typeof (props.margin) === 'string' ? props.margin : `${(props.margin * goldenRatio)}px` || '1em'}`}; - ${props.marginVertical && ` - margin-top: ${typeof (props.marginVertical) === 'string' ? props.marginVertical : `${(props.marginVertical * goldenRatio)}px` || '1em'}; - margin-bottom: ${typeof (props.marginVertical) === 'string' ? props.marginVertical : `${(props.marginVertical * goldenRatio)}px` || '1em'}; + ${props.marginBottom && + `margin-bottom: ${typeof props.marginBottom === `string` + ? props.marginBottom + : `${props.marginBottom * goldenRatio}px` || `1em`}`}; + ${props.marginTop && + `margin-top: ${typeof props.marginTop === `string` + ? props.marginTop + : `${props.marginTop * goldenRatio}px` || `1em`}`}; + ${props.marginLeft && + `margin-left: ${typeof props.marginLeft === `string` + ? props.marginLeft + : `${props.marginLeft * goldenRatio}px` || `1em`}`}; + ${props.marginRight && + `margin-right: ${typeof props.marginRight === `string` + ? props.marginRight + : `${props.marginRight * goldenRatio}px` || `1em`}`}; + ${props.margin && + `margin: ${typeof props.margin === `string` + ? props.margin + : `${props.margin * goldenRatio}px` || `1em`}`}; + ${props.marginVertical && + ` + margin-top: ${typeof props.marginVertical === `string` + ? props.marginVertical + : `${props.marginVertical * goldenRatio}px` || `1em`}; + margin-bottom: ${typeof props.marginVertical === `string` + ? props.marginVertical + : `${props.marginVertical * goldenRatio}px` || `1em`}; `}; - ${props.marginHorizontal && ` - margin-left: ${typeof (props.marginHorizontal) === 'string' ? props.marginHorizontal : `${(props.marginHorizontal * goldenRatio)}px` || '1em'}; - margin-right: ${typeof (props.marginHorizontal) === 'string' ? props.marginHorizontal : `${(props.marginHorizontal * goldenRatio)}px` || '1em'}; + ${props.marginHorizontal && + ` + margin-left: ${typeof props.marginHorizontal === `string` + ? props.marginHorizontal + : `${props.marginHorizontal * goldenRatio}px` || `1em`}; + margin-right: ${typeof props.marginHorizontal === `string` + ? props.marginHorizontal + : `${props.marginHorizontal * goldenRatio}px` || `1em`}; `}; -`; +` // PADDING -export const paddingPropsVar = { paddingBottom: 'paddingBottom', paddingTop: 'paddingTop', paddingLeft: 'paddingLeft', paddingRight: 'paddingRight', padding: 'padding', paddingVertical: 'paddingVertical', paddingHorizontal: 'paddingHorizontal' }; +export const paddingPropsVar = { + paddingBottom: `paddingBottom`, + paddingTop: `paddingTop`, + paddingLeft: `paddingLeft`, + paddingRight: `paddingRight`, + padding: `padding`, + paddingVertical: `paddingVertical`, + paddingHorizontal: `paddingHorizontal`, +} export const paddingProps = props => css` - ${props.paddingBottom && `padding-bottom: ${typeof (props.paddingBottom) === 'string' ? props.paddingBottom : `${(props.paddingBottom * goldenRatio)}px` || '1em'}`}; - ${props.paddingTop && `padding-top: ${typeof (props.paddingTop) === 'string' ? props.paddingTop : `${(props.paddingTop * goldenRatio)}px` || '1em'}`}; - ${props.paddingLeft && `padding-left: ${typeof (props.paddingLeft) === 'string' ? props.paddingLeft : `${(props.paddingLeft * goldenRatio)}px` || '1em'}`}; - ${props.paddingRight && `padding-right: ${typeof (props.paddingRight) === 'string' ? props.paddingRight : `${(props.paddingRight * goldenRatio)}px` || '1em'}`}; - ${props.padding && `padding: ${typeof (props.padding) === 'string' ? props.padding : `${(props.padding * goldenRatio)}px` || '1em'}`}; - ${props.paddingVertical && ` - padding-top: ${typeof (props.paddingVertical) === 'string' ? props.paddingVertical : `${(props.paddingVertical * goldenRatio)}px` || '1em'}; - padding-bottom: ${typeof (props.paddingVertical) === 'string' ? props.paddingVertical : `${(props.paddingVertical * goldenRatio)}px` || '1em'}; + ${props.paddingBottom && + `padding-bottom: ${typeof props.paddingBottom === `string` + ? props.paddingBottom + : `${props.paddingBottom * goldenRatio}px` || `1em`}`}; + ${props.paddingTop && + `padding-top: ${typeof props.paddingTop === `string` + ? props.paddingTop + : `${props.paddingTop * goldenRatio}px` || `1em`}`}; + ${props.paddingLeft && + `padding-left: ${typeof props.paddingLeft === `string` + ? props.paddingLeft + : `${props.paddingLeft * goldenRatio}px` || `1em`}`}; + ${props.paddingRight && + `padding-right: ${typeof props.paddingRight === `string` + ? props.paddingRight + : `${props.paddingRight * goldenRatio}px` || `1em`}`}; + ${props.padding && + `padding: ${typeof props.padding === `string` + ? props.padding + : `${props.padding * goldenRatio}px` || `1em`}`}; + ${props.paddingVertical && + ` + padding-top: ${typeof props.paddingVertical === `string` + ? props.paddingVertical + : `${props.paddingVertical * goldenRatio}px` || `1em`}; + padding-bottom: ${typeof props.paddingVertical === `string` + ? props.paddingVertical + : `${props.paddingVertical * goldenRatio}px` || `1em`}; `}; - ${props.paddingHorizontal && ` - padding-left: ${typeof (props.paddingHorizontal) === 'string' ? props.paddingHorizontal : `${(props.paddingHorizontal * goldenRatio)}px` || '1em'}; - padding-right: ${typeof (props.paddingHorizontal) === 'string' ? props.paddingHorizontal : `${(props.paddingHorizontal * goldenRatio)}px` || '1em'}; + ${props.paddingHorizontal && + ` + padding-left: ${typeof props.paddingHorizontal === `string` + ? props.paddingHorizontal + : `${props.paddingHorizontal * goldenRatio}px` || `1em`}; + padding-right: ${typeof props.paddingHorizontal === `string` + ? props.paddingHorizontal + : `${props.paddingHorizontal * goldenRatio}px` || `1em`}; `}; -`; +` export const borderProps = props => css` - ${props.borderBottom && `border-bottom: ${props.borderWidth || '1px'} solid ${color.white}`}; - ${props.borderTop && `border-top: ${props.borderWidth || '1px'} solid ${color.white}`}; - ${props.borderLeft && `border-left: ${props.borderWidth || '1px'} solid ${color.white}`}; - ${props.borderRight && `border-right: ${props.borderWidth || '1px'} solid ${color.white}`}; -`; + ${props.borderBottom && + `border-bottom: ${props.borderWidth || `1px`} solid ${color.white}`}; + ${props.borderTop && + `border-top: ${props.borderWidth || `1px`} solid ${color.white}`}; + ${props.borderLeft && + `border-left: ${props.borderWidth || `1px`} solid ${color.white}`}; + ${props.borderRight && + `border-right: ${props.borderWidth || `1px`} solid ${color.white}`}; +` export const backgroundProps = props => css` - ${props.bgWhite && typeof(props.bgWhite) === 'boolean' && `background-color: ${color.white};`}; - ${props.bgGrey && typeof(props.bgGrey) === 'boolean' && `background-color: ${color.gray};`}; - ${props.bgColor && typeof(props.bgColor) === 'string' && `background-color: ${props.bgColor};`}; -`; + ${props.bgWhite && + typeof props.bgWhite === `boolean` && + `background-color: ${color.white};`}; + ${props.bgGrey && + typeof props.bgGrey === `boolean` && + `background-color: ${color.gray};`}; + ${props.bgColor && + typeof props.bgColor === `string` && + `background-color: ${props.bgColor};`}; +` export const heightProps = props => css` - ${props.height && typeof(props.height) === 'number' && `height: ${goldenRatio * props.height}px;`} -`; + ${props.height && + typeof props.height === `number` && + `height: ${goldenRatio * props.height}px;`} +` export const outlineProps = props => css` - ${props.outline && typeof(props.outline) === 'boolean' && 'outline: 1px solid white' } -`; \ No newline at end of file + ${props.outline && + typeof props.outline === `boolean` && + `outline: 1px solid white`} +` diff --git a/examples/using-wordpress/src/components/styled/theme.js b/examples/using-wordpress/src/components/styled/theme.js index ac80a2e9cd5a4..9569fd88ab4f0 100644 --- a/examples/using-wordpress/src/components/styled/theme.js +++ b/examples/using-wordpress/src/components/styled/theme.js @@ -3,31 +3,31 @@ export const theme = { lg: 992, md: 768, sm: 450, - max: '1200px', + max: `1200px`, }, goldenRatio: 7, color: { - gray: '#bfbfbf', - lightGray: '#efefef', - red: '#ac3842', - link: '#008caa', - white: '#fff', - han: '#464646', + gray: `#bfbfbf`, + lightGray: `#efefef`, + red: `#ac3842`, + link: `#008caa`, + white: `#fff`, + han: `#464646`, }, ftz: { - h1: '77px', - h2: '63px', - h3: '42px', - h4: '28px', - h5: '21px', - h6: '18px', - h7: '14px', - p1: '28px', - p2: '21px', - p3: '18px', - p4: '16px', - p5: '12px', + h1: `77px`, + h2: `63px`, + h3: `42px`, + h4: `28px`, + h5: `21px`, + h6: `18px`, + h7: `14px`, + p1: `28px`, + p2: `21px`, + p3: `18px`, + p4: `16px`, + p5: `12px`, }, -}; +} -export default theme; \ No newline at end of file +export default theme diff --git a/examples/using-wordpress/src/html.js b/examples/using-wordpress/src/html.js index d179c6bebd4c0..2d8b4d85526d5 100644 --- a/examples/using-wordpress/src/html.js +++ b/examples/using-wordpress/src/html.js @@ -1,6 +1,5 @@ -import React, { Component } from 'react' -import * as PropTypes from 'prop-types' -import Helmet from 'react-helmet' +import React, { Component } from "react" +import * as PropTypes from "prop-types" let stylesStr if (process.env.NODE_ENV === `production`) { @@ -13,11 +12,13 @@ if (process.env.NODE_ENV === `production`) { class Html extends Component { render() { - const head = Helmet.rewind() // TODO let css if (process.env.NODE_ENV === `production`) { css = ( -