Utilize SASS to maintain empowering Design Systems and Utilities

February 04, 2024
By: James A. Hernandez
article featured image
When it comes to SASS and CSS styling, a lot of early planning can keep a Design System simple and productive for development teams. Adoption of BEM can also keep conflicts between components to a minimum, as long as there is a good foundation of custom stylized variables. And keep your team up-to-date by adopting a gatekeeper to modify or adjust universal styles.

§  Utilizing SASS variables

// previously fonts-and-colors.scss

// ##############################
// From bootstrap (manual entry)
// https://getbootstrap.com/docs/5.0/utilities/colors/

$blue: #0d6efd;
$indigo: #6610f2;
$purple: #6f42c1;
$pink: #d63384;
$red: #dc3545;
$orange: #fd7e14;
$yellow: #ffc107;
$green: #198754;
$teal: #20c997;
$cyan: #0dcaf0;

// greys
$white: #fff;
$gray-100: #f8f9fa;
$gray-200: #e9ecef;
$gray-300: #dee2e6;
$gray-400: #ced4da;
$gray-500: #adb5bd;
$gray-600: #6c757d;
$gray-700: #495057;
$gray-800: #343a40;
$gray-900: #212529;
$black: #000;

// functional-color-coding
$primary: $blue;
$secondary: $gray-600;
$success: $green;
$info: $cyan;
$warning: $yellow;
$danger: $red;
$light: $gray-100;
$dark: $gray-900;

// ##############################
// END From bootstrap
// https://getbootstrap.com/docs/5.0/utilities/colors/

§  Utilizing Bootstrap built-in Dark Mode settings

The following variables come standard with my Gatbsy template.

@import 'styles/variables/main-colors.scss';

$default-font: 'DM Sans', 'Trebuchet MS', Sans-serif, 'Bebas Neue';

$original-light-blue: #b0e1f7; // nav
$original-orange: #f15a54;
// DEFAULT CUSTOM COLORS

$default-lightMode-blue-links: $blue;
$default-darkMode-blue-links: #7ab6ff;

// LIGHT MODE

// contrasts: (dark tones)

$lightMode-primary-contrast: $gray-900;
$lightMode-secondary-contrast: $gray-500;
$lightMode-tertiary-contrast: $gray-400;

$lightMode-link-color: $default-lightMode-blue-links;

// backgrounds
$lightMode-primary-bckg: $gray-100;
$lightMode-secondary-bckg: $gray-200;
$lightMode-tertiary-bckg: $gray-300;

// DARK MODE

//  contrasts: (light tones)
$darkMode-primary-contrast: $gray-400;
$darkMode-secondary-contrast: $gray-600;
$darkMode-tertiary-contrast: $gray-500;

$darkMode-link-color: $default-darkMode-blue-links;

// backgrounds

$darkMode-primary-bckg: $gray-900;
$darkMode-secondary-bckg: $gray-800;
$darkMode-tertiary-bckg: $gray-700;

// navigation

$default-nvg-bckg: $original-orange;
//$default-nvg-text: $gray-100;
$default-nvg-text: $gray-900;

$x24hr-nvg-text: $white;

There are several files which hold a variety of different style categories

  • dominant
    • best practices
    • breakpoints
    • utilities
    • helpers
  • site-specific
    • general
    • icons
    • remark
  • variables
    • gatsby-template
    • instance-additions
    • main-color
  • index

