Future work for @mk-kit/ui, deferred from the main line of development.
-
Adopt SCSS as the source preprocessor. (Started — infra + theme + reference component done; remaining component migrations pending.)
Done so far:
styles/_mixins.scsswithtone()/tone-selectors/focus-ring().styles/mk-kit.scssis now the theme source: the dark tokens live in one$mk-darkmap emitted into both dark selectors via@each, removing the 3-place duplication. Compiled tostyles/mk-kit.cssbynpm run build:theme(run automatically bybuild:libandstart). Verified token-identical to the previous hand-written CSS.- Button migrated to
button.scssusing the tone/focus-ring mixins (reference pattern), verified pixel-identical in light + dark.
Also done:
- All component styles migrated from
.cssto.scss(73 files) with theirstyleUrls updated — a mechanical, no-visual-change pass. - Adopted
mk.tone-selectorsin the components whose[data-tone]blocks matched the shared pattern:badge,tag,chip,button-toggle-group(Button was the reference). Verified pixel-identical in the browser.
Also done:
- Adopted
mk.focus-ring()across every component (48 focus blocks in 39 files), passing the negative-offset variants (calc(-1 * …)/calc(… * -1)) as the mixin arg. Verified byte-identical compiled output.
Also done:
- Added a
mk.control-size($size, $padding)mixin (height + padding + font-size triple) and adopted it in the control inputs whose size blocks matched exactly:button,select,input,autocomplete(8 blocks). Padding is a parameter (varies per component); size-scopedborder-radiusstays with the caller. Verified byte-identical compiled output.
Also done:
- Added
mk.tone-main-selectors($contrast)and adopted it in the single---_maincontrols —radio,switch,slider(main only) andcheckbox($contrast: true). Verified byte-identical compiled output. The SCSS refactor is now effectively complete.
Remaining (optional):
- Consider generating the light token block from a map too (currently literal — it only lives in one place, so lower priority).
- The original plain-CSS notes below still describe the target end state:
- Tone → local-var mapping (the
--_main/--_subtle/ … blocks repeated across button, button-toggle, etc.) → a@mixin mk-tone($name). - Size scales (
sm/md/lgheight/padding/font blocks) → a size mixin. - Focus-ring, reduced-motion, and
:host([hidden])boilerplate → mixins. - The theme token blocks in
mk-kit.cssare duplicated across three selectors (light:root, theprefers-color-scheme: darkmedia query, and[data-mk-theme='dark']). A SCSS map +@eachemitting the dark values into both dark selectors would remove that duplication (today a token must be edited in three places — e.g. the chart palette). - Keep the public contract unchanged: components must still be themed by
--mk-*CSS custom properties at runtime (SCSS is build-time only; do not replace runtime custom properties with SCSS variables). - ng-packagr supports SCSS out of the box (
styleUrl: '*.scss'); the built package still ships plain CSS, so consumers are unaffected. - Do this as a mechanical, no-visual-change migration with a screenshot diff pass to confirm parity in light and dark.