Refactoring SCSS Base and (Variable) Abstracts for Simplicity #6
Replies: 1 comment 1 reply
-
|
I have to say this really is a tough call. On one hand, I'd appreciate the verbosity of seeing through |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Recently, I've been working on refactoring my base and abstracts layers, and I’ve realized that the key to a maintainable and straightforward structure lies in avoiding unnecessary abstractions. By focusing on plain element grouping instead of over-complicating things with broad or vague categorizations, I've found a cleaner, more intuitive approach.
Starting Point: Rethinking base ⚾🧢
Initially, the
base/directory contained stylesheets likebase/typographyandbase/animations. Withinbase/typography, I styled headers, paragraphs, and other common text elements, effectively merging reset styles with basic typographic rules. However, as I re-evaluated its purpose, a few things became clear:The Move to Plain Element Grouping
To simplify and clarify, I decided to organize base by grouping styles by element or thematic focus, rather than trying to bundle everything into generic categories. Here’s what my updated base looks like:
<h1>-<h6>styles.<p>styles, including spacing rules.This shift to plain element grouping eliminates unnecessary abstraction (e.g., no more vague
foundation, ortypographystylesheets) and makes the organization self-explanatory. If I’m looking for heading-specific rules, I know exactly where to go.The Problem with Over-Abstraction
Previously, I toyed with naming conventions like foundation or core to house resets and typography. However:
By sticking to clear, element-based groupings, I avoid these pitfalls altogether.
Advantages of This Approach
base/headings.scss, list styles inbase/lists.scss, and so on.Conclusion
Refactoring base into plain, element-grouped stylesheets is a step toward a leaner and more intuitive codebase. By resisting the urge to over-abstract with concepts like
foundation, I’m able to keep things simple and focused. This approach emphasizes clarity and scalability, making it easier to maintain and extend the structure as the project evolves.Beta Was this translation helpful? Give feedback.
All reactions