Contribution Proposal: Box Component
See original GitHub issueHey F36 Community 👋
I’m proposing a new component that will reduce the overhead of writing CSS for spacing purposes. I many times see the same code being written to add margins and paddings, and I think we’d benefit from a Box component that will add a spaced box around its children. This component would simply expose padding and margin CSS properties to be set with our tokens.
Box PropTypes
Property | Values | Default |
---|---|---|
element | any html element | div |
padding | F36 spacing token | undefined |
paddingTop | F36 spacing token | undefined |
paddingRight | F36 spacing token | undefined |
paddingBottom | F36 spacing token | undefined |
paddingLeft | F36 spacing token | undefined |
margin | F36 spacing token | undefined |
marginTop | F36 spacing token | undefined |
marginRight | F36 spacing token | undefined |
marginBottom | F36 spacing token | undefined |
marginLeft | F36 spacing token | undefined |
marginHorizontal | F36 spacing token | undefined |
marginVertical | F36 spacing token | undefined |
paddingHorizontal | F36 spacing token | undefined |
paddingVertical | F36 spacing token | undefined |
<Box paddingTop="xs" margin="l" element="span">
{children}
</Box>
Let me know what you think 😊
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (12 by maintainers)
Top Results From Across the Web
Basic components of a proposal | Foundation Relations
Basic components of a proposal · 1. Abstract/Summary · 2. Statement of Need · 3. Project Activity, Methodology and Outcomes · 4. Evaluation...
Read more >6 Creative and Unique Ways to Propose to Your Bridesmaids
Thinking of creative ways to ask your bridesmaids to be in your wedding party? Here are 6 fun, creative and unique ways to...
Read more >How To Write An Effective Grant Proposal | A Nonprofit's Guide
1. First, create a diversified fundraising plan – where grants are only one of the funding sources.
Take time to analyze if applying for...
Read more >How to Write a Project Proposal (Steps & Template Included)
It sells value to both internal and external project stakeholders. The intent of the proposal is to grab stakeholder and project sponsor ...
Read more >The 23 Best Bridesmaid Proposal Gifts of 2022 | by Brides
To help, we researched the best bridesmaid proposal gifts. ... finding the perfect gift to go along with your proposal is part of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Actually, I think all values should be undefined by default, not
m
I have a few thoughts on the issue. Bear with me! 😄
I’m curious, what is this specifically trying to solve – is this trying to solve spacing (margins, padding) to wrappers like a
div
and essentially replace those wrapper with our own component? Or are we trying to avoid people adding wrappers simply for spacing purposes?If we are trying to avoid the latter, I believe the real solution to this problem is to have default spacing on all components, such that you only have to add spacing between components if there is something that needs to be different than the default. This problem only really presents itself because there isn’t spacing by default on anything; for example, if you take a component such as
Card
, you probably would only need to add spacing classes but likely little else as provides internal styles already.Barring default spacing being an option, I think that if we are trying to avoid/help people who add spacing to our components, then I don’t believe that the Box component is the best approach. I think that a better solution would be to add an attribute to every, or almost every, component that allows you to customize spacing. I think performance is a potential problem, but I’d worry more about the cognitive overhead of having even more components.
However, if we are trying to avoid the former, for users to avoid using layout wrapper divs, then I think a Box component may have a large benefit, even taking into account the potential cognitive overhead and performance issues.
One red flag that keeps coming to my mind with adding the Box component is now you are going to be explicitly blessing and mixing template with logic (JSX) with layout and styles. I would guess people don’t often mix those (and those that do, most likely use CSS-in-JS, which this isn’t exactly compatible with as far as I can tell) and somehow use styles in a different way (import a
.css
file,emotion
, etc.) and so mixing spacing into the template while the other styles live somewhere else may bring complications to those using Forma. This adds to the cognitive overhead issue I mentioned earlier, but now not only is it due to our components (which can most likely be solved with familiarity and documentation) but also due to styling living in both templates and in the stylesheets.Overall I’m not entirely convinced a
Box
component is a good solution, default spacing argument aside, because it will make things more complicated for those that use our library.