From f0d947a4119184690f4e3e38ef57786b73dac27c Mon Sep 17 00:00:00 2001 From: "louismaxime.piton" Date: Fri, 6 Oct 2023 14:55:47 +0200 Subject: [PATCH] Add color mode on select --- scss/_root.scss | 4 ++ scss/_variables-dark.scss | 4 +- scss/_variables.scss | 62 ++++++++++----------- scss/forms/_form-select.scss | 4 +- site/content/docs/5.3/dark-mode.md | 87 ++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 34 deletions(-) diff --git a/scss/_root.scss b/scss/_root.scss index 770ebda162..1463c0a36d 100644 --- a/scss/_root.scss +++ b/scss/_root.scss @@ -143,6 +143,8 @@ --#{$prefix}active-bg: #{$gray-400}; --#{$prefix}disabled-color: #{$gray-500}; --#{$prefix}placeholder-color: #{$gray-700}; + --#{$prefix}select-indicator: #{$form-select-indicator}; + --#{$prefix}select-disabled-indicator: #{$form-select-disabled-indicator}; // ******* End additions for dark-mode } @@ -218,6 +220,8 @@ --#{$prefix}active-bg: #{$gray-700}; --#{$prefix}disabled-color: #{$gray-700}; --#{$prefix}placeholder-color: #{$gray-600}; + --#{$prefix}select-indicator: #{$form-select-indicator-dark}; + --#{$prefix}select-disabled-indicator: #{$form-select-disabled-indicator-dark}; // ******* End additions for dark-mode // scss-docs-end root-dark-mode-vars } diff --git a/scss/_variables-dark.scss b/scss/_variables-dark.scss index dc93a2d330..1ac1a7c194 100644 --- a/scss/_variables-dark.scss +++ b/scss/_variables-dark.scss @@ -97,7 +97,9 @@ $focus-visible-outer-color-dark: $white !default; // Boosted mod // // Boosted mod: no $form-select-indicator-color-dark -// Boosted mod: no $form-select-indicator-dark + +$form-select-indicator-dark: escape-svg(url("data:image/svg+xml,")) !default; +$form-select-disabled-indicator-dark: escape-svg(url("data:image/svg+xml,")) !default; // Boosted mod // Boosted mod: no $form-switch-color-dark // Boosted mod: no $form-switch-bg-image-dark diff --git a/scss/_variables.scss b/scss/_variables.scss index f953538a02..5ff9ed699c 100644 --- a/scss/_variables.scss +++ b/scss/_variables.scss @@ -1230,47 +1230,47 @@ $input-group-addon-border-color: null !default; // scss-docs-end input-group-variables // scss-docs-start form-select-variables -$form-select-padding-y: $input-padding-y !default; -$form-select-padding-x: $input-padding-x !default; -$form-select-font-family: $input-font-family !default; -$form-select-font-size: $input-font-size !default; -$form-select-indicator-padding: $form-select-padding-x * 3 !default; // Extra padding for background-image -$form-select-font-weight: $input-font-weight !default; -$form-select-line-height: $input-line-height !default; -$form-select-color: $input-color !default; -$form-select-bg: $input-bg !default; -$form-select-disabled-color: $gray-700 !default; -$form-select-disabled-bg: $input-disabled-bg !default; -$form-select-disabled-border-color: $input-disabled-border-color !default; -$form-select-bg-position: right $form-select-padding-x top add(50%, 1px) !default; -$form-select-bg-size: .875rem 1rem !default; // In pixels because image dimensions -$form-select-indicator: url("data:image/svg+xml,") !default; -$form-select-disabled-indicator: url("data:image/svg+xml,") !default; // Boosted mod +$form-select-padding-y: $input-padding-y !default; +$form-select-padding-x: $input-padding-x !default; +$form-select-font-family: $input-font-family !default; +$form-select-font-size: $input-font-size !default; +$form-select-indicator-padding: $form-select-padding-x * 3 !default; // Extra padding for background-image +$form-select-font-weight: $input-font-weight !default; +$form-select-line-height: $input-line-height !default; +$form-select-color: $input-color !default; +$form-select-bg: $input-bg !default; +$form-select-disabled-color: $input-disabled-color !default; // Boosted mod: instead of `null` +$form-select-disabled-bg: $input-disabled-bg !default; +$form-select-disabled-border-color: $input-disabled-border-color !default; +$form-select-bg-position: right $form-select-padding-x top add(50%, 1px) !default; +$form-select-bg-size: .875rem 1rem !default; // In pixels because image dimensions +$form-select-indicator: escape-svg(url("data:image/svg+xml,")) !default; +$form-select-disabled-indicator: escape-svg(url("data:image/svg+xml,")) !default; // Boosted mod $form-select-feedback-icon-padding-end: $form-select-padding-x * 2.5 + $form-select-indicator-padding !default; $form-select-feedback-icon-position: center right $form-select-indicator-padding !default; $form-select-feedback-icon-size: $input-height-inner-half $input-height-inner-half !default; -$form-select-border-width: $input-border-width !default; -$form-select-border-color: $input-border-color !default; -$form-select-border-radius: $input-border-radius !default; -$form-select-box-shadow: none !default; // Boosted mod +$form-select-border-width: $input-border-width !default; +$form-select-border-color: $input-border-color !default; +$form-select-border-radius: $input-border-radius !default; +$form-select-box-shadow: none !default; // Boosted mod -$form-select-focus-border-color: $input-color !default; // Boosted mod: for border to show in Firefox +$form-select-focus-border-color: $input-color !default; // Boosted mod: for border to show in Firefox // Boosted mod: no $form-select-focus-width -$form-select-focus-box-shadow: none !default; // Boosted mod +$form-select-focus-box-shadow: none !default; // Boosted mod -$form-select-padding-y-sm: add($input-padding-y-sm, 1px) !default; // Boosted mod -$form-select-padding-x-sm: $input-padding-x-sm !default; -$form-select-font-size-sm: $input-font-size-sm !default; -$form-select-border-radius-sm: $input-border-radius-sm !default; +$form-select-padding-y-sm: add($input-padding-y-sm, 1px) !default; // Boosted mod +$form-select-padding-x-sm: $input-padding-x-sm !default; +$form-select-font-size-sm: $input-font-size-sm !default; +$form-select-border-radius-sm: $input-border-radius-sm !default; -$form-select-padding-y-lg: $spacer * .5 !default; // Boosted mod -$form-select-padding-x-lg: $input-padding-x-lg !default; -$form-select-font-size-lg: $input-font-size-lg !default; -$form-select-border-radius-lg: $input-border-radius-lg !default; +$form-select-padding-y-lg: $spacer * .5 !default; // Boosted mod +$form-select-padding-x-lg: $input-padding-x-lg !default; +$form-select-font-size-lg: $input-font-size-lg !default; +$form-select-border-radius-lg: $input-border-radius-lg !default; -$form-select-transition: $input-transition !default; +$form-select-transition: $input-transition !default; // scss-docs-end form-select-variables // scss-docs-start form-range-variables diff --git a/scss/forms/_form-select.scss b/scss/forms/_form-select.scss index 3b4483f54a..7c715cfffa 100644 --- a/scss/forms/_form-select.scss +++ b/scss/forms/_form-select.scss @@ -4,7 +4,7 @@ // https://primer.github.io/. .form-select { - --#{$prefix}form-select-bg-img: #{escape-svg($form-select-indicator)}; + --#{$prefix}form-select-bg-img: var(--#{$prefix}select-indicator); display: block; width: 100%; @@ -45,7 +45,7 @@ &:disabled { color: $form-select-disabled-color; background-color: $form-select-disabled-bg; - background-image: escape-svg($form-select-disabled-indicator); // Boosted mod + background-image: var(--#{$prefix}select-disabled-indicator); // Boosted mod border-color: $form-select-disabled-border-color; } diff --git a/site/content/docs/5.3/dark-mode.md b/site/content/docs/5.3/dark-mode.md index 5c4b5ac9c9..dfda699944 100644 --- a/site/content/docs/5.3/dark-mode.md +++ b/site/content/docs/5.3/dark-mode.md @@ -750,6 +750,93 @@ Additional variables for dark-mode (temporary) +### Select + +

No theme

+ +
+ + +
+ +

Dark theme on container

+ +
+ + +
+ +

Light theme on container

+ +
+ + +
+ +

Dark theme on component

+ +
+ + +
+ +

Light theme on component

+ +
+ + +
+ ### Star rating

No theme