Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion scss/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Rows contain your columns.

:root {
#{$root-selector} { // Boosted mod: instead of `:root`
@each $name, $value in $grid-breakpoints {
--#{$prefix}breakpoint-#{$name}: #{$value};
}
Expand Down
4 changes: 2 additions & 2 deletions scss/_reboot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// Ability to the value of the root font sizes, affecting the value of `rem`.
// null by default, thus nothing is generated.

:root {
#{$root-selector} { // Boosted mod: instead of `:root`
// Boosted mod: Improve focus visibility when fixed/sticky header is used
// See https://caniuse.com/?search=scroll-padding
// scss-docs-start scroll-offset
Expand Down Expand Up @@ -61,7 +61,7 @@
// See https://developer.mozilla.org/fr/docs/Web/CSS/font-synthesis

// scss-docs-start reboot-body-rules
body {
#{$root-selector} > * { // Boosted mod: instead of `body`
position: relative; // Boosted mod: required for back-to-top component
margin: 0; // 1
font-family: var(--#{$prefix}body-font-family);
Expand Down
5 changes: 2 additions & 3 deletions scss/_root.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Boosted mod
:root,
#{$root-selector},
[data-bs-theme] {
color: var(--#{$prefix}body-color);
background-color: var(--#{$prefix}body-bg);
Expand All @@ -8,8 +8,7 @@
// Note that some of the following variables in `:root, [data-bs-theme="light"]` could be extracted into `:root` only selector since they are not modified by other color modes!
// End mod

:root,
[data-bs-theme="light"] {
@include color-mode(light, true) {
color-scheme: light; // Boosted mod

// Note: Custom variable values only support SassScript inside `#{}`.
Expand Down
1 change: 1 addition & 0 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ $color-mode-type: data !default; // `data` or `media-query`

// Prefix for :root CSS variables

$root-selector: ":root" !default; // Boosted mod
$variable-prefix: bs- !default; // Deprecated in v5.2.0 for the shorter `$prefix`
$prefix: $variable-prefix !default;
// fusv-disable
Expand Down
10 changes: 8 additions & 2 deletions scss/mixins/_color-mode.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@if $color-mode-type == "media-query" {
@if $root == true {
@media (prefers-color-scheme: $mode) {
:root {
#{$root-selector} {
@content;
}
}
Expand All @@ -12,10 +12,16 @@
@content;
}
}
} @else {
} @else if $root == true and $mode == light {
#{$root-selector},
[data-bs-theme="#{$mode}"] {
@content;
}
} @else {
[data-bs-theme="#{$mode}"],
#{$root-selector}[data-bs-theme="#{$mode}"] {
@content;
}
}
}
// scss-docs-end color-mode-mixin
6 changes: 4 additions & 2 deletions scss/tests/mixins/_color-modes.test.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
}
}
@include expect() {
[data-bs-theme=dark] .element {
[data-bs-theme=dark] .element,
:root[data-bs-theme=dark] .element {
color: var(--bs-primary-text-emphasis);
background-color: var(--bs-primary-bg-subtle);
}
[data-bs-theme=dark] {
[data-bs-theme=dark],
:root[data-bs-theme=dark] {
--custom-color: #757bd8; // Boosted mod: instead of `#3aff8`
}
}
Expand Down
25 changes: 25 additions & 0 deletions site/src/content/docs/customize/color-modes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,31 @@ For example, you can create a “blue theme” with the selector `data-bs-theme=
</div>
```

### Change the root selector

You can also change the root selector from where the theme variables are set. By default, it's set to `:root`, but you can change it to any other selector. This is useful if you want to apply the theme to another element, for instance in Angular where you can't access easily the `<html>` element.

```scss
$root-selector: "#app";

@include "boosted";
```

Outputs to:

```css
#app,
[data-bs-theme="light"] {
/* Your light mode variables definition */
}

[data-bs-theme="dark"] {
/* Your dark mode variables definition */
}

/* Further Boosted CSS */
```

## JavaScript

To allow visitors or users to toggle color modes, you’ll need to create a toggle element to control the `data-bs-theme` attribute on the root element, `<html>`. We’ve built a toggler in our documentation that initially defers to a user’s current system color mode, but provides an option to override that and pick a specific color mode.
Expand Down
6 changes: 6 additions & 0 deletions site/src/content/docs/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ aliases:
toc: true
---

## v5.3.8

### Core

- <span class="badge text-bg-warning">Warning</span> The root selector have been tweaked for more flexibility on JS frameworks. You can change it by defining `$root-selector`, before the Boosted custom call in Scss. More information in our [color modes documentation]([[docsref:/customize/color-modes#change-the-root-selector]]). Please don’t hesitate to contact us if you find any issue with it. Nonetheless, note that it shouldn’t change anything for a normal usage of Boosted.

## v5.3.7

## v5.3.6
Expand Down
2 changes: 1 addition & 1 deletion site/src/scss/_boosted.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// stylelint-disable selector-max-id
:root {
#{$root-selector} { // Boosted mod: instead of `:root`
scroll-padding-top: $offset-top * .5;

@include media-breakpoint-up(lg) {
Expand Down
2 changes: 1 addition & 1 deletion site/src/scss/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Boosted mod: the entire file is modified and is specific to Boosted

:root {
#{$root-selector} { // Boosted mod: instead of `:root`
// All available CSS vars and specific modifications for Boosted
--docsearch-primary-color: var(--bs-primary);
--docsearch-text-color: var(--bs-body-color);
Expand Down
2 changes: 1 addition & 1 deletion site/src/scss/_syntax.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Note: Bootstrap stops at --base0F

:root,
#{$root-selector}, // Boosted mod: instead of `:root`
[data-bs-theme="light"] {
--base00: #{$white};
--base01: #{$gray-700};
Expand Down
2 changes: 1 addition & 1 deletion site/src/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $bd-violet: lighten(saturate($bd-purple, 5%), 15%); // stylelint-disable-
$bd-gutter-x: .625rem; // Boosted mod
$bd-callout-variants: info, warning, danger !default;

:root,
#{$root-selector}, // Boosted mod: instead of `:root`
[data-bs-theme="light"] {
--bd-primary-light: #{$bd-primary-light}; // Boosted mod
// Boosted mod: no --bd-purple
Expand Down