-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
147 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,4 +65,5 @@ typings/ | |
/dist | ||
/lib | ||
/full | ||
.coverage | ||
.coverage | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/components/loader/__test__/__snapshots__/loader.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Box component Should Exist 1`] = `[Function]`; | ||
|
||
exports[`Box component Should concat Bulma class with classes in props 1`] = ` | ||
<div | ||
className="loader other-class test" | ||
style={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`Box component Should have box classname 1`] = ` | ||
<div | ||
className="loader" | ||
style={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`Box component Should have custom inline styles 1`] = ` | ||
<section | ||
className="loader" | ||
style={ | ||
Object { | ||
"width": 200, | ||
"zIndex": 1, | ||
} | ||
} | ||
/> | ||
`; | ||
|
||
exports[`Box component Should render as an html section 1`] = ` | ||
<section | ||
className="loader" | ||
style={Object {}} | ||
/> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import Loader from '..'; | ||
|
||
describe('Box component', () => { | ||
it('Should Exist', () => { | ||
expect(Loader).toMatchSnapshot(); | ||
}); | ||
it('Should have box classname', () => { | ||
const component = renderer.create( | ||
<Loader />, | ||
); | ||
expect(component.toJSON()).toMatchSnapshot(); | ||
}); | ||
it('Should concat Bulma class with classes in props', () => { | ||
const component = renderer.create( | ||
<Loader className="other-class test" />, | ||
); | ||
expect(component.toJSON()).toMatchSnapshot(); | ||
}); | ||
it('Should render as an html section', () => { | ||
const component = renderer.create( | ||
<Loader renderAs="section" />, | ||
); | ||
expect(component.toJSON()).toMatchSnapshot(); | ||
}); | ||
it('Should have custom inline styles', () => { | ||
const component = renderer.create( | ||
<Loader renderAs="section" style={{ width: 200, zIndex: 1 }} />, | ||
); | ||
expect(component.toJSON()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './loader.sass'; | ||
|
||
export { default } from './loader'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classnames from 'classnames'; | ||
|
||
const Loader = ({ | ||
children, | ||
className, | ||
style, | ||
renderAs, | ||
}) => { | ||
const Element = renderAs; | ||
return ( | ||
<Element | ||
style={style} | ||
className={classnames('loader', className)} | ||
> | ||
{children} | ||
</Element> | ||
); | ||
}; | ||
|
||
Loader.propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
style: PropTypes.object, | ||
renderAs: PropTypes.string, | ||
}; | ||
|
||
Loader.defaultProps = { | ||
children: null, | ||
className: '', | ||
style: {}, | ||
renderAs: 'div', | ||
}; | ||
|
||
export default Loader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import '../utils.sass'; | ||
|
||
.loader | ||
+loader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
|
||
import { storiesOf } from '@storybook/react'; | ||
import { withInfo } from '@storybook/addon-info'; | ||
|
||
import './loader.story.sass'; | ||
import Loader from '.'; | ||
|
||
storiesOf('Loader', module) | ||
.addDecorator(story => ( | ||
<div style={{ margin: 10 }}> | ||
{story()} | ||
</div> | ||
)) | ||
.add('Default', withInfo()(() => ( | ||
<Loader /> | ||
))) | ||
.add('with inline style', withInfo()(() => ( | ||
<Loader style={{ width: 300, height: 300, border: '4px solid blue', borderTopColor: 'transparent', borderRightColor: 'transparent' }} /> | ||
))) | ||
.add('with other classes', withInfo()(() => ( | ||
<Loader className="loader-override" /> | ||
))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.loader-override | ||
margin-left: auto | ||
margin-right: auto | ||
height: 4em | ||
width: 4em | ||
border: 4px solid red | ||
border-right-color: transparent | ||
border-top-color: transparent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters