-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support placeholders with arbitrary width, height and borderRadius (#34)
* Add a box placeholder type with customizable width, height and border radius * Add docs * Fix comment * Extend the media component to handle arbitrary width and height * Revert "Extend the media component to handle arbitrary width and height" This reverts commit 6699ab1. * Use radius instead of borderRadius and default to a square * Replace borderRadius -> radius in api example * Fix default height in example
- Loading branch information
1 parent
8ba64fd
commit c31510a
Showing
5 changed files
with
73 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
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 { shallow } from 'enzyme'; | ||
import { View } from 'react-native'; | ||
import Box from './../box'; | ||
|
||
describe('Box#render', () => { | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = shallow(<Box />); | ||
}); | ||
|
||
it('should own a props style that matches the default style', () => { | ||
const style = { | ||
height: 50, | ||
width: 50, | ||
borderRadius: 0, | ||
backgroundColor: '#efefef', | ||
}; | ||
expect(wrapper.find(View).prop('style')).toEqual(style); | ||
}); | ||
|
||
it('should own a props style that matches the props', () => { | ||
wrapper = shallow(<Box height={50} width={20} color="red" radius={5} />); | ||
const style = { | ||
height: 50, | ||
width: 20, | ||
backgroundColor: 'red', | ||
borderRadius: 5, | ||
}; | ||
expect(wrapper.find(View).prop('style')).toEqual(style); | ||
}); | ||
}); |
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,10 @@ | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
import computeStyle from './box.style'; | ||
|
||
/** | ||
* Create a box placeholder | ||
*/ | ||
export default function (props) { | ||
return <View style={computeStyle(props)} />; | ||
} |
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,6 @@ | ||
export default ({ height = 50, width = 50, radius = 0, color = '#efefef' }) => ({ | ||
height, | ||
width, | ||
borderRadius: radius, | ||
backgroundColor: color, | ||
}); |
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