Integer aliquam odio ac leo rhoncus, et fringilla metus sollicitudin. Maecenas vel dui ante. Curabitur efficitur nisl in mauris pulvinar, vitae maximus purus iaculis. Phasellus ligula nunc, tempor sed finibus non, blandit laoreet justo. Vestibulum vitae purus nibh. Ut porta mi id ornare porttitor. Vestibulum tincidunt dui a metus fermentum lacinia. Curabitur vulputate, ante eget facilisis bibendum, augue ligula tempor nulla, nec sodales purus lacus et mauris. Fusce aliquet lorem at mi mollis, vitae pulvinar purus dapibus. Donec auctor urna sit amet mauris gravida lobortis.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi a quam libero. In consequat, libero nec porta ullamcorper, risus metus pellentesque erat, nec euismod ipsum libero et elit. Nam elementum convallis enim sit amet tincidunt. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse eu purus tristique, dictum nunc sagittis, vulputate diam. Sed ante ipsum, pharetra vel bibendum sit amet, auctor ut est. Aenean vel imperdiet turpis. Vivamus sit amet lacinia libero, id convallis dolor. Etiam in tortor dignissim massa euismod aliquam at at justo. Cras tincidunt dictum dictum. Vestibulum feugiat quam felis, sit amet scelerisque turpis rutrum vel.

Sed molestie lobortis erat, id posuere leo ornare consequat. Ut quam metus, tempor a convallis id, tincidunt eu orci. Etiam vel metus pretium, rutrum mauris ut, convallis ligula. Vestibulum tincidunt laoreet dolor, eu pellentesque velit tincidunt in. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Integer pharetra interdum sagittis. Nullam mollis metus vitae cursus condimentum. Etiam malesuada sem nisl, ut condimentum leo rutrum a. Vestibulum ac arcu ex. Sed lacus nunc, pulvinar in quam nec, lacinia scelerisque mauris.

Integer aliquam odio ac leo rhoncus, et fringilla metus sollicitudin. Maecenas vel dui ante. Curabitur efficitur nisl in mauris pulvinar, vitae maximus purus iaculis. Phasellus ligula nunc, tempor sed finibus non, blandit laoreet justo. Vestibulum vitae purus nibh. Ut porta mi id ornare porttitor. Vestibulum tincidunt dui a metus fermentum lacinia. Curabitur vulputate, ante eget facilisis bibendum, augue ligula tempor nulla, nec sodales purus lacus et mauris. Fusce aliquet lorem at mi mollis, vitae pulvinar purus dapibus. Donec auctor urna sit amet mauris gravida lobortis.

Nullam laoreet turpis eget odio molestie gravida. Donec consectetur auctor aliquet. Proin dapibus tristique mauris, nec egestas ligula. Phasellus a erat pellentesque, hendrerit diam quis, commodo ex. Pellentesque sit amet turpis euismod felis consequat blandit sed vitae augue. Maecenas velit elit, laoreet id erat in, lacinia consequat leo. Proin auctor sem ac dui faucibus, vitae hendrerit dui aliquet. Sed at ex eu orci scelerisque porttitor. Suspendisse ornare nisi id orci finibus suscipit. Nam ut velit eget magna pharetra dignissim. Integer hendrerit arcu sit amet elit pulvinar posuere. Maecenas condimentum euismod arcu, sed eleifend nibh. Aliquam fermentum, mauris ac volutpat laoreet, sapien dui aliquet nibh, vel pellentesque nisi metus at metus. Suspendisse vitae massa lacus. Quisque volutpat, tellus eu eleifend vulputate, magna turpis sodales massa, in porttitor sapien risus ut elit.

Sed hendrerit mi elit, et varius massa consequat sed. Phasellus in massa est. Quisque bibendum lacinia quam, a sollicitudin tortor rutrum ut. Integer at massa lorem. Nunc in dui non neque cursus dictum. Suspendisse iaculis suscipit interdum. Nullam erat nulla, vulputate at dignissim vitae, sagittis non ligula. Sed dictum malesuada pharetra. Mauris venenatis, lorem in hendrerit accumsan, neque nibh auctor tellus, ac rutrum tellus diam ac leo. Maecenas at semper quam, sed sollicitudin tellus. Morbi semper vulputate leo quis maximus. Vestibulum volutpat porttitor lacus vitae congue. Nulla congue lacinia posuere. Aenean vitae urna quis lacus congue faucibus. Pellentesque quis turpis augue. Curabitur lacus felis, semper vel purus et, efficitur facilisis risus.

Utilizing Bootstrap built-in Dark Mode settings