-
-
Notifications
You must be signed in to change notification settings - Fork 33
Add comparison with styled-system #144
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
Comments
Atomic-layout vs styled-systemAtomic-layoutI have recently refactored my website from Rebass Overall, I'm glad I started my CSS grid journey from CSS grid helps me to avoid adding margins all over the place. Just think about it, if you are a frontend developer, how often do you wonder if you should add a bottom margin to this component, or a top margin to the next one. What about the last component in the list, will it have a margin too? Or do you need to do the My absolutely favorite thing about Now, regarding things that I don't quite like about Another thing that could be better about Styled-systemWhen I was integrating
If you are not familiar with
The new
As you can see here, that API is a little different, but not too much. The
And to give you another example, here is a dynamic grid of repos you can see on my website.
SummaryThis concludes my comparison. I think both approaches are very worthy, and the main difference between them is naming conventions that the two libraries adopt. Personally, I'm going to stick with Overall I'm very happy with the CSS grid, and I hope to use it more in the future. my-website |
Hi, @Hermanya. I absolutely love your comparison and I was reading it with so much thrill! The way you highlight similarities and differences is constructive and practical, love it. Thank you! Atomic layout has a way to go, a bunch of API to refine and introduce. I'm glad to see some pain points that I've experienced myself, and to know that we have proposals to solve them. To be frank, I think that the comparison with more mature solution is too early to make, but it's handy to have since it's a common question people ask. I will add my comparison once I gain more experience with I will briefly go through some of your points to keep this thread updated about things that are likely to change in the future releases of Shared responsive behavior
This is crucial. There are two steps to perform to address this:
API, prop names, and conventions
That's true, some prop aliases used in Template-less composition
Try Template-less composition. It's not required to always use render prop with <Composition
templateCols="250px 1fr"
templateRows="100px 200px"
gutter={20}
>
<header />
<content />
<footer />
</Composition> Children of composition still abide by the CSS Grid you create around them. Theoretically, you can also use I've opened an issue for namespace collision (#154), so everybody is welcome to contribute. It would be great to resolve this, as I can feel the pain around that. Overall, I want to make |
Responsive propsBoth
Array of values
<Box padding={[10, 20, 30]} /> However, I find this not very intuitive as a newcomer to that library. It feels like an extra library-specific thing I need to learn to use it. It also raised a few questions the first time I saw it: what is the association between breakpoints and values? How to skip/autoplace certain values? Those can be answered, but I need to reach to a documentation each time I doubt.
<Box padding={10} paddingMd={20} paddingLg={30} /> On the other hand, such declaration is indeed more lengthy. This can be dealt with by using snippets and shortcuts. The bottom line is to have a proper balance between predictability and shortness. Making breakpoints order matter
Since
<Box paddingLg={30} padding={10} paddingMd={20} />
Because of this, you can use various breakpoints side-by-side without appearing awkward in both declaration and semantics: <Box padding={10} paddingRetina={20} paddingScreenReader={30} /> Adding/deprecating breakpointsBased from the previous point, I wonder how much effort it takes to introduce new or deprecate an existing breakpoint in // let's say we had two breakpoints
<Box padding={[10, 20]} />
<AnotherBox={[10, 20]} />
// but now we want to add a third one in between:
<Box pading={[10, 15, 20]} /> // we need to cover it here
<AnotherBox={[10, 15, 20]} /> // and here
// and if we accidentally screw something, a wrong value would be applied
// on the introduced breakpoint. That's rarely what we want.
// let's say we have two breakpoints
<Box padding={10} paddingLg={20} />
<AnotherBox padding={10} paddingLg={20} />
// and now we want to have a new one in between
<Box padding={10} paddingMd={15} paddingLg={20} />
<AnotherBox padding={10} paddingMd={15} paddingLg={20} />
// adding a value for a new breakpoint is *explicit*
// we don't have to touch existing implementation, meaning less breaking factor.
// and we need to add new values for a new breakpoint explicitly,
// meaning nothing would happen with the existing implementation unless
// we explicitly tell to. |
@kettanaito the styled system doc mentions object api for responsive props. That being said, last time I tried to use them, I could not get them to work. But from design perspective, I kinds like this approach. |
@Hermanya, yes, I've mentioned that at the beginning of my post (in the quote). With object as a value styled-system is still prop-based, while atomic-layout is pair-based. Apart from that the difference would be the depth of objects nesting: // styled-system
<Box padding={{ large: 10 }} /> // 2 levels: props, then value of "padding"
// atomic-layout
<Box paddingLg={10} /> // 1 level: Box's props I have explicitly compared an array usage, since it looks like the most popular way people use responsive props in styled-system. Also the most common question I get is to explain why I don't copy such API. |
Thanks, I missed that. |
@kettanaito i had a look on styled-system library, the idea differ, atomic-layout simply consider spacing as a component itself which is |
@ruhaise, true. The intention is different, but certain aspects of two libraries cross over. For example, both solutions suggest an API to handle responsive props. That may raise a decision for you which one to use in the end, and may potentially lead to unpleasant situations when you try to utilize two APIs at once (which you shouldn't do). I've tried to cover the difference and reasoning behind Responsive props API in this thread for more technical insights. It would be awesome to make Styled System and Atomic Layout compatible on-demand (i.e. via explicit options). |
Posted the outlines of this discussion to the docs: Comparison with styled-system. Huge thanks to all for participating. Please feel free to comment on this issue with your own experience and vision of difference. Edit: I plan to simplify the comparison page by showcasing the same UI built with two different solutions in the future. If you have a desire to contribute, comment here. Thanks. |
What:
Need to add a comparison between Atomic layout and
styled-system
.Why:
Two solutions seem similar at first glance, and it's fair to let developers know the difference between them, to pick the right one for their needs.
How:
The text was updated successfully, but these errors were encountered: