Skip to content
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

Add stack utilities in favour of outer-grid #363

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

robdekort
Copy link
Contributor

@robdekort robdekort commented Nov 30, 2023

The problem
The current outer grid holding page builder blocks is very easy to grasp, but it has a few limitations. Gaps between rows are always the same and you need negative margins to remove gaps.

A solution
Using utilities similar to space-y-* but with a few superpowers.

<main class="stack-16">
  <section></section>
  <section class="no-space-y">No space above section and above next sibling section</section>
  <section></section>
  <section class="stack-space-8">Less space above this section</section>
</main>

Compiles to:

.stack-16 {
    --stack-space: 4rem;
}
.stack-16 > *:not(.no-space-y, .no-space-b) + *:not(.no-space-y, .no-space-t) {
    margin-block-start: var(--stack-space, 4rem);
}
.stack-space-8 {
    --stack-space: 2rem;
}

You can also use no-space-t or no-space-b to alter the spacing. Arbitrary values and modifiers like stack-[5px] md:stack-16 are also supported.

Inspired by the various stack/flow/owl techniques from smart others.

@klickreflex
Copy link
Sponsor Contributor

After taking a couple of minutes to understand it fully, I absolutely love it!

@marcorieser
Copy link
Contributor

@sjclark
Copy link
Contributor

sjclark commented Dec 1, 2023

My inuition is that this is a good idea - but could you reference any of the "Inspired by the various stack/flow/owl techniques from smart others" @robdekort, because I'm a silly dumb person who wants to understand this a bit more 😂

@robdekort robdekort merged commit 465f543 into main Dec 1, 2023
1 check passed
@robdekort robdekort deleted the feature/stack-utilities branch December 1, 2023 08:51
@robdekort
Copy link
Contributor Author

My inuition is that this is a good idea - but could you reference any of the "Inspired by the various stack/flow/owl techniques from smart others" @robdekort, because I'm a silly dumb person who wants to understand this a bit more 😂

I guess the original source is this: https://alistapart.com/article/axiomatic-css-and-lobotomized-owls/ and it was expanded on here: https://every-layout.dev/layouts/stack/.

I based my proposal on the Tailwind space-y utilities. The option to clear the next sibling top spacing I haven't seen before.

@robdekort robdekort mentioned this pull request Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants