Fix: Reference page subcategory heading margins overridden by global CSS - #1610
MishtiGarg250 wants to merge 2 commits into
Conversation
|
Hi @MishtiGarg250, thank you for working on this PR. I tested the changes locally. The bottom-margin fix works. On main, the Constants h2 has the mb-[var(--gutter-md)] class, but the browser still applies a bottom margin of 0px. On this PR, the class works and the bottom margin becomes 40px. However, @layer components currently wraps the whole section, .section block, not only the bottom-margin rule causing the problem. This changes the priority of the other section styles as well. In DevTools, Tailwind’s base styles override those section styles, causing these changes:
Could you limit the layer change to the heading bottom-margin rule, or adjust the layer order so the other section styles keep their current values? I also checked Shape. It has a visible h3 called “2D Primitives,” so the Shape h2 should receive mb-0 because the h3 already provides spacing. Instead, it receives mb-[var(--gutter-md)], which adds a 40px bottom margin. This happens because the condition checks only category.subcats[0]. The first item has no name, while “2D Primitives” appears later in the list. The condition therefore decides that there is no visible h3 and applies the extra margin. The CSS change does not cause the wrong class to be assigned; it only allows that class to take effect. Could you please review the condition so categories with a visible h3 receive mb-0, as intended in #370? Lastly, this PR deletes package-lock.json, accounting for 24,670 unrelated deleted lines. Please update the branch with main and keep the current package-lock.json before the next review. Thank you. |
|
Hi @Nwakaego-Ego , okay I will update you after applying all those changes |
|
@MishtiGarg250 I found an older Issue/PR that is related to issues with spacing in the headers of the Reference page:
Perhaps you may want to take a look and see if the solutions conflict. PR #632 is from 2024, so we can close that if you feel your solution will fix that as well. |
Description
This PR fixes issue in #1538 , following the issue in #370, where the conditional
mb-[var(--gutter-md)]Tailwind classes applied to subcategory headings weren't actually displaying.The Cause:
Because Tailwind v4 relies heavily on cascade layers, its utility classes are placed in
@layer utilities. However, themargin-bottom: 0px;rule forsection h2instyles/global.scsswas completely unlayered. In standard CSS cascade behavior, unlayered CSS always beats layered CSS regardless of specificity, which causedglobal.scssto override the Tailwind utilities.The Fix:
Wrapped the
sectionand.sectionlayout rules instyles/global.scsswith@layer components { ... }.By moving these rules to the components layer:
baselayer (ensuring our custom font sizes aren't overridden by the Tailwind preflight).utilitieslayer.As a result, the conditional Tailwind utility classes (
mb-[var(--gutter-md)]andmb-0) inReferenceDirectoryWithFilternow properly take effect.Testing
mb-[var(--gutter-md)]gap appears.h3heading to ensuremb-0is appropriately applied.