Skip to content

Commit

Permalink
Add dark mode to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdo committed Aug 10, 2022
1 parent a685b96 commit 71f5b79
Show file tree
Hide file tree
Showing 42 changed files with 732 additions and 224 deletions.
12 changes: 6 additions & 6 deletions .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"files": [
{
"path": "./dist/css/bootstrap-grid.css",
"maxSize": "7.5 kB"
"maxSize": "7.75 kB"
},
{
"path": "./dist/css/bootstrap-grid.min.css",
"maxSize": "6.55 kB"
"maxSize": "7.0 kB"
},
{
"path": "./dist/css/bootstrap-reboot.css",
"maxSize": "2.75 kB"
"maxSize": "3.0 kB"
},
{
"path": "./dist/css/bootstrap-reboot.min.css",
"maxSize": "2.5 kB"
"maxSize": "2.75 kB"
},
{
"path": "./dist/css/bootstrap-utilities.css",
Expand All @@ -26,11 +26,11 @@
},
{
"path": "./dist/css/bootstrap.css",
"maxSize": "28.75 kB"
"maxSize": "29.25 kB"
},
{
"path": "./dist/css/bootstrap.min.css",
"maxSize": "26.75 kB"
"maxSize": "27.25 kB"
},
{
"path": "./dist/js/bootstrap.bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion scss/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

.accordion {
// scss-docs-start accordion-css-vars
--#{$prefix}accordion-color: #{color-contrast($accordion-bg)};
--#{$prefix}accordion-color: #{$accordion-color};
--#{$prefix}accordion-bg: #{$accordion-bg};
--#{$prefix}accordion-transition: #{$accordion-transition};
--#{$prefix}accordion-border-color: #{$accordion-border-color};
Expand Down
8 changes: 8 additions & 0 deletions scss/_close.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@
.btn-close-white {
filter: $btn-close-white-filter;
}

@if $enable-dark-mode {
[data-bs-theme="dark"] {
.btn-close {
filter: $btn-close-white-filter;
}
}
}
1 change: 1 addition & 0 deletions scss/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
white-space: nowrap; // prevent links from randomly breaking onto new lines
background-color: transparent; // For `<button>`s
border: 0; // For `<button>`s
border-radius: var(--#{$prefix}dropdown-item-border-radius, 0); // stylelint-disable-line property-disallowed-list

&:hover,
&:focus {
Expand Down
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) {
&:first-child {
.page-link {
@include border-start-radius(var(--#{$prefix}pagination-border-radius));
Expand Down
77 changes: 72 additions & 5 deletions scss/_root.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:root {
[data-bs-theme="light"] {
// Note: Custom variable values only support SassScript inside `#{}`.

// Colors
Expand Down Expand Up @@ -44,12 +44,33 @@
--#{$prefix}body-font-weight: #{$font-weight-base};
--#{$prefix}body-line-height: #{$line-height-base};
--#{$prefix}body-color: #{$body-color};
// --#{$prefix}body-accent-color: #{$body-accent-color};

// todo: replace body-accent-color with secondary-color
--#{$prefix}secondary-color: #{$body-secondary-color};
--#{$prefix}secondary-color-rgb: #{to-rgb($body-secondary-color)};
--#{$prefix}secondary-bg: #{$body-secondary-bg};
--#{$prefix}secondary-bg-rgb: #{to-rgb($body-secondary-bg)};

--#{$prefix}tertiary-color: #{$body-tertiary-color};
--#{$prefix}tertiary-color-rgb: #{to-rgb($body-tertiary-color)};
--#{$prefix}tertiary-bg: #{$body-tertiary-bg};
--#{$prefix}tertiary-bg-rgb: #{to-rgb($body-tertiary-bg)};

@if $body-text-align != null {
--#{$prefix}body-text-align: #{$body-text-align};
}
--#{$prefix}body-bg: #{$body-bg};
--#{$prefix}body-bg-rgb: #{to-rgb($body-bg)};
// scss-docs-end root-body-variables

--#{$prefix}heading-color: #{$headings-color};
--#{$prefix}link-color: #{$link-color};
--#{$prefix}link-hover-color: #{$link-hover-color};

--#{$prefix}code-color: #{$code-color};
--#{$prefix}highlight-bg: #{$mark-bg};

// scss-docs-start root-border-var
--#{$prefix}border-width: #{$border-width};
--#{$prefix}border-style: #{$border-style};
Expand All @@ -64,10 +85,56 @@
--#{$prefix}border-radius-pill: #{$border-radius-pill};
// scss-docs-end root-border-var

--#{$prefix}link-color: #{$link-color};
--#{$prefix}link-hover-color: #{$link-hover-color};
--#{$prefix}emphasis-color: #{$emphasis-color};
--#{$prefix}accent-color: #{$accent-color};
--#{$prefix}accent-bg: #{$accent-bg};
--#{$prefix}accent-border: #{$accent-border};

--#{$prefix}code-color: #{$code-color};
// TODO: move to form components? or make global?
--#{$prefix}form-control-bg: var(--#{$prefix}body-bg);
--#{$prefix}form-control-disabled-bg: var(--#{$prefix}secondary-bg);
}

--#{$prefix}highlight-bg: #{$mark-bg};
[data-bs-theme="dark"] {
// --#{$prefix}primary: #{$blue-300};
// --#{$prefix}success: #{$green-300};
// --#{$prefix}danger: #{$red-300};
// --#{$prefix}warning: #{$yellow-300};
// --#{$prefix}info: #{$cyan-300};

// --#{$prefix}primary-rgb: #{to-rgb($blue-300)};
// --#{$prefix}success-rgb: #{to-rgb($green-300)};
// --#{$prefix}danger-rgb: #{to-rgb($red-300)};
// --#{$prefix}warning-rgb: #{to-rgb($yellow-300)};
// --#{$prefix}info-rgb: #{to-rgb($cyan-300)};

--#{$prefix}body-color: #{$body-color-dark};
--#{$prefix}body-color-rgb: #{to-rgb($body-color-dark)};
--#{$prefix}body-bg: #{$body-bg-dark};
--#{$prefix}body-bg-rgb: #{to-rgb($body-bg-dark)};

--#{$prefix}secondary-color: #{$body-secondary-color-dark};
// --#{$prefix}secondary-color-rgb: #{to-rgb($body-secondary-color-dark)};
--#{$prefix}secondary-bg: #{$body-secondary-bg-dark};
--#{$prefix}secondary-bg-rgb: #{to-rgb($body-secondary-bg-dark)};

--#{$prefix}tertiary-color: #{$body-tertiary-color-dark};
// --#{$prefix}tertiary-color-rgb: #{to-rgb($body-tertiary-color-dark)};
--#{$prefix}tertiary-bg: #{$body-tertiary-bg-dark};
--#{$prefix}tertiary-bg-rgb: #{to-rgb($body-tertiary-bg-dark)};

--#{$prefix}emphasis-color: #{$emphasis-color-dark};
--#{$prefix}accent-color: #{$accent-color-dark};
--#{$prefix}accent-bg: #{$accent-bg-dark};
--#{$prefix}accent-border: #{$accent-border-dark};

--#{$prefix}heading-color: #{$headings-color-dark};

--#{$prefix}link-color: #{$link-color-dark};
--#{$prefix}link-hover-color: #{$link-hover-color-dark};

--#{$prefix}code-color: #{$code-color-dark};

--#{$prefix}border-color: #{$border-color-dark};
--#{$prefix}border-color-translucent: #{$border-color-translucent-dark};
}
6 changes: 5 additions & 1 deletion scss/_utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ $utilities: map-merge(
"muted": $text-muted,
"black-50": rgba($black, .5), // deprecated
"white-50": rgba($white, .5), // deprecated
"body-secondary": var(--#{$prefix}secondary-color),
"body-tertiary": var(--#{$prefix}tertiary-color),
"reset": inherit,
)
)
Expand All @@ -563,7 +565,9 @@ $utilities: map-merge(
values: map-merge(
$utilities-bg-colors,
(
"transparent": transparent
"transparent": transparent,
"body-secondary": rgba(var(--#{$prefix}secondary-bg-rgb), var(--#{$prefix}bg-opacity)),
"body-tertiary": rgba(var(--#{$prefix}tertiary-bg-rgb), var(--#{$prefix}bg-opacity)),
)
)
),
Expand Down
26 changes: 26 additions & 0 deletions scss/_variables-dark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Dark color mode variables
//
// Custom variables for the `[data-bs-theme="dark"]` theme. Use this as a starting point for your own custom color modes by creating a new theme-specific file like `_variables-dark.scss` and adding the variables you need.

$body-color-dark: $gray-500 !default;
$body-bg-dark: $gray-900 !default;
$body-secondary-color-dark: rgba($body-color-dark, .75) !default;
$body-secondary-bg-dark: $gray-800 !default;
$body-tertiary-color-dark: rgba($body-color-dark, .5) !default;
$body-tertiary-bg-dark: mix($gray-800, $gray-900, 50%) !default;
$emphasis-color-dark: $white !default;
$accent-bg-dark: $blue-300 !default;
$accent-color-dark: color-contrast($accent-bg-dark) !default;
$accent-border-dark: $blue-400 !default;
$border-color-dark: $gray-700 !default;
$border-color-translucent-dark: rgba($white, .15) !default;
$headings-color-dark: #fff !default;
$link-color-dark: $blue-300 !default;
$link-hover-color-dark: $blue-200 !default;
$code-color-dark: $pink-300 !default;

$form-select-indicator-color-dark: $body-color-dark !default;
$form-select-indicator-dark: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='#{$form-select-indicator-color-dark}' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/></svg>") !default;

$form-switch-color-dark: rgba($white, .25) !default;
$form-switch-bg-image-dark: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='#{$form-switch-color-dark}'/></svg>") !default;
Loading

0 comments on commit 71f5b79

Please sign in to comment.