Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dark mode support #35857

Merged
merged 57 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
5a343c8
Add dark mode to docs
mdo Feb 16, 2022
eaa0869
Minor fix: missing space indentation
julien-deramond Nov 17, 2022
d09cc90
Minor fix: revert utilities/z-index added-in modification
julien-deramond Nov 17, 2022
3669ff8
Remove prev: and next: from doc because extracted to another PR
julien-deramond Nov 18, 2022
17c3670
Use .bg-body-tertiary in all Utilities > Overflow examples
julien-deramond Nov 18, 2022
451e7c3
fix example
mdo Nov 19, 2022
c95c068
Fix up spacing examples
mdo Nov 19, 2022
5ee6ce5
Update box-shadow Sass variables and utilities to auto-adjust to colo…
mdo Nov 19, 2022
65cce21
Remove unused docs class
mdo Nov 19, 2022
cd01c4b
Refactor form styles to use CSS variable for background images on .fo…
mdo Nov 19, 2022
bd303d8
Fix docs selector
mdo Nov 19, 2022
ade37c1
Rename shortcut for clarity
mdo Nov 19, 2022
71d0264
Heading consistency
mdo Nov 19, 2022
fd7580a
Reintroduce missing 4th grid item in Utilities > Spacing example
julien-deramond Nov 19, 2022
564c873
Merge branch 'main' into new-masthead-darkmode
julien-deramond Nov 19, 2022
f09eb97
Fix bundlewatch
julien-deramond Nov 19, 2022
61cbd9d
.bd-callout* rendering is OK so removing comments in the code
julien-deramond Nov 19, 2022
3676c23
Update scss/_utilities.scss
mdo Nov 19, 2022
12d82b0
Fix gutters example styling
mdo Nov 19, 2022
b99606b
Fix text colors on background utils docs
mdo Nov 19, 2022
1ffcbdf
redesign and fix up position marker example, which doesn't show nicel…
mdo Nov 19, 2022
508957c
fix some color utils examples
mdo Nov 19, 2022
1b63a98
Deprecate mixin notice
mdo Nov 19, 2022
36e2264
Deprecate notice for list-group-item-variant() mixin
mdo Nov 19, 2022
c59f429
Revamp new link CSS vars
mdo Nov 20, 2022
adf418a
Use map-keys in some each Sass files
julien-deramond Nov 24, 2022
40dfd22
Remove list-group-item-variant mixin ref in sass loop desc
julien-deramond Nov 24, 2022
5031d41
Display CSS vars scoped to our built-in dark mode
julien-deramond Nov 24, 2022
d5b1b85
Revert previous commit
julien-deramond Nov 24, 2022
3917c03
Fix list group variant link
julien-deramond Nov 25, 2022
9163b9f
Fix typo
julien-deramond Nov 25, 2022
0cffe85
Remove imports of alert/list-group mixins in scss/_mixins.scss
julien-deramond Nov 25, 2022
f39e8d4
Small formatting + comments removal in scss/_content.scss
julien-deramond Nov 25, 2022
eba5fc6
Fix alert links colors
julien-deramond Nov 25, 2022
afb664a
fix dropdown border-radius mixin
mdo Nov 25, 2022
1c7b5ba
fix link color and underline again, this time using CSS var override …
mdo Nov 25, 2022
ad17750
fix colors on docs navbar for dark mode
mdo Nov 25, 2022
b49a4c4
remove two changes
mdo Nov 25, 2022
e3e4dba
missing ref
mdo Nov 25, 2022
aaf89f3
another link underline fix, just use sass vars for link decoration fo…
mdo Nov 25, 2022
bd67392
missing color bg docs, plus move dropdown override to scss
mdo Nov 25, 2022
1dbc505
more changes from review
mdo Nov 25, 2022
d855319
fix some examples, drop unused docs navbar styles, update docs navbar…
mdo Nov 25, 2022
3fe9bd3
Few fixes around type
mdo Nov 25, 2022
59c2b32
Restyle custom details > summary element in docs
mdo Nov 25, 2022
1e24b69
Rewrite some migration docs
mdo Nov 25, 2022
0e4e0bb
fix form checks
mdo Nov 26, 2022
58b9780
Fix up some navbar styling, tweak docs callout
mdo Nov 28, 2022
3493066
Fix select images, mostly for validation styling
mdo Nov 28, 2022
6e8e0b9
Clean up some migration notes, document some new form control CSS var…
mdo Nov 28, 2022
fccb28d
Update site/content/docs/5.2/components/scrollspy.md
mdo Nov 28, 2022
15c8d21
Apply suggestions from code review
mdo Nov 28, 2022
13438b7
mention form control css vars in migration guide
mdo Nov 28, 2022
a84e038
Tweak grid and flex docs background examples
mdo Nov 28, 2022
d83988a
clarify some docs
mdo Nov 28, 2022
cde601e
fix some more things
mdo Nov 28, 2022
5746a4c
Merge branch 'main' into new-masthead-darkmode
julien-deramond Nov 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
"files": [
{
"path": "./dist/css/bootstrap-grid.css",
"maxSize": "7.5 kB"
"maxSize": "8.25 kB"
},
{
"path": "./dist/css/bootstrap-grid.min.css",
"maxSize": "6.75 kB"
"maxSize": "7.5 kB"
},
{
"path": "./dist/css/bootstrap-reboot.css",
"maxSize": "2.75 kB"
"maxSize": "3.5 kB"
},
{
"path": "./dist/css/bootstrap-reboot.min.css",
"maxSize": "2.5 kB"
"maxSize": "3.25 kB"
},
{
"path": "./dist/css/bootstrap-utilities.css",
"maxSize": "9.75 kB"
"maxSize": "10.5 kB"
},
{
"path": "./dist/css/bootstrap-utilities.min.css",
"maxSize": "9.0 kB"
"maxSize": "9.75 kB"
},
{
"path": "./dist/css/bootstrap.css",
"maxSize": "30.25 kB"
"maxSize": "31.25 kB"
},
{
"path": "./dist/css/bootstrap.min.css",
"maxSize": "28 kB"
"maxSize": "29.25 kB"
},
{
"path": "./dist/js/bootstrap.bundle.js",
Expand Down
9 changes: 9 additions & 0 deletions scss/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,12 @@
}
}
}

