🎨Modular Approach to CSS
In the design guideline, the designer needs to prepare styles for basic elements such as buttons, form fields, lists, and other functional elements used in your layout. It is also necessary to determine the basic styles for links (general rules in different states (hover, focus, active)), borders, shadows, etc.
Of course, an element can have custom features, but it should be rare. A good design, like everything else in the world, should be aligned to a system. So that most of the website layout can and must be covered by a guideline, which can be easily disassembled into modular CSS files.
Having clear design rules makes it much easier for both the designer and developer to work. Such a guideline helps keep styles organized. For example:
📂 assets/css/src/general-styles/*_buttons*.css
It is also important to remember that partial files should be included in the parent CSS file, by default it is:
📂 assets/css/src/global.css
Modular Approach
The WP Rig Toolkit methodology follows a modular logic, and in CSS, this is reflected in the use of "atomic CSS" (in particular, the Framework and Spacing System follow this logic). This approach allows you to easily manipulate your styles directly from HTML, saving development time and, therefore, budget.
The task of the designer is to prepare a visual guideline, describing all possible forms of a certain element in all of its states. The task of the developer is to create a set of CSS classes based on this.
Let's take a look at buttons from the designer and developer's perspective.
Example: Designer’s side
The designer needs to draw buttons in Figma in all their states and that's it.
Normal Action Button
normal state
hover state
active/focus state
Big Action Button
normal state
hover state
active/focus state
disabled
Example: Developer’s side
The developer examines what the designer has created, "deconstructs" it, and creates modular CSS classes from it.
Common styles for all buttons (.btn)
Sizes of Button
normal (.btn--size-normal)
big (.btn--size-big)
Colors of Button
primary color (.btn--color-primary)
orange color (.btn--color-orange)
etc.
Special States of Button
hover state
active/focus state
disabled state
Icons for Buttons
In case you need to add an icon inside a specific button, you can encode the icon to base64 and add special classes to manipulate it.
select the right colored icon (.btn--arrowed-primary)
adjust the size of the icon (.btn--arrowed-small)
etc.
This list is not exhaustive and you can add to it as per your needs. Remember, it's important to keep your logic flexible, so you don't have to create another class describing all the styles of a specific button in case the designer suddenly adds an icon, changes color, size, etc.