diff --git a/site/assets/js/code-examples.js b/site/assets/js/code-examples.js index 3b03b17c49ca..0805aee9e839 100644 --- a/site/assets/js/code-examples.js +++ b/site/assets/js/code-examples.js @@ -20,10 +20,13 @@ const btnHtml = [ '
', - '
', - ' ', + '
', + ' html', + '
', + ' ', + '
', '
', '
' ].join('') @@ -35,6 +38,7 @@ if (!element.closest('.bd-example-snippet')) { element.insertAdjacentHTML('beforebegin', btnHtml) element.previousElementSibling.append(element) + element.previousElementSibling.querySelector('small').textContent = element.querySelector('pre > code').getAttribute('data-lang') } }) diff --git a/site/assets/js/snippets.js b/site/assets/js/snippets.js index 66c7a005ce21..fc5b328df68b 100644 --- a/site/assets/js/snippets.js +++ b/site/assets/js/snippets.js @@ -52,11 +52,13 @@ // Instantiate all toasts in docs pages only document.querySelectorAll('.bd-example .toast') .forEach(toastNode => { - const toast = new bootstrap.Toast(toastNode, { - autohide: false - }) + if (toastNode.id !== 'liveToast') { + const toast = new bootstrap.Toast(toastNode, { + autohide: false + }) - toast.show() + toast.show() + } }) // Instantiate all toasts in docs pages only @@ -119,6 +121,27 @@ } }) + // ------------------------------- + // Forms + // ------------------------------- + // Modal 'Varying modal content' example in docs and StackBlitz + // js-docs-start forms-validation + // Fetch all the forms we want to apply custom Bootstrap validation styles to + const forms = document.querySelectorAll('.needs-validation') + + // Loop over them and prevent submission + Array.from(forms).forEach(form => { + form.addEventListener('submit', event => { + if (!form.checkValidity()) { + event.preventDefault() + event.stopPropagation() + } + + form.classList.add('was-validated') + }, false) + }) + // js-docs-end forms-validation + // ------------------------------- // Links // ------------------------------- diff --git a/site/assets/scss/_callouts.scss b/site/assets/scss/_callouts.scss index c3e5629a8e3f..abc5780f7bdd 100644 --- a/site/assets/scss/_callouts.scss +++ b/site/assets/scss/_callouts.scss @@ -24,10 +24,6 @@ + .bd-callout { margin-top: -.25rem; } - - .highlight { - background-color: rgba($black, .05); - } } // Variations diff --git a/site/assets/scss/_clipboard-js.scss b/site/assets/scss/_clipboard-js.scss index de709d09ba7f..3ade1db6e581 100644 --- a/site/assets/scss/_clipboard-js.scss +++ b/site/assets/scss/_clipboard-js.scss @@ -23,7 +23,7 @@ padding: .5em; line-height: 1; color: var(--bs-body-color); - background-color: var(--bd-pre-bg); + background-color: transparent; border: 0; @include border-radius(.25rem); diff --git a/site/assets/scss/_component-examples.scss b/site/assets/scss/_component-examples.scss index 1d8caed666cc..30d198e46db8 100644 --- a/site/assets/scss/_component-examples.scss +++ b/site/assets/scss/_component-examples.scss @@ -12,6 +12,19 @@ margin-left: 0; border-width: 1px; @include border-radius(var(--bs-border-radius)); + + > :first-child { + @include border-top-radius(calc(var(--bs-border-radius) - 1px)); + } + + > :last-child { + @include border-bottom-radius(calc(var(--bs-border-radius) - 1px)); + } + + // stylelint-disable-next-line selector-max-universal + > * + * { + border-top: 1px solid var(--bs-border-color); + } } } @@ -31,7 +44,10 @@ margin-right: 0; margin-left: 0; border-width: 1px; - @include border-radius(var(--bs-border-radius)); + + &:not(:first-child) { + @include border-radius(var(--bs-border-radius)); + } } + p { @@ -353,7 +369,6 @@ @include media-breakpoint-up(md) { padding: .75rem 1.25rem; - @include border-radius(calc(var(--bs-border-radius) - 1px)); } @include media-breakpoint-up(lg) { @@ -381,10 +396,6 @@ .highlight-toolbar { background-color: var(--bd-pre-bg); - - + .highlight { - @include border-top-radius(0); - } } .bd-file-ref { diff --git a/site/assets/scss/_masthead.scss b/site/assets/scss/_masthead.scss index d74d1ec24941..32df8a49f81a 100644 --- a/site/assets/scss/_masthead.scss +++ b/site/assets/scss/_masthead.scss @@ -21,10 +21,27 @@ } .bd-code-snippet { + --bs-border-radius: .5rem; + + position: relative; margin: 0; - border-color: var(--bs-border-color-translucent); border-width: 1px; - @include border-radius(.5rem); + } + + .highlight-toolbar { + padding: 0 !important; // stylelint-disable-line declaration-no-important + + > :first-child { + display: none; + } + + > :last-child { + position: absolute; + top: 50%; + right: .75rem; + z-index: 1; + transform: translateY(-50%); + } } .highlight { @@ -34,7 +51,8 @@ text-overflow: ellipsis; white-space: nowrap; background-color: rgba(var(--bs-body-color-rgb), .075); - @include border-radius(calc(.5rem - 1px)); + border: 0; + @include border-radius(subtract(var(--bs-border-radius), 1px)); @include media-breakpoint-up(lg) { padding-right: 4rem; @@ -46,12 +64,6 @@ overflow: hidden; } } - .btn-clipboard { - position: absolute; - top: -.625rem; - right: 0; - background-color: transparent; - } #carbonads { // stylelint-disable-line selector-max-id margin-inline: auto; diff --git a/site/content/docs/5.3/components/buttons.md b/site/content/docs/5.3/components/buttons.md index 83a61382a310..967bd0f84e40 100644 --- a/site/content/docs/5.3/components/buttons.md +++ b/site/content/docs/5.3/components/buttons.md @@ -243,9 +243,9 @@ Each `.btn-*` modifier class updates the appropriate CSS variables to minimize a Here's an example of building a custom `.btn-*` modifier class as we do for the buttons unique to our docs by reassigning Bootstrap's CSS variables with a mixture of our own CSS and Sass variables. -
+{{< example show_markup=false >}} -
+{{< /example >}} {{< scss-docs name="btn-css-vars-example" file="site/assets/scss/_buttons.scss" >}} diff --git a/site/content/docs/5.3/components/dropdowns.md b/site/content/docs/5.3/components/dropdowns.md index 6e3811f1f132..32a5176662b1 100644 --- a/site/content/docs/5.3/components/dropdowns.md +++ b/site/content/docs/5.3/components/dropdowns.md @@ -59,84 +59,79 @@ While ` - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
+{{< example skip=ul >}} + +
+ + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    +
    + + +
    + + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    +
    + + +
    + + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    +
    + + +
    + + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    +
    + + +
    + + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    -```html
    - - +
    -``` +{{< /example >}} ### Split button @@ -144,208 +139,159 @@ Similarly, create split button dropdowns with virtually the same markup as singl We use this extra class to reduce the horizontal `padding` on either side of the caret by 25% and remove the `margin-left` that's added for regular button dropdowns. Those extra changes keep the caret centered in the split button and provide a more appropriately sized hit area next to the main button. -
    -
    - - - -
    -
    - - - -
    -
    - - - -
    -
    - - - -
    -
    - - - -
    -
    - - - -
    +{{< example skip=ul >}} + +
    + + + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    -```html - + +
    + + + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    +
    + +
    - + + + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    +
    + + +
    + + + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    +
    + + +
    + + + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    +
    + + +
    + - +
    -``` +{{< /example >}} ## Sizing Button dropdowns work with buttons of all sizes, including default and split dropdown buttons. -
    -
    - - -
    -
    - - - -
    -
    - -```html +{{< example skip="ul" >}}
    - + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    - + - -
    -``` - -
    -
    - - -
    -
    - - - -
    + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    +{{< /example >}} -```html +{{< example skip="ul" >}} +
    - + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    - + - + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    -``` +{{< /example >}} ## Dark dropdowns @@ -424,45 +370,19 @@ Make the dropdown menu centered below the toggle with `.dropdown-center` on the Trigger dropdown menus above elements by adding `.dropup` to the parent element. -
    - -
    - - - -
    -
    - -```html +{{< example skip=ul >}}
    - + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    @@ -473,11 +393,15 @@ Trigger dropdown menus above elements by adding `.dropup` to the parent element. - + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    -``` +{{< /example >}} ### Dropup centered @@ -500,45 +424,19 @@ Make the dropup menu centered above the toggle with `.dropup-center` on the pare Trigger dropdown menus at the right of the elements by adding `.dropend` to the parent element. -
    -
    - - -
    -
    - - - -
    -
    - -```html +{{< example skip=ul >}}
    - + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    @@ -549,55 +447,33 @@ Trigger dropdown menus at the right of the elements by adding `.dropend` to the - + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    -``` +{{< /example >}} ### Dropstart Trigger dropdown menus at the left of the elements by adding `.dropstart` to the parent element. -
    -
    - - -
    -
    - - - -
    -
    - -```html +{{< example skip=ul >}}
    - + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    @@ -605,14 +481,18 @@ Trigger dropdown menus at the left of the elements by adding `.dropstart` to the - + +
  • Action
  • +
  • Another action
  • +
  • Something else here
  • +
  • +
  • Separated link
  • +
    -``` +{{< /example >}} ## Menu items diff --git a/site/content/docs/5.3/components/list-group.md b/site/content/docs/5.3/components/list-group.md index 598bb38d6026..10418e036c7c 100644 --- a/site/content/docs/5.3/components/list-group.md +++ b/site/content/docs/5.3/components/list-group.md @@ -335,55 +335,34 @@ Loop that generates the modifier classes with an overriding of CSS variables. Use the tab JavaScript plugin—include it individually or through the compiled `bootstrap.js` file—to extend our list group to create tabbable panes of local content. -
    -
    -
    - -
    -
    - -
    -
    -
    - -```html +{{< example >}}
    -``` +{{< /example >}} ### Using data attributes diff --git a/site/content/docs/5.3/components/modal.md b/site/content/docs/5.3/components/modal.md index ba2a51a6e320..25c59c235666 100644 --- a/site/content/docs/5.3/components/modal.md +++ b/site/content/docs/5.3/components/modal.md @@ -38,28 +38,8 @@ Keep reading for demos and usage guidelines. Below is a _static_ modal example (meaning its `position` and `display` have been overridden). Included are the modal header, modal body (required for `padding`), and modal footer (optional). We ask that you include modal headers with dismiss actions whenever possible, or provide another explicit dismiss action. -
    - -
    - -```html -