Scope docs CSS to custom layer

This commit is contained in:
Mark Otto 2025-09-28 09:50:28 -07:00
parent 2fada13166
commit 35cb124035
21 changed files with 1081 additions and 1056 deletions

View File

@ -55,8 +55,10 @@ try {
<Code containerClass="bd-example-snippet bd-code-snippet bd-file-ref" code={content} lang="js"> <Code containerClass="bd-example-snippet bd-code-snippet bd-file-ref" code={content} lang="js">
<div slot="pre" class="d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-bottom"> <div slot="pre" class="d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-bottom">
<a <a
class="font-monospace link-secondary link-underline-secondary link-underline-opacity-0 link-underline-opacity-100-hover small" class="text-decoration-none color-body"
href={`${getConfig().repo}/blob/v${getConfig().current_version}/${file}`.replaceAll('\\', '/')} href={`${getConfig().repo}/blob/v${getConfig().current_version}/${file}`.replaceAll('\\', '/')}
target="_blank"
rel="noopener noreferrer"
> >
{file} {file}
</a> </a>

View File

@ -57,8 +57,10 @@ try {
<Code containerClass="bd-example-snippet bd-file-ref" code={content} lang="scss"> <Code containerClass="bd-example-snippet bd-file-ref" code={content} lang="scss">
<div slot="pre" class="d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-bottom"> <div slot="pre" class="d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-bottom">
<a <a
class="font-monospace link-secondary link-underline-secondary link-underline-opacity-0 link-underline-opacity-100-hover small" class="text-decoration-none color-body"
href={`${getConfig().repo}/blob/v${getConfig().current_version}/${file}`.replaceAll('\\', '/')} href={`${getConfig().repo}/blob/v${getConfig().current_version}/${file}`.replaceAll('\\', '/')}
target="_blank"
rel="noopener noreferrer"
> >
{file} {file}
</a> </a>

View File

@ -8,6 +8,7 @@
// Carbon ads // Carbon ads
// //
@layer custom {
#carbonads { #carbonads {
position: static; position: static;
max-width: 400px; max-width: 400px;
@ -64,3 +65,4 @@
margin-top: .75rem; margin-top: .75rem;
color: var(--bs-fg-3) !important; color: var(--bs-fg-3) !important;
} }
}

View File

@ -1,6 +1,7 @@
@use "../../../scss/variables" as *; @use "../../../scss/variables" as *;
@use "../../../scss/mixins/transition" as *; @use "../../../scss/mixins/transition" as *;
@layer custom {
.anchor-link { .anchor-link {
padding: 0 .175rem; padding: 0 .175rem;
font-weight: 400; font-weight: 400;
@ -22,3 +23,4 @@
opacity: 1; opacity: 1;
} }
} }
}

View File

@ -7,6 +7,7 @@
// Brand guidelines // Brand guidelines
// //
@layer custom {
// Logo series wrapper // Logo series wrapper
.bd-brand-logos { .bd-brand-logos {
color: $bd-violet; color: $bd-violet;
@ -63,3 +64,4 @@
height: 6rem; height: 6rem;
} }
} }
}

View File

@ -3,10 +3,7 @@
@use "../../../scss/colors" as *; @use "../../../scss/colors" as *;
@use "variables" as *; @use "variables" as *;
// Buttons @layer custom {
//
// Custom buttons for the docs.
// scss-docs-start btn-css-vars-example // scss-docs-start btn-css-vars-example
.btn-bd-primary { .btn-bd-primary {
--bs-btn-font-weight: 600; --bs-btn-font-weight: 600;
@ -55,3 +52,4 @@
padding: .8125rem 2rem; padding: .8125rem 2rem;
} }
}

View File