@if $enable-dark-mode {
julien-deramond marked this conversation as resolved.
Show resolved Hide resolved
@include color-mode(dark) {
.accordion-button::after {
--#{$prefix}accordion-btn-icon: #{escape-svg($accordion-button-icon-dark)};
--#{$prefix}accordion-btn-active-icon: #{escape-svg($accordion-button-active-icon-dark)};
}
}
}
19 changes: 8 additions & 11 deletions scss/_alert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
--#{$prefix}alert-border-color: transparent;
--#{$prefix}alert-border: #{$alert-border-width} solid var(--#{$prefix}alert-border-color);
--#{$prefix}alert-border-radius: #{$alert-border-radius};
--#{$prefix}alert-link-color: inherit;
// scss-docs-end alert-css-vars

position: relative;
Expand All @@ -32,6 +33,7 @@
// Provide class for links that match alerts
.alert-link {
font-weight: $alert-link-font-weight;
color: var(--#{$prefix}alert-link-color);
}


Expand All @@ -54,18 +56,13 @@


// scss-docs-start alert-modifiers
// Generate contextual modifier classes for colorizing the alert.

@each $state, $value in $theme-colors {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't looked at it yet but I'm afraid that https://deploy-preview-35857--twbs-bootstrap.netlify.app/docs/5.2/customize/sass/#add-to-map won't work anymore.

$alert-background: shift-color($value, $alert-bg-scale);
$alert-border: shift-color($value, $alert-border-scale);
$alert-color: shift-color($value, $alert-color-scale);

@if (contrast-ratio($alert-background, $alert-color) < $min-contrast-ratio) {
$alert-color: mix($value, color-contrast($alert-background), abs($alert-color-scale));
}
// Generate contextual modifier classes for colorizing the alert
@each $state in map-keys($theme-colors) {
.alert-#{$state} {
@include alert-variant($alert-background, $alert-border, $alert-color);
--#{$prefix}alert-color: var(--#{$prefix}#{$state}-text);
mdo marked this conversation as resolved.
Show resolved Hide resolved
--#{$prefix}alert-bg: var(--#{$prefix}#{$state}-bg-subtle);
--#{$prefix}alert-border-color: var(--#{$prefix}#{$state}-border-subtle);
--#{$prefix}alert-link-color: var(--#{$prefix}#{$state}-text);
mdo marked this conversation as resolved.
Show resolved Hide resolved
}
}
// scss-docs-end alert-modifiers
14 changes: 13 additions & 1 deletion scss/_carousel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@

// Dark mode carousel

.carousel-dark {
%carousel-dark {
.carousel-control-prev-icon,
Copy link
Member

@julien-deramond julien-deramond Nov 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On dark mode, it is very difficult to distinguish the normal color and the hovered one on the third slide

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, let's save for later with more feedback.

.carousel-control-next-icon {
filter: $carousel-dark-control-icon-filter;
Expand All @@ -224,3 +224,15 @@
color: $carousel-dark-caption-color;
}
}

.carousel-dark {
@extend %carousel-dark;
}

@if $enable-dark-mode {
@include color-mode(dark) {
.carousel {
@extend %carousel-dark;
}
}
}
14 changes: 13 additions & 1 deletion scss/_close.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
}
}

