Commit 4d51ba

2026-01-16 09:39:17 Melisha Dsouza: CSS
CMMI/Guidelines/Coding Standard/Front-End Styling (CSS).md ..
@@ 7,13 7,13 @@
| Target | All Frontend Teams |
| Scope | CSS, SCSS, LESS |
- ### **Core Principles**
+ ### **1. Core Principles**
* **Maintainability over Brevity**: Code is read far more often than it is written. Explicit class names and structures are preferred over clever hacks.
* **Component-Based**: Styles should be scoped to components, avoiding global pollution.
* **Mobile-First**: Design for the smallest screen first, then use min-width media queries to enhance the layout for larger screens.
* **Predictability**: A developer should be able to look at a class name and know exactly what it does and where it belongs.
- ### **Formatting & Syntax**
+ ### **2. Formatting & Syntax**
Consistency in formatting makes the codebase easier to scan and debug.
* **Indentation**: Use 2 spaces (soft tabs).
* **Brackets**:
@@ 46,7 46,7 @@
}
```
- ### **Naming Conventions (BEM)**
+ ### **3. Naming Conventions (BEM)**
We strictly follow the BEM (Block Element Modifier) methodology to keep specificity low and semantic meaning high.
* **Block**: The standalone component (e.g., .btn, .modal).
* **Element**: A child part of the block, denoted by two underscores (e.g., .btn__icon, .modal__header).
@@ 57,8 57,8 @@
* **No Type Selectors**: Avoid unqualified type selectors (e.g., div, span, h1) in component styles to prevent style leakage.
* **JavaScript Hooks**: Do not use BEM classes for JS bindings. Use a dedicated js- prefixed class (e.g., .js-toggle-modal) which should have no styles attached.
- ### **Pre-processor Specifics (SCSS & LESS)**
- #### **1. Variables**
+ ### **4. Pre-processor Specifics (SCSS & LESS)**
+ #### **4.1. Variables**
* **Naming**: Use kebab-case (e.g., $brand-primary, @font-size-base).
* **Usage**:
* Define all colors, fonts, z-indexes, and spacing measurements in a centralized variables file.
@@ 76,7 76,7 @@
margin: 15px; // ❌ Bad (Magic number)
}
```
- #### **2 Nesting**
+ #### **4.2 Nesting**
* **Depth Limit**: Do not nest more than 3 levels deep. Deep nesting increases file size and creates specificity wars.
* **Usage**: Use nesting primarily for BEM element targeting and pseudo-states (:hover, :focus).
**The "Inception" Rule:**
@@ 99,11 99,11 @@
}
}
```
- #### **3. Mixins vs. Extend**
+ #### **4.3. Mixins vs. Extend**
* **Mixins**: Preferred. Use for grouping properties or handling vendor prefixes.
* **Extend**: Avoid. @extend breaks the source order of CSS and can group selectors unexpectedly, leading to difficult debugging and bloated files.
- ### **Architecture (The 7-1 Pattern)**
+ ### **5. Architecture (The 7-1 Pattern)**
Structure your Sass/Less directories into 7 folders and 1 main file.
1. **abstracts/:** Variables, Mixins, Functions (outputs no CSS).
2. **base/:** Reset, Typography, global rules.
@@ 114,7 114,7 @@
7. **vendors/:** Third-party CSS (Bootstrap, jQuery UI).
8. **main.scss:** The entry point that imports all above.
- ### **Responsive Design & Units**
+ ### **6. Responsive Design & Units**
* **Layout**: Use relative units (%, vw, vh, fr) for containers.
* **Typography**: Use rem for font-size. This respects the user's browser settings.
* **Spacing**: Use rem or em for padding/margin to ensure spacing scales with typography.
@@ 143,14 143,16 @@
}
```
- ### **Performance**
+ ### **7. Performance**
* **Animation**: Only animate transform and opacity. Animating properties like width, height, top, or left causes expensive browser reflows.
* **Selectors**: Avoid the universal selector * inside complex components.
* **Imports**:
* **CSS**: Avoid @import in plain CSS (blocks parallel loading).
* **SCSS/LESS**: @import (or @use) is acceptable as it compiles to a single file.
- ### **Accessibility (A11y)**
+ ### **8. Accessibility (A11y)**
* **Hiding Content**: Do not use display: none for content meant for screen readers. Use a .visually-hidden utility class.
* **Focus**: Never set outline: 0 or outline: none on focusable elements without providing a visible replacement style.
* **Contrast**: Ensure text color contrast ratios meet WCAG AA standards (4.5:1 for normal text).
+
+ **Document** - [CSS](https://docs.google.com/document/d/1CU_KDWtQcGuYa6LDK_kU0E_EjqR0AlTed7-1o-iiT3s/edit?usp=sharing)
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9