Override global Sass variables from theme

Continuing the discussion from Cleaning up our color palette :artist_palette::

Themes already have the ability to define sass variables:

However, from personal testing, these seem to be local to the theme’s stylesheets, and won’t globally override a variable.

If they did it would prove incredibly useful for theme development, as it would allow the theme to specify exactly what colour should be used as $primary-medium, $tertiary-low and so on - rather than have it automagically calculated off of the colour scheme.

Perhaps there should be a scope option, something like this:

"fields": {
  "primary-medium": {
    "value": "#012345",
    "type": "color",
    "scope": "global"
  }
}

Maybe, but what happens if multiple theme components are fighting for such a change, who wins?

As a wise man once said:

I can’t see much use for this beyond colours, and I can’t ever see a user wanting to enable two themes both of which change the color scheme.

Perhaps though this makes more sense as an extension to color_schemes, which can only be enabled individually:

"color_schemes": {
  "Extened Scheme": {
    "primary": "000",
    "primary-medium": "666",
    "primary-low": "aaaaaa"
  }
}

Related:

これ本当に必要なんです。

デフォルトのプライマリカラーは 4d238c です。問題は、$primary-secondary で生成される色(#a179de)がアクセシビリティガイドラインを満たしていないことです。そのため、もっと暗くする必要があります。

システムがセカンダリカラーを使用しているすべての場所で変更するのは手間がかかりますが、$primary-secondary : red; と上書きするだけで済むはずです。

リモートテーマで自動生成された変数をオーバーライドできるようになりました: Override values for auto-generated color variables