question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stack generates a lot of extra Markup

See original GitHub issue

I watched the conference talk of Mark last night and found it very interesting. One flag to me was that Stack wraps a Div for every child. Seems like an overload of unnecessary markup. The approach in our Design system was to apply a default stack (1 rem down) to our Atomic components. With a BEM modifier of $–no-stack as an optional prop noStack

If we need spacing to be grouped, we use a Block and allow that to have a variety of stack down sizes.

https://github.com/seek-oss/braid-design-system/blob/master/lib/components/Stack/Stack.tsx

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
markdalgleishcommented, Nov 7, 2019

Thanks for raising this question. It’s definitely a valid concern.

An alternative approach would be to use a selector like > *:not(:first-child) to add top padding to all child nodes via CSS, but there are a couple of tradeoffs here:

  • This will create additional CSS, rather than re-using existing padding classes from Box. We’d have to create a separate atomic class for every item in our space scale, for each of our viewport sizes.
  • Arguably creates a leaky abstraction if a child component returns a fragment because the spacing will impact the child nodes of another component.

However, I can definitely see an argument that this tradeoff is worth it:

  • If Stack is used a lot in a single page, the extra CSS will be smaller than the additional HTML.
  • You could alternatively argue that not spacing out fragmented content is actually a bug. Currently, if a component returns a fragment and you want to maintain the correct spacing, you have to return a Stack instead. We’ve run into this a bit, and in practice it kinda feels like a poor separation of concerns.

On reflection, I can see us changing approaches here, but we’ll discuss this a bit further internally.

2reactions
LasseRafncommented, Feb 22, 2020

Still toying around, mostly have just made the layout components (not buttons etc.)

Will be making it available soon, can shoot you a link by then?

Tried to make api, dom structure and styling more or less identical

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoid extra markup in Sharepoint Web Parts
I dont want extra divs to be generated. I just want the markup starting from "fii-twitter-feeds". How can I achieve that? sharepoint-server ...
Read more >
How to deal with extra markup used for angular directives?
My css expects th <app-grouped-button> elements to be direct descendants of <app-button-group> , so they can be laid out as flexbox items. But...
Read more >
Lecture 2, The basics of the web stack
In this course we will use HTML to create our data visualizations. HTML stands for “HyperText Markup Language”. 25 years ago, that used...
Read more >
What is the JAM Stack: JavaScript, APIs and Markup - WebriQ
JAM stack focuses on the front end build, eschewing server-side functions as much as possible. Jamstack defines a group of technologies and a ......
Read more >
What is Jamstack? JavaScript, APIs, and Markup (JAM)
Jamstack is a term that describes a modern web development architecture based ... the number of requests sent to a server and thus...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found