Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !34942

Move reassigned Sass maps for colors to another stylesheet

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Mark Otto requested to merge split-vars-maps-import into main Sep 09, 2021
  • Overview 4
  • Commits 7
  • Pipelines 0
  • Changes 10

Fixes #34756 (closed).

The intent of the new CSS variables and the Sass maps that power them was improved customization, but it complicates things and breaks a common workflow. There's no great way around this unfortunately as the problem is how we create new variables and maps based on existing ones. For example, we extend $theme-colors into $theme-colors-rgb and two maps for .text-* and .bg-* utilities. As of v5.1.1, those other maps do not get updated after $theme-colors are modified.

There are two viable solutions I can see:

  1. Re-declare every map, like so:
@import "functions";
@import "variables";
@import "mixins";

$custom: #df711b;

$custom-theme-colors: (
"custom": $custom
);

$theme-colors: map-merge($theme-colors, $custom-theme-colors);
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
$utilities-colors: map-merge($utilities-colors, $theme-colors-rgb);
$utilities-text-colors: map-loop($utilities-colors, rgba-css-var, "$key", "text");
$utilities-bg-colors: map-loop($utilities-colors, rgba-css-var, "$key", "bg");
  1. Or, as this PR does, split those maps out to another stylesheet so we can have folks place modified values between variables and the new maps so they can be updated accordingly. Like so:
// Configuration
@import "functions";
@import "variables";

$starorange: #df711b !default;

$custom-theme-colors: (
  "starorange": $starorange
) !default;

$theme-colors: map-merge($theme-colors, $custom-theme-colors); // stylelint-disable-line scss/dollar-variable-default

@import "maps";
@import "mixins";
@import "utilities";

// Layout & components
// ...

Todos

  • Document this somewhere
  • Verify other maps that need moving

/cc @twbs/css-review

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: split-vars-maps-import