Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 56 additions & 84 deletions src/components/button/readme.md
Original file line number Diff line number Diff line change
@@ -1,103 +1,75 @@
Fill button:

```jsx
<ul className="list-reset flex justify-around flex-wrap">
<li>
<FillButton brand="primary">Primary</FillButton>
</li>
<li>
<FillButton brand="secondary">Secondary</FillButton>
</li>
<li>
<FillButton brand="danger">Danger</FillButton>
</li>
<li>
<FillButton brand="warning">Warning</FillButton>
</li>
<li>
<FillButton brand="info">Info</FillButton>
</li>
<li>
<FillButton bg="purple" text="white">
Custom
</FillButton>
</li>
</ul>
<List inline padding>
<FillButton brand="primary">Primary</FillButton>

<FillButton brand="secondary">Secondary</FillButton>

<FillButton brand="danger">Danger</FillButton>

<FillButton brand="warning">Warning</FillButton>

<FillButton brand="info">Info</FillButton>

<FillButton bg="purple" text="white">
Custom
</FillButton>
</List>
```

Outline button:

```jsx
<ul className="list-reset flex justify-around flex-wrap">
<li>
<OutlineButton brand="primary">Primary</OutlineButton>
</li>
<li>
<OutlineButton brand="secondary">Secondary</OutlineButton>
</li>
<li>
<OutlineButton brand="danger">Danger</OutlineButton>
</li>
<li>
<OutlineButton brand="warning">Warning</OutlineButton>
</li>
<li>
<OutlineButton brand="info">Info</OutlineButton>
</li>
<li>
<OutlineButton border="purple" text="white">
Custom
</OutlineButton>
</li>
</ul>
<List inline padding>
<OutlineButton brand="primary">Primary</OutlineButton>

<OutlineButton brand="secondary">Secondary</OutlineButton>

<OutlineButton brand="danger">Danger</OutlineButton>

<OutlineButton brand="warning">Warning</OutlineButton>

<OutlineButton brand="info">Info</OutlineButton>

<OutlineButton border="purple" text="white">
Custom
</OutlineButton>
</List>
```

Text button:

```jsx
<ul className="list-reset flex justify-around flex-wrap">
<li>
<TextButton brand="primary">Primary</TextButton>
</li>
<li>
<TextButton brand="secondary">Secondary</TextButton>
</li>
<li>
<TextButton brand="danger">Danger</TextButton>
</li>
<li>
<TextButton brand="warning">Warning</TextButton>
</li>
<li>
<TextButton brand="info">Info</TextButton>
</li>
<li>
<TextButton text="purple">Custom</TextButton>
</li>
</ul>
<List inline padding>
<TextButton brand="primary">Primary</TextButton>

<TextButton brand="secondary">Secondary</TextButton>

<TextButton brand="danger">Danger</TextButton>

<TextButton brand="warning">Warning</TextButton>

<TextButton brand="info">Info</TextButton>

<TextButton text="purple">Custom</TextButton>
</List>
```

Link button:

```jsx
<ul className="list-reset flex justify-around flex-wrap">
<li>
<LinkButton brand="primary">Primary</LinkButton>
</li>
<li>
<LinkButton brand="secondary">Secondary</LinkButton>
</li>
<li>
<LinkButton brand="danger">Danger</LinkButton>
</li>
<li>
<LinkButton brand="warning">Warning</LinkButton>
</li>
<li>
<LinkButton brand="info">Info</LinkButton>
</li>
<li>
<LinkButton text="purple">Custom</LinkButton>
</li>
</ul>
<List inline padding>
<LinkButton brand="primary">Primary</LinkButton>

<LinkButton brand="secondary">Secondary</LinkButton>

<LinkButton brand="danger">Danger</LinkButton>

<LinkButton brand="warning">Warning</LinkButton>

<LinkButton brand="info">Info</LinkButton>

<LinkButton text="purple">Custom</LinkButton>
</List>
```
72 changes: 72 additions & 0 deletions src/components/list/List.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'

