-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support placeholders with arbitrary width, height and borderRadius #34
Conversation
Hey :) Sorry for being that late, and thank you for the contrib ! I find the idea interesting and it may help people with something much configurable than the current The main question I have in mind is : should we consider replacing From what I've seen inside the PR you're proposing, the <Placeholder.Box
height={50}
width="100%"
borderRadius={5}
color="teal"
/> vs <Placeholder.Media
color="#0000ff"
size={70}
hasRadius
> What are your thougts on that ? And again, really thank you :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really thank your for this PR 👍 , it's following the project code style and it helps improving this library.
I really appreciate the initiative and the code quality !
src/box/__tests__/box.test.js
Outdated
|
||
it('should own a props style that matches the default style', () => { | ||
const style = { | ||
height: 40, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your thoughts on having a square box instead of a rectangle one by default ? Like setting { width: 50, height: 50}
or { width: 40, height: 40 }
?
What is the most common use case you have in mind ?
src/box/box.style.js
Outdated
@@ -0,0 +1,6 @@ | |||
export default ({ height = 40, width = 50, borderRadius = 0, color = '#efefef' }) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having the same question than the previous one concerning default values :)
API.md
Outdated
- `height: Number | String`: the height of the component (default: `40`) | ||
- `width: Number | String`: the width of the component (default: `50`) | ||
- `borderRadius: Number`: the border radius of the component (default: `0`) | ||
- `color: String`: the background color radius of the component (default: `#efefef`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of :
the background color
radiusof the component
API.md
Outdated
#### Props available | ||
- `height: Number | String`: the height of the component (default: `40`) | ||
- `width: Number | String`: the width of the component (default: `50`) | ||
- `borderRadius: Number`: the border radius of the component (default: `0`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of only using radius
instead of borderRadius
? It's a smaller prop name, and in my thoughts, it's self descriptive ?
Hi @mfrachet // media.style.js
export default ({ size = 40, hasRadius = false, color = '#efefef', width, height, borderRadius }) => ({
height: height || size,
width: width || size,
borderRadius: borderRadius || (hasRadius ? size / 2 : 3),
backgroundColor: color,
}); Which doesn't beak the existing functionality, but potentially makes the API more confusing, because it relies on the combination of props being passed in. What do you think of the above solution? Happy to change it to that if you think it's better |
Hi again @mfrachet - I've updated the PR to update the |
I've just seen your changes and I think you're right concerning the props combination. It makes the API unclear and could create some confusion. Maybe we could just use both I actually really appreciate that |
Third time's the charm! I've changed |
API.md
Outdated
<Placeholder.Box | ||
height={50} | ||
width="100%" | ||
borderRadius={5} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be the last catch :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops!
LGTM 👍 thank you again 😄 |
@mfrachet any idea when this will be released onto npm? |
I'll try to release a semi-major today :-) |
Thank you for the amazingly useful library 😊
I'd like to suggest adding a very generic component that can be given an arbitrary
width
,height
,borderRadius
andcolor
. I think that will be generic enough for 99% of the use cases.The current presets only work for square images and the border radius is not customisable.
This came out of me needing a series of rectangular placeholders with a specific border radius. Even though this can be achieved by building your own Custom Component, I was wondering if perhaps that is basic enough functionality to be included out of the box.