diff --git a/pages/_app.js b/pages/_app.js index 383147be8be..f6c58c97322 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -6,7 +6,7 @@ import * as primerComponents from '..' import * as docComponents from './doc-components' import Index from './index.mdx' -const {BaseStyles, Box, FlexContainer, Link} = primerComponents +const {BaseStyles, Box, Flex, Link} = primerComponents const {SideNav, Header, IndexHero, customTheme} = docComponents const iconComponents = Object.keys(iconsByName).reduce((map, key) => { @@ -46,7 +46,7 @@ export default class MyApp extends App {
- + {isIndex && } @@ -54,7 +54,7 @@ export default class MyApp extends App { - + diff --git a/pages/components/docs/Flex.md b/pages/components/docs/Flex.md index e60dc0c207e..94096fd07be 100644 --- a/pages/components/docs/Flex.md +++ b/pages/components/docs/Flex.md @@ -1,41 +1,41 @@ -# FlexContainer and FlexItem +# Flex and Flex.Item -FlexContainer and FlexItem are wrapping components that will give the content flexbox properties. +Flex and Flex.Item are wrapping components that will give the content flexbox properties. Flex.Item is included in the export for Flex. ## Default example ```.jsx - - + + Item 1 - - + + Item 2 - - + + Item 3 - - + + ``` ## System props -FlexContainer components get `FLEX_CONTAINER`, `COMMON`, and `LAYOUT` system props. +Flex components get `FLEX_CONTAINER`, `COMMON`, and `LAYOUT` system props. -FlexItem components get `FLEX_ITEM`, `COMMON`, and `LAYOUT` system props. +Flex.Item components get `FLEX_ITEM`, `COMMON`, and `LAYOUT` system props. Read our [System Props](/components/docs/system-props) doc page for a full list of available props. ## Component props -FlexContainer and FlexItem do not get any additional props other than the system props mentioned above. +Flex and Flex.Item do not get any additional props other than the system props mentioned above. export const meta = {displayName: 'Flex'} diff --git a/pages/doc-components/Header.js b/pages/doc-components/Header.js index 7b24ff7cfcb..c3676412341 100644 --- a/pages/doc-components/Header.js +++ b/pages/doc-components/Header.js @@ -3,18 +3,18 @@ import {withRouter} from 'next/router' import Octicon, {MarkGithub} from '@githubprimer/octicons-react' import NextLink from 'next/link' import BoxShadow from './BoxShadow' -import {Text, FlexContainer, Link, Sticky, Box} from '../..' +import {Text, Flex, Link, Sticky, Box} from '../..' const Header = ({router}) => ( - + - + Primer Components - + @@ -57,7 +57,7 @@ const Header = ({router}) => ( - + ) diff --git a/pages/doc-components/SideNav.js b/pages/doc-components/SideNav.js index a9def5f1c79..d639d99817a 100644 --- a/pages/doc-components/SideNav.js +++ b/pages/doc-components/SideNav.js @@ -1,7 +1,7 @@ import React from 'react' import {withRouter} from 'next/router' import {default as NextLink} from 'next/link' -import {Text, Box, Link, FlexContainer, Relative} from '../..' +import {Text, Box, Link, Flex, Relative} from '../..' import * as docs from '../components/docs' const getLink = router => { @@ -37,7 +37,7 @@ const SideNav = ({router}) => ( borderColor="gray.2" id="sidenav" > - + ( Primer Theme - + diff --git a/src/CircleOcticon.js b/src/CircleOcticon.js index 46741000e53..fef285c6514 100644 --- a/src/CircleOcticon.js +++ b/src/CircleOcticon.js @@ -1,26 +1,26 @@ import React from 'react' import PropTypes from 'prop-types' import Octicon from '@githubprimer/octicons-react' -import FlexContainer from './FlexContainer' +import Flex from './Flex' function CircleOcticon(props) { const {size} = props const {icon, ...rest} = props return ( - + - + ) } CircleOcticon.defaultProps = { - ...FlexContainer.defaultProps, + ...Flex.defaultProps, size: 32, borderRadius: '50%' } CircleOcticon.propTypes = { - ...FlexContainer.propTypes, + ...Flex.propTypes, icon: Octicon.propTypes.icon, size: PropTypes.number } diff --git a/src/Dropdown.js b/src/Dropdown.js index edd43c2bb0d..92f1a6f4989 100644 --- a/src/Dropdown.js +++ b/src/Dropdown.js @@ -7,14 +7,14 @@ import Button from './Button' import Box from './Box' import Caret from './Caret' import Details from './Details' -import FlexContainer from './FlexContainer' +import Flex from './Flex' import {withSystemProps, COMMON} from './system-props' function Dropdown({title, scheme, children, className, ...rest}) { const {minWidth} = rest return (
- + {({toggle}) => (
) } diff --git a/src/Flex.js b/src/Flex.js new file mode 100644 index 00000000000..a3b41def41f --- /dev/null +++ b/src/Flex.js @@ -0,0 +1,13 @@ +import {withSystemProps, FLEX_CONTAINER, FLEX_ITEM} from './system-props' + +const Flex = withSystemProps( + { + is: 'div', + display: 'flex' + }, + FLEX_CONTAINER +) + +Flex.Item = withSystemProps('div', FLEX_ITEM) + +export default Flex diff --git a/src/FlexContainer.js b/src/FlexContainer.js deleted file mode 100644 index 74d556767f2..00000000000 --- a/src/FlexContainer.js +++ /dev/null @@ -1,11 +0,0 @@ -import {withSystemProps, FLEX_CONTAINER} from './system-props' - -const FlexContainer = withSystemProps( - { - is: 'div', - display: 'flex' - }, - FLEX_CONTAINER -) - -export default FlexContainer diff --git a/src/FlexItem.js b/src/FlexItem.js deleted file mode 100644 index 168fa8519dd..00000000000 --- a/src/FlexItem.js +++ /dev/null @@ -1,5 +0,0 @@ -import {withSystemProps, FLEX_ITEM} from './system-props' - -const FlexItem = withSystemProps('div', FLEX_ITEM) - -export default FlexItem diff --git a/src/__tests__/FlexContainer.js b/src/__tests__/FlexContainer.js index 37366c167e8..32e42b436f1 100644 --- a/src/__tests__/FlexContainer.js +++ b/src/__tests__/FlexContainer.js @@ -1,54 +1,54 @@ import React from 'react' -import FlexContainer from '../FlexContainer' +import Flex from '../Flex' import {FLEX_CONTAINER} from '../system-props' import {render} from '../utils/testing' -describe('FlexContainer', () => { +describe('Flex', () => { it('is a system component', () => { - expect(FlexContainer.systemComponent).toEqual(true) + expect(Flex.systemComponent).toEqual(true) }) it('implements flex system props', () => { - expect(FlexContainer).toImplementSystemProps(FLEX_CONTAINER) + expect(Flex).toImplementSystemProps(FLEX_CONTAINER) }) it('gets display: flex by default', () => { - expect(render()).toHaveStyleRule('display', 'flex') + expect(render()).toHaveStyleRule('display', 'flex') }) it('respects flexWrap', () => { - expect(render()).toMatchSnapshot() + expect(render()).toMatchSnapshot() }) it('respects flexDirection', () => { - expect(render()).toMatchSnapshot() + expect(render()).toMatchSnapshot() }) it('respects justifyContent', () => { - expect(render()).toMatchSnapshot() + expect(render()).toMatchSnapshot() }) it('respects alignItems', () => { - expect(render()).toMatchSnapshot() + expect(render()).toMatchSnapshot() }) it('respects alignContent', () => { - expect(render()).toMatchSnapshot() + expect(render()).toMatchSnapshot() }) it('respects display', () => { - expect(render()).toHaveStyleRule('display', 'inline-flex') + expect(render()).toHaveStyleRule('display', 'inline-flex') }) it('respects responsive display', () => { - expect(render()).toMatchSnapshot() + expect(render()).toMatchSnapshot() }) it('respects the "is" prop', () => { - expect(render().type).toEqual('span') + expect(render().type).toEqual('span') }) it('renders a div by default', () => { - expect(render().type).toEqual('div') + expect(render().type).toEqual('div') }) }) diff --git a/src/__tests__/FlexItem.js b/src/__tests__/FlexItem.js index 43982c8acfe..632ede22346 100644 --- a/src/__tests__/FlexItem.js +++ b/src/__tests__/FlexItem.js @@ -1,26 +1,26 @@ import React from 'react' -import FlexItem from '../FlexItem' +import Flex from '../Flex' import {FLEX_ITEM} from '../system-props' import {render} from '../utils/testing' -describe('FlexItem', () => { +describe('Flex.Item', () => { it('is a system component', () => { - expect(FlexItem.systemComponent).toEqual(true) + expect(Flex.Item.systemComponent).toEqual(true) }) it('implements FLEX_ITEM props', () => { - expect(FlexItem).toImplementSystemProps(FLEX_ITEM) + expect(Flex.Item).toImplementSystemProps(FLEX_ITEM) }) it('respects alignSelf', () => { - expect(render()).toMatchSnapshot() + expect(render()).toMatchSnapshot() }) it('renders as correct tag', () => { const item = render( - + hi - + ) expect(item.type).toEqual('button') expect(item).toMatchSnapshot() diff --git a/src/__tests__/__snapshots__/FlexContainer.js.snap b/src/__tests__/__snapshots__/FlexContainer.js.snap index 30942a18ea4..698aa7b5148 100644 --- a/src/__tests__/__snapshots__/FlexContainer.js.snap +++ b/src/__tests__/__snapshots__/FlexContainer.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`FlexContainer respects alignContent 1`] = ` +exports[`Flex respects alignContent 1`] = ` .emotion-0 { display: -webkit-box; display: -webkit-flex; @@ -16,7 +16,7 @@ exports[`FlexContainer respects alignContent 1`] = ` /> `; -exports[`FlexContainer respects alignItems 1`] = ` +exports[`Flex respects alignItems 1`] = ` .emotion-0 { display: -webkit-box; display: -webkit-flex; @@ -33,7 +33,7 @@ exports[`FlexContainer respects alignItems 1`] = ` /> `; -exports[`FlexContainer respects flexDirection 1`] = ` +exports[`Flex respects flexDirection 1`] = ` .emotion-0 { display: -webkit-box; display: -webkit-flex; @@ -49,7 +49,7 @@ exports[`FlexContainer respects flexDirection 1`] = ` /> `; -exports[`FlexContainer respects flexWrap 1`] = ` +exports[`Flex respects flexWrap 1`] = ` .emotion-0 { display: -webkit-box; display: -webkit-flex; @@ -65,7 +65,7 @@ exports[`FlexContainer respects flexWrap 1`] = ` /> `; -exports[`FlexContainer respects justifyContent 1`] = ` +exports[`Flex respects justifyContent 1`] = ` .emotion-0 { display: -webkit-box; display: -webkit-flex; @@ -82,7 +82,7 @@ exports[`FlexContainer respects justifyContent 1`] = ` /> `; -exports[`FlexContainer respects responsive display 1`] = ` +exports[`Flex respects responsive display 1`] = ` .emotion-0 { display: -webkit-box; display: -webkit-flex; diff --git a/src/__tests__/__snapshots__/FlexItem.js.snap b/src/__tests__/__snapshots__/FlexItem.js.snap index 4f59c2038e8..cf292068b40 100644 --- a/src/__tests__/__snapshots__/FlexItem.js.snap +++ b/src/__tests__/__snapshots__/FlexItem.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`FlexItem renders as correct tag 1`] = ` +exports[`Flex.Item renders as correct tag 1`] = ` .emotion-0 { -webkit-align-self: center; -ms-flex-item-align: center; @@ -14,7 +14,7 @@ exports[`FlexItem renders as correct tag 1`] = ` `; -exports[`FlexItem respects alignSelf 1`] = ` +exports[`Flex.Item respects alignSelf 1`] = ` .emotion-0 { -webkit-align-self: center; -ms-flex-item-align: center; diff --git a/src/index.js b/src/index.js index 1fee1553cf2..7808e7f66db 100644 --- a/src/index.js +++ b/src/index.js @@ -35,8 +35,7 @@ export {default as Dropdown} from './Dropdown' export {default as Donut} from './Donut' export {default as FilterList} from './FilterList' -export {default as FlexContainer} from './FlexContainer' -export {default as FlexItem} from './FlexItem' +export {default as Flex} from './Flex' export {default as TextInput} from './TextInput'