import { BaseComponent } from '../tailwind'
import { withTheme } from '../theme'

const List = ({
theme,
is,
children,
className,
padding,
reset,
inline,
justified,
fullWidth,
ordered,
...rest
}) => (
<BaseComponent
is={ordered ? 'ol' : is}
m={{ b: theme.spacing.md }}
flex={justified || fullWidth || (inline ? [true, 'wrap'] : undefined)}
justify={justified ? 'between' : undefined}
className={classnames(
(reset || inline || justified || fullWidth) && 'list-reset',
className,
)}
{...rest}
>
{React.Children.map(children, child => (
<li
className={classnames(
padding && !justified && !fullWidth && `mb-${theme.spacing.sm}`,
inline && `mr-${theme.spacing.sm}`,
fullWidth && 'flex-1',
)}
>
{child}
</li>
))}
</BaseComponent>
)

List.propTypes = {
theme: PropTypes.shape({}).isRequired,
is: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]),
children: PropTypes.node,
className: PropTypes.string,
padding: PropTypes.bool,
reset: PropTypes.bool,
inline: PropTypes.bool,
justified: PropTypes.bool,
fullWidth: PropTypes.bool,
ordered: PropTypes.bool,
}

List.defaultProps = {
is: 'ul',
children: undefined,
className: undefined,
padding: false,
reset: false,
inline: false,
justified: false,
fullWidth: false,
ordered: false,
}

export { List as component }
export default withTheme(List)
30 changes: 30 additions & 0 deletions src/components/list/__tests__/List.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'
import { shallow } from 'enzyme'

import { component as List } from '../List'
import { defaultTheme } from '../../theme'

const setup = (testProps = {}) => {
const props = Object.assign({ theme: defaultTheme }, testProps)

const wrapper = shallow(
<List inline {...props}>
<span>One</span>
<span>Two</span>
<span>Three</span>
</List>,
)

return {
props,
wrapper,
}
}

describe('List', () => {
it('renders matching snapshot', () => {
const { wrapper } = setup()

expect(wrapper).toMatchSnapshot()
})
})
44 changes: 44 additions & 0 deletions src/components/list/__tests__/__snapshots__/List.jsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`List renders matching snapshot 1`] = `
<BaseComponent
className="list-reset"
flex={
Array [
true,
"wrap",
]
}
is="ul"
m={
Object {
"b": 4,
}
}
>
<li
className="mr-2"
key=".0"
>
<span>
One
</span>
</li>
<li
className="mr-2"
key=".1"
>
<span>
Two
</span>
</li>
<li
className="mr-2"
key=".2"
>
<span>
Three
</span>
</li>
</BaseComponent>
`;
1 change: 1 addition & 0 deletions src/components/list/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as List } from './List'
45 changes: 45 additions & 0 deletions src/components/list/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Simple list:

```jsx
<List padding ordered>
<Text>One</Text>
<Text>Two</Text>
<Text>Three</Text>
</List>
```

Inline list:

```jsx
<List padding inline>
<Text>One</Text>
<Text>Two</Text>
<Text>Three</Text>
</List>
```

Justified list:

```jsx
<List justified>
<Text>One</Text>
<Text>Two</Text>
<Text>Three</Text>
</List>
```

Full width list:

```jsx
<List fullWidth>
<Text text="center" p={2} bg="grey-lighter" block>
One
</Text>
<Text text="center" p={2} bg="grey-light" block>
Two
</Text>
<Text text="center" p={2} bg="grey-lighter" block>
Three
</Text>
</List>
```
1 change: 1 addition & 0 deletions src/components/tailwind/tailwindProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const propTypes = {
absolute: PropTypes.bool,
align: PropTypes.string,
appearance: PropTypes.oneOf(['none']),
block: PropTypes.bool,
bg: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
border: PropTypes.oneOfType([
PropTypes.string,
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './components/footer'
export * from './components/form'
export * from './components/grid'
export * from './components/header'
export * from './components/list'
export * from './components/main'
export * from './components/typography'
export * from './components/visuallyHidden'
Expand Down