Skip to content

Commit

Permalink
feat(divider): add wave divider component
Browse files Browse the repository at this point in the history
  • Loading branch information
theetrain committed Sep 25, 2017
1 parent e797a85 commit 895d3c8
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ module.exports = {
path.resolve('src/old-components/ExpandCollapse/Panel.jsx')
]
}
},
{
name: 'Dividers',
components() {
return compact([
toggleByEnv('Dividers', path.resolve('src/components/Dividers/WaveDivider/WaveDivider.jsx'))
])
}
}
]
},
Expand Down
11 changes: 11 additions & 0 deletions src/components/Dividers/WaveDivider/WaveDivider.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

import safeRest from '../../../utils/safeRest'

import styles from './WaveDivider.modules.scss'

const WaveDivider = ({ ...rest }) => (
<hr {...safeRest(rest)} className={styles.wave} />
)

export default WaveDivider
3 changes: 3 additions & 0 deletions src/components/Dividers/WaveDivider/WaveDivider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```
<WaveDivider />
```
12 changes: 12 additions & 0 deletions src/components/Dividers/WaveDivider/WaveDivider.modules.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@import "../../../scss/settings/colours";

$transparent-white: rgba(255, 255, 255, 0);
$transparent-black: rgba(0, 0, 0, 0.13);

.wave {
height: 200px;
background-image: linear-gradient(-1deg, $color-white 40%, $color-gainsboro 100%), linear-gradient(-172deg, $transparent-white 6%, $color-white 48%), linear-gradient(-90deg, $transparent-white 53%, $color-white 100%);
// background-size need to do this later comma-separated as well
box-shadow: inset 0 10px 16px 0 $transparent-black;
opacity: 0.3;
}
35 changes: 35 additions & 0 deletions src/components/Dividers/WaveDivider/__tests__/WaveDivider.spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react'
import { shallow, render } from 'enzyme'
import toJson from 'enzyme-to-json'

import WaveDivider from '../WaveDivider'

describe('WaveDivider', () => {
const doShallow = (props = {}) => shallow(<WaveDivider {...props} />)

it('renders', () => {
const waveDivider = render(<WaveDivider />)

expect(toJson(waveDivider)).toMatchSnapshot()
})

it('renders an <hr>', () => {
const waveDivider = doShallow()

expect(waveDivider).toHaveTagName('hr')
})

it('passes additional attributes to the element', () => {
const waveDivider = doShallow({ id: 'the-id', 'data-some-attr': 'some value' })

expect(waveDivider).toHaveProp('id', 'the-id')
expect(waveDivider).toHaveProp('data-some-attr', 'some value')
})

it('does not allow custom CSS', () => {
const waveDivider = doShallow({ className: 'my-custom-class', style: { color: 'hotpink' } })

expect(waveDivider).not.toHaveProp('className', 'my-custom-class')
expect(waveDivider).not.toHaveProp('style')
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`WaveDivider renders 1`] = `
<hr
class="wave"
/>
`;

0 comments on commit 895d3c8

Please sign in to comment.