@ -7,6 +7,7 @@
// Callouts // Callouts
// //
@layer custom {
.bd-callout { .bd-callout {
--#{$prefix}link-color: var(--bd-callout-color); --#{$prefix}link-color: var(--bd-callout-color);
--#{$prefix}link-hover-color: var(--bd-callout-color); --#{$prefix}link-hover-color: var(--bd-callout-color);
@ -51,3 +52,4 @@
--bd-callout-border: var(--bs-#{$variant}-border); --bd-callout-border: var(--bs-#{$variant}-border);
} }
} }
}

View File

@ -5,6 +5,7 @@
// //
// JS-based `Copy` buttons for code snippets. // JS-based `Copy` buttons for code snippets.
@layer custom {
.bd-clipboard, .bd-clipboard,
.bd-edit { .bd-edit {
position: relative; position: relative;
@ -42,6 +43,7 @@
.btn-clipboard { .btn-clipboard {
position: relative; position: relative;
z-index: 2; z-index: 2;
margin-top: 1.25rem; margin-top: .5rem;
margin-right: .75rem; margin-right: .5rem;
}
} }

View File

@ -346,7 +346,7 @@
.highlight { .highlight {
position: relative; position: relative;
padding: .75rem ($bd-gutter-x * .5); padding: .75rem ($bd-gutter-x * .5);
background-color: var(--bs-bg-1); background-color: var(--bd-pre-bg);
@include media-breakpoint-up(md) { @include media-breakpoint-up(md) {
padding: 1rem; padding: 1rem;

View File

@ -8,6 +8,7 @@
// Bootstrap docs content theming // Bootstrap docs content theming
// //
@layer custom {
.bd-content { .bd-content {
> h2, > h2,
> h3, > h3,
@ -119,21 +120,6 @@
min-width: 280px; min-width: 280px;
} }
.table-swatches {
th {
color: var(--bs-emphasis-color);
}
td code {
white-space: nowrap;
}
// Astro HTML parser adds extra <p> tags to the content
td p {
margin: 0;
}
}
.bd-title { .bd-title {
--bs-heading-color: var(--bs-emphasis-color); --bs-heading-color: var(--bs-emphasis-color);
@include font-size(3rem); @include font-size(3rem);
@ -193,3 +179,4 @@
} }
} }
// scss-docs-end custom-color-mode // scss-docs-end custom-color-mode
}

View File

@ -2,6 +2,7 @@
// Footer // Footer
// //
@layer custom {
.bd-footer { .bd-footer {
a { a {
color: var(--bs-body-color); color: var(--bs-body-color);
@ -14,3 +15,4 @@
} }
} }
} }
}

View File

@ -2,6 +2,7 @@
@use "../../../scss/layout/breakpoints" as *; @use "../../../scss/layout/breakpoints" as *;
@use "variables" as *; @use "variables" as *;
@layer custom {
.bd-gutter { .bd-gutter {
--bs-gutter-x: #{$bd-gutter-x}; --bs-gutter-x: #{$bd-gutter-x};
} }
@ -14,6 +15,10 @@
grid-template-columns: 1fr 5fr; grid-template-columns: 1fr 5fr;
gap: $grid-gutter-width; gap: $grid-gutter-width;
} }
@include media-breakpoint-up(xl) {
gap: 2rem;
}
} }
.bd-sidebar { .bd-sidebar {
@ -59,3 +64,4 @@
grid-area: content; grid-area: content;
min-width: 1px; // Fix width when bd-content contains a `<pre>` https://github.com/twbs/bootstrap/issues/25410 min-width: 1px; // Fix width when bd-content contains a `<pre>` https://github.com/twbs/bootstrap/issues/25410
} }
}

View File