.btn-close-white {
%btn-close-white {
filter: var(--#{$prefix}btn-close-white-filter);
}

.btn-close-white {
@extend %btn-close-white;
}

@if $enable-dark-mode {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@include color-mode(dark) {
.btn-close {
@extend %btn-close-white;
}
}
}
1 change: 1 addition & 0 deletions scss/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
white-space: nowrap; // prevent links from randomly breaking onto new lines
background-color: transparent; // For `<button>`s
border: 0; // For `<button>`s
@include border-radius(var(--#{$prefix}dropdown-item-border-radius, 0));

&:hover,
&:focus {
Expand Down
26 changes: 19 additions & 7 deletions scss/_list-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,25 @@
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.

@each $state, $value in $theme-colors {
$list-group-variant-bg: shift-color($value, $list-group-item-bg-scale);
$list-group-variant-color: shift-color($value, $list-group-item-color-scale);
@if (contrast-ratio($list-group-variant-bg, $list-group-variant-color) < $min-contrast-ratio) {
$list-group-variant-color: mix($value, color-contrast($list-group-variant-bg), abs($list-group-item-color-scale));
}
@each $state in map-keys($theme-colors) {
.list-group-item-#{$state} {
--#{$prefix}list-group-color: var(--#{$prefix}#{$state}-text);
--#{$prefix}list-group-bg: var(--#{$prefix}#{$state}-bg-subtle);
--#{$prefix}list-group-border-color: var(--#{$prefix}#{$state}-border-subtle);

&.list-group-item-action {
&:hover,
&:focus {
--#{$prefix}list-group-action-hover-color: var(--#{$prefix}emphasis-color);
--#{$prefix}list-group-action-hover-bg: var(--#{$prefix}#{$state}-border-subtle);
}

@include list-group-item-variant($state, $list-group-variant-bg, $list-group-variant-color);
&:active {
--#{$prefix}list-group-active-color: var(--#{$prefix}emphasis-color);
--#{$prefix}list-group-active-bg: var(--#{$prefix}#{$state}-text);
--#{$prefix}list-group-active-border-color: var(--#{$prefix}#{$state}-text);
}
}
}
}
// scss-docs-end list-group-modifiers
67 changes: 67 additions & 0 deletions scss/_maps.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,39 @@
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value") !default;
// scss-docs-end theme-colors-rgb

$theme-colors-text: (
julien-deramond marked this conversation as resolved.
Show resolved Hide resolved
"primary": $primary-text,
"secondary": $secondary-text,
"success": $success-text,
"info": $info-text,
"warning": $warning-text,
"danger": $danger-text,
"light": $light-text,
"dark": $dark-text,
) !default;

$theme-colors-bg-subtle: (
"primary": $primary-bg-subtle,
"secondary": $secondary-bg-subtle,
"success": $success-bg-subtle,
"info": $info-bg-subtle,
"warning": $warning-bg-subtle,
"danger": $danger-bg-subtle,
"light": $light-bg-subtle,
"dark": $dark-bg-subtle,
) !default;

$theme-colors-border-subtle: (
"primary": $primary-border-subtle,
"secondary": $secondary-border-subtle,
"success": $success-border-subtle,
"info": $info-border-subtle,
"warning": $warning-border-subtle,
"danger": $danger-border-subtle,
"light": $light-border-subtle,
"dark": $dark-border-subtle,
) !default;

// Utilities maps
//
// Extends the default `$theme-colors` maps to help create our utilities.
Expand All @@ -25,6 +58,17 @@ $utilities-text: map-merge(
)
) !default;
$utilities-text-colors: map-loop($utilities-text, rgba-css-var, "$key", "text") !default;

$utilities-text-emphasis-colors: (
"primary-emphasis": var(--#{$prefix}primary-text),
"secondary-emphasis": var(--#{$prefix}secondary-text),
"success-emphasis": var(--#{$prefix}success-text),
"info-emphasis": var(--#{$prefix}info-text),
"warning-emphasis": var(--#{$prefix}warning-text),
"danger-emphasis": var(--#{$prefix}danger-text),
"light-emphasis": var(--#{$prefix}light-text),
"dark-emphasis": var(--#{$prefix}dark-text)
) !default;
// scss-docs-end utilities-text-colors

// scss-docs-start utilities-bg-colors
Expand All @@ -37,6 +81,18 @@ $utilities-bg: map-merge(
)
) !default;
$utilities-bg-colors: map-loop($utilities-bg, rgba-css-var, "$key", "bg") !default;

$utilities-bg-subtle: (
"primary-subtle": var(--#{$prefix}primary-bg-subtle),
"secondary-subtle": var(--#{$prefix}secondary-bg-subtle),
"success-subtle": var(--#{$prefix}success-bg-subtle),
"info-subtle": var(--#{$prefix}info-bg-subtle),
"warning-subtle": var(--#{$prefix}warning-bg-subtle),
"danger-subtle": var(--#{$prefix}danger-bg-subtle),
"light-subtle": var(--#{$prefix}light-bg-subtle),
"dark-subtle": var(--#{$prefix}dark-bg-subtle)
) !default;
// $utilities-bg-subtle-colors: map-loop($utilities-bg-subtle, rgba-css-var, "$key", "bg") !default;
// scss-docs-end utilities-bg-colors

// scss-docs-start utilities-border-colors
Expand All @@ -47,6 +103,17 @@ $utilities-border: map-merge(
)
) !default;
$utilities-border-colors: map-loop($utilities-border, rgba-css-var, "$key", "border") !default;

$utilities-border-subtle: (
"primary-subtle": var(--#{$prefix}primary-border-subtle),
"secondary-subtle": var(--#{$prefix}secondary-border-subtle),
"success-subtle": var(--#{$prefix}success-border-subtle),
"info-subtle": var(--#{$prefix}info-border-subtle),
"warning-subtle": var(--#{$prefix}warning-border-subtle),
"danger-subtle": var(--#{$prefix}danger-border-subtle),
"light-subtle": var(--#{$prefix}light-border-subtle),
"dark-subtle": var(--#{$prefix}dark-border-subtle)
) !default;
// scss-docs-end utilities-border-colors

$negative-spacers: if($enable-negative-margins, negativify-map($spacers), null) !default;
Expand Down
3 changes: 1 addition & 2 deletions scss/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

// Helpers
@import "mixins/breakpoints";
@import "mixins/color-mode";
@import "mixins/color-scheme";
@import "mixins/image";
@import "mixins/resize";
Expand All @@ -21,13 +22,11 @@
@import "mixins/utilities";

// Components
@import "mixins/alert";
@import "mixins/backdrop";
@import "mixins/buttons";
@import "mixins/caret";
@import "mixins/pagination";
@import "mixins/lists";
@import "mixins/list-group";
@import "mixins/forms";
@import "mixins/table-variants";

Expand Down
8 changes: 8 additions & 0 deletions scss/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,11 @@
--#{$prefix}navbar-toggler-icon-bg: #{escape-svg($navbar-dark-toggler-icon-bg)};
// scss-docs-end navbar-dark-css-vars
}

@if $enable-dark-mode {
@include color-mode(dark) {
.navbar {
--#{$prefix}navbar-toggler-icon-bg: #{escape-svg($navbar-dark-toggler-icon-bg)};
}
}
}
2 changes: 1 addition & 1 deletion scss/_pagination.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
margin-left: $pagination-margin-start;
}

@if $pagination-margin-start == ($pagination-border-width * -1) {
@if $pagination-margin-start == calc($pagination-border-width * -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except if you've found a non-working use case, this modification should be reverted (see a153f36).

&:first-child {
.page-link {
@include border-start-radius(var(--#{$prefix}pagination-border-radius));
Expand Down
6 changes: 3 additions & 3 deletions scss/_reboot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ hr {
font-style: $headings-font-style;
font-weight: $headings-font-weight;
line-height: $headings-line-height;
color: $headings-color;
color: var(--#{$prefix}heading-color, inherit);
}

h1 {
Expand Down Expand Up @@ -241,11 +241,11 @@ sup { top: -.5em; }
// Links

a {
color: var(--#{$prefix}link-color);
color: rgba(var(--#{$prefix}link-color-rgb), var(--#{$prefix}link-opacity, 1));
text-decoration: $link-decoration;

&:hover {
color: var(--#{$prefix}link-hover-color);
--#{$prefix}link-color-rgb: var(--#{$prefix}link-hover-color-rgb);
text-decoration: $link-hover-decoration;
}
}
Expand Down
Loading