[DPEDE-7039] Optimize SCSS for Sidenav component#2080
Conversation
|
The CI pipeline has run successfully in https://jenkinsprod.corp.intranet:8443/job/UX-CHI/job/Productive/job/Chi/job/PR-2080/1/. ✅ |
|
You can check this PRs instance in https://nginx-pr-2080-ux-chi.rke-odc-test.corp.intranet (internal) |
|
The CI pipeline has run successfully in https://jenkinsprod.corp.intranet:8443/job/UX-CHI/job/Productive/job/Chi/job/PR-2080/2/. ✅ |
|
You can check this PRs instance in https://nginx-pr-2080-ux-chi.rke-odc-test.corp.intranet (internal) |
…ze-SCSS-for-Sidenav-component
|
SonarQube Quality Gate
|
|
The CI pipeline has run successfully in https://jenkinsprod.corp.intranet:8443/job/UX-CHI/job/Productive/job/Chi/job/PR-2080/3/. ✅ |
|
You can check this PRs instance in https://nginx-pr-2080-ux-chi.rke-odc-test.corp.intranet (internal) |








https://lumen.atlassian.net/browse/DPEDE-7039
Summary
Optimized
sidenav.scssto reduce compiled CSS output by −6,562 B per theme (lumen). Source lines reduced from 1,160 to 864 (536 main + 328 partial; −296 net). 133 duplicate theme variable lines consolidated. Longest compiled selector reduced from 837 to 220 characters. Primary techniques: nesting flattening (selector text reduction), CSS custom property consolidation (--sidenav-w), and@mixindeduplication. Additionally fixed 4 bugs discovered during review and standardizedfont-weightbehavior across legacy and accordion drawer variants.Background
sidenav.scsswas the 7th heaviest component in Chi at 27.5 KB compiled / 171 rule blocks (lumen), representing 4.0% of total CSS output. The primary optimization opportunities were:.-global— SCSS following DOM structure literally, producing the longest selector in the design system (837 chars / 40 combinators) for a singlecolorrule..chi-drawer.-left { left: $width }blocks across size variants and responsive breakpoints.background-color,box-shadow,color,font-weight) across drawer accordion contexts.!default..-slidingmodifier, unreferenced&__description.Changes Made
1. Deep nesting flattening in
.-globalRemoved the
.chi-sidenav__content nav .chi-sidenav__list > liprefix from ~40 compiled rules in the global variant. The.-globalmodifier provides sufficient specificity without intermediate DOM-path selectors. Extracted the entire.-globalsection into_sidenav-global.scsspartial (330 lines).Before:
.chi-sidenav.-global .chi-sidenav__content nav .chi-sidenav__list > li .chi-sidenav__item-wrapper ...(837 chars)After:
.chi-sidenav.-global .chi-sidenav__item-wrapper ...(220 chars max)2. CSS custom property
--sidenav-wfor drawer positioningReplaced 5 duplicate
.chi-drawer.-leftblocks (base, responsive md,-sm,-md,-lg) with a singlevar(--sidenav-w)declaration. Each size variant sets the custom property as a one-liner instead of duplicating 6 lines of drawer positioning.3. Active/hover state deduplication
Created
@mixin _sidenav-drawer-active-statefor the 4× repeated active-state block in drawer content. Flattened drawer content nesting and consolidated expand/collapse visibility patterns at the base.-globallevel.4. Selector compression via
:is():is(.chi-link, .icon-chevron-down)combines visibility toggle selectors5. Unused code cleanup
.-slidingmodifier.-floatmodifier on sidenav root.-sm,.-md,.-lgsize modifiers on sidenav root--sidenav-wcustom property (§2)&__descriptionblock6. Theme variable
!defaultconsolidation19 variables identical across all 7 themes moved to
sidenav.scsswith!default. Consolidated 133 duplicate lines from theme_variables.scssfiles.7. CSS shorthand, logical properties & source architecture
margin-block: 0, padding/margin/border-radius shorthand conversions. Added section headers for navigation. Extracted.-globalinto partial file.8. Bug fixes discovered during review
8a. Drawer z-index stacking
Drawer panel was rendering on top of
__contentduring slide animation. Root cause:__contenthadz-index: $zindex-fixed + 1(21) which tied with.-activedrawer (also 21), and DOM order caused the drawer to win. Fixed by bumping__contentto$zindex-fixed + 2(22).8b. Global sidenav specificity regression
Accordion trigger icons in the global sidenav rendered teal instead of grey. The nesting flattening in §1 dropped
.chi-sidenav__content navfrom the.chi-sidenav__list > liselector chain, reducing specificity from(0,6,2)to(0,5,1)— which lost to the accordion component's.chi-accordion.-link .chi-accordion__trigger .chi-iconat(0,6,0). Fixed by restoring.chi-sidenav__content navnesting for the list-items block only.8c. Legacy icon sizing for material icons
Drawer close button icon, accordion trigger chevron, and
chi-sidenav__title::afterpseudo-icon were sized at0.75rem— appropriate for the old custom icon font but too small for Material Symbols Outlined. Updated all icon sizing properties (font-size,height,width,line-height) to1.25remand adjusted absolute positioning (top,right) for vertical centering.8d. Missing
text-decoration: noneon drawer content anchorsPre-existing issue:
a.chi-drawer__subitem-list-triggerlinks were underlined because theremove-anchor-stylemixin only setstext-decoration: noneon:hover. Addedtext-decoration: noneto the.chi-drawer__content abase rule.9. Global sidenav visual regression tests
Added global sidenav test sections (collapsed + expanded) to
tests/js/sidenav.pug.10. Font-weight standardization across drawer variants (intentional visual change)
This is an intentional design alignment, not a regression. The accordion drawer variant applied
font-weight: 500to ALL top-level items unconditionally (both active and inactive). The legacy drawer variant only appliedfont-weight: 500conditionally on-activeand-expandedstates. No documentation examples use the legacy pattern — all sidenav docs reference the accordion variant.Standardized legacy
__drawer-listto match: all top-level items now render atfont-weight: 500, unifying behavior across both variants and simplifying the code.Results
Source Metrics
sidenav.scsssource linesCompiled CSS Size
Sidenav-Specific CSS (lumen)