@ -7,6 +7,7 @@
@use "../../../scss/mixins/transition" as *; @use "../../../scss/mixins/transition" as *;
@use "../../../scss/mixins/color-mode" as *; @use "../../../scss/mixins/color-mode" as *;
@layer custom {
.bd-masthead { .bd-masthead {
--bd-pink-rgb: #{to-rgb($pink)}; --bd-pink-rgb: #{to-rgb($pink)};
padding: 3rem 0; padding: 3rem 0;
@ -132,3 +133,4 @@
// } // }
// } // }
// } // }
}

View File

@ -6,6 +6,7 @@
@use "../../../scss/layout/breakpoints" as *; @use "../../../scss/layout/breakpoints" as *;
@use "../../../scss/vendor/rfs" as *; @use "../../../scss/vendor/rfs" as *;
@layer custom {
.bd-navbar { .bd-navbar {
padding: .75rem 0; padding: .75rem 0;
background-color: transparent; background-color: transparent;
@ -140,3 +141,4 @@
box-shadow: 0 .5rem 1rem rgba($black, .15), inset 0 -1px 0 rgba($white, .15); box-shadow: 0 .5rem 1rem rgba($black, .15), inset 0 -1px 0 rgba($white, .15);
} }
} }
}

View File

@ -6,6 +6,7 @@
// Remember to update `site/_layouts/examples.html` too if this changes! // Remember to update `site/_layouts/examples.html` too if this changes!
@layer custom {
.bd-placeholder-img { .bd-placeholder-img {
@include font-size(1.125rem); @include font-size(1.125rem);
user-select: none; user-select: none;
@ -15,3 +16,4 @@
.bd-placeholder-img-lg { .bd-placeholder-img-lg {
@include font-size(3.5rem); @include font-size(3.5rem);
} }
}

View File

@ -1,5 +1,6 @@
// When navigating with the keyboard, prevent focus from landing behind the sticky header // When navigating with the keyboard, prevent focus from landing behind the sticky header
@layer custom {
main { main {
a, a,
button, button,
@ -14,3 +15,4 @@ main {
scroll-margin-bottom: 100px; scroll-margin-bottom: 100px;
} }
} }
}

View File

@ -31,6 +31,7 @@
--docsearch-muted-color: #7f8497; --docsearch-muted-color: #7f8497;
} }
@layer custom {
.bd-search { .bd-search {
position: relative; position: relative;
@ -177,3 +178,4 @@
.DocSearch-Logo svg .cls-2 { .DocSearch-Logo svg .cls-2 {
fill: var(--docsearch-logo-color); fill: var(--docsearch-logo-color);
} }
}

View File

@ -2,6 +2,7 @@
@use "../../../scss/layout/breakpoints" as *; @use "../../../scss/layout/breakpoints" as *;
@use "../../../scss/mixins/border-radius" as *; @use "../../../scss/mixins/border-radius" as *;
@layer custom {
.bd-sidebar { .bd-sidebar {
@include media-breakpoint-up(lg) { @include media-breakpoint-up(lg) {
position: sticky; position: sticky;
@ -72,3 +73,4 @@
font-weight: 600; font-weight: 600;
} }
} }
}

View File

@ -1,6 +1,7 @@
@use "../../../scss/colors" as *; @use "../../../scss/colors" as *;
@use "variables" as *; @use "variables" as *;
@layer custom {
.skippy { .skippy {
background-color: $bd-purple; background-color: $bd-purple;
@ -8,3 +9,4 @@
color: $white; color: $white;
} }
} }
}

View File

@ -43,6 +43,7 @@
} }
// Shell prompts // Shell prompts
@layer custom {
.language-bash .line::before, .language-bash .line::before,
.language-sh .line::before { .language-sh .line::before {
display: inline-block; display: inline-block;
@ -161,3 +162,4 @@
color: var(--base03); color: var(--base03);
} }
} }
}

View File

@ -4,6 +4,7 @@
// stylelint-disable selector-max-type, selector-no-qualifying-type // stylelint-disable selector-max-type, selector-no-qualifying-type
@layer custom {
.bd-toc { .bd-toc {
container-type: inline-size; container-type: inline-size;
@ -98,3 +99,4 @@
display: block !important; // stylelint-disable-line declaration-no-important display: block !important; // stylelint-disable-line declaration-no-important
} }
} }
}