Skip to content

Commit 3c820c3

Browse files
Lasse Borlydanilowoz
authored andcommitted
List component (#14)
* Add list style component * Add list component to index * Add tests for ListStyle * update readme with list component
1 parent a7f72dc commit 3c820c3

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,17 @@ const MyLoader = () => {
7474
#### Code Style
7575
![Code Style](https://cloud.githubusercontent.com/assets/4838076/22555473/effa54c2-e94a-11e6-9128-9b608bcc69d9.gif)
7676

77+
#### List Style
78+
![List Style](https://user-images.githubusercontent.com/2671660/27986068-7a0040d6-63f9-11e7-8e54-dcb220e42fd7.gif)
79+
80+
7781
#### Custom Style
7882
![Code Style](https://cloud.githubusercontent.com/assets/4838076/22760218/aa619f32-ee3c-11e6-9cd1-c4af9dd1278e.gif)
7983

8084
### Todo
8185
- [x] Code component;
8286
- [x] Custom elements;
83-
- [ ] List component;
87+
- [x] List component;
8488
- [ ] Test in multiples browser;
8589

8690
#### Credits

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Wrap from './Wrap'
66
import FacebookStyle from './stylized/FacebookStyle'
77
import InstagramStyle from './stylized/InstagramStyle'
88
import CodeStyle from './stylized/CodeStyle'
9+
import ListStyle from './stylized/ListStyle'
910
// Custom
1011
import Rect from './custom/Rect'
1112
import Circle from './custom/Circle'
@@ -50,6 +51,10 @@ class ContentLoader extends Component {
5051
return <CodeStyle {...this.state} />
5152
break
5253

54+
case 'list':
55+
return <ListStyle {...this.state} />
56+
break
57+
5358
default:
5459
case 'facebook':
5560
return <FacebookStyle {...this.state} />

src/stylized/ListStyle.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react'
2+
import Wrap from '../Wrap'
3+
4+
const ListStyle = (props) => {
5+
return (
6+
<Wrap {...props}>
7+
<rect x="0" y="0" rx="3" ry="3" width="250" height="10" />
8+
<rect x="20" y="20" rx="3" ry="3" width="220" height="10" />
9+
<rect x="20" y="40" rx="3" ry="3" width="170" height="10" />
10+
<rect x="0" y="60" rx="3" ry="3" width="250" height="10" />
11+
<rect x="20" y="80" rx="3" ry="3" width="200" height="10" />
12+
<rect x="20" y="100" rx="3" ry="3" width="80" height="10" />
13+
</Wrap>
14+
)
15+
}
16+
17+
export default ListStyle

tests/stylized/ListStyle.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react'
2+
3+
import {mount, render} from 'enzyme'
4+
import chai, {expect} from 'chai'
5+
import chaiEnzyme from 'chai-enzyme'
6+
import sinon from 'sinon'
7+
8+
chai.use(chaiEnzyme())
9+
10+
import ListStyle from '../../src/stylized/ListStyle'
11+
12+
describe('<ListStyle />', () => {
13+
it('has a `svg`', () => {
14+
const wrapper = render(<ListStyle />)
15+
expect(wrapper.find('svg')).to.have.length(1)
16+
})
17+
18+
it('has a `rect` with `clip-path`', () => {
19+
const wrapper = render(<ListStyle />)
20+
expect(wrapper.find('rect[clip-path]')).to.have.length(1)
21+
})
22+
23+
it('has a `linearGradient`', () => {
24+
const wrapper = render(<ListStyle />)
25+
expect(wrapper.find('linearGradient')).to.have.length(1)
26+
})
27+
28+
it('has three `stop`', () => {
29+
const wrapper = render(<ListStyle />)
30+
expect(wrapper.find('stop')).to.have.length(3)
31+
})
32+
33+
it('has `stop` inside the `linearGradient`', () => {
34+
const wrapper = render(<ListStyle />)
35+
expect(wrapper.find('stop').parent().is('lineargradient')).to.equal(true)
36+
})
37+
})

0 commit comments

Comments
 (0)