mirror of
https://github.com/zhigang1992/react-content-loader.git
synced 2026-05-19 11:34:49 +08:00
List component (#14)
* Add list style component * Add list component to index * Add tests for ListStyle * update readme with list component
This commit is contained in:
committed by
Danilo Woznica
parent
a7f72dc361
commit
3c820c3e7f
@@ -74,13 +74,17 @@ const MyLoader = () => {
|
||||
#### Code Style
|
||||

|
||||
|
||||
#### List Style
|
||||

|
||||
|
||||
|
||||
#### Custom Style
|
||||

|
||||
|
||||
### Todo
|
||||
- [x] Code component;
|
||||
- [x] Custom elements;
|
||||
- [ ] List component;
|
||||
- [x] List component;
|
||||
- [ ] Test in multiples browser;
|
||||
|
||||
#### Credits
|
||||
|
||||
@@ -6,6 +6,7 @@ import Wrap from './Wrap'
|
||||
import FacebookStyle from './stylized/FacebookStyle'
|
||||
import InstagramStyle from './stylized/InstagramStyle'
|
||||
import CodeStyle from './stylized/CodeStyle'
|
||||
import ListStyle from './stylized/ListStyle'
|
||||
// Custom
|
||||
import Rect from './custom/Rect'
|
||||
import Circle from './custom/Circle'
|
||||
@@ -50,6 +51,10 @@ class ContentLoader extends Component {
|
||||
return <CodeStyle {...this.state} />
|
||||
break
|
||||
|
||||
case 'list':
|
||||
return <ListStyle {...this.state} />
|
||||
break
|
||||
|
||||
default:
|
||||
case 'facebook':
|
||||
return <FacebookStyle {...this.state} />
|
||||
|
||||
17
src/stylized/ListStyle.js
Normal file
17
src/stylized/ListStyle.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import React from 'react'
|
||||
import Wrap from '../Wrap'
|
||||
|
||||
const ListStyle = (props) => {
|
||||
return (
|
||||
<Wrap {...props}>
|
||||
<rect x="0" y="0" rx="3" ry="3" width="250" height="10" />
|
||||
<rect x="20" y="20" rx="3" ry="3" width="220" height="10" />
|
||||
<rect x="20" y="40" rx="3" ry="3" width="170" height="10" />
|
||||
<rect x="0" y="60" rx="3" ry="3" width="250" height="10" />
|
||||
<rect x="20" y="80" rx="3" ry="3" width="200" height="10" />
|
||||
<rect x="20" y="100" rx="3" ry="3" width="80" height="10" />
|
||||
</Wrap>
|
||||
)
|
||||
}
|
||||
|
||||
export default ListStyle
|
||||
37
tests/stylized/ListStyle.js
Normal file
37
tests/stylized/ListStyle.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from 'react'
|
||||
|
||||
import {mount, render} from 'enzyme'
|
||||
import chai, {expect} from 'chai'
|
||||
import chaiEnzyme from 'chai-enzyme'
|
||||
import sinon from 'sinon'
|
||||
|
||||
chai.use(chaiEnzyme())
|
||||
|
||||
import ListStyle from '../../src/stylized/ListStyle'
|
||||
|
||||
describe('<ListStyle />', () => {
|
||||
it('has a `svg`', () => {
|
||||
const wrapper = render(<ListStyle />)
|
||||
expect(wrapper.find('svg')).to.have.length(1)
|
||||
})
|
||||
|
||||
it('has a `rect` with `clip-path`', () => {
|
||||
const wrapper = render(<ListStyle />)
|
||||
expect(wrapper.find('rect[clip-path]')).to.have.length(1)
|
||||
})
|
||||
|
||||
it('has a `linearGradient`', () => {
|
||||
const wrapper = render(<ListStyle />)
|
||||
expect(wrapper.find('linearGradient')).to.have.length(1)
|
||||
})
|
||||
|
||||
it('has three `stop`', () => {
|
||||
const wrapper = render(<ListStyle />)
|
||||
expect(wrapper.find('stop')).to.have.length(3)
|
||||
})
|
||||
|
||||
it('has `stop` inside the `linearGradient`', () => {
|
||||
const wrapper = render(<ListStyle />)
|
||||
expect(wrapper.find('stop').parent().is('lineargradient')).to.equal(true)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user