2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-11 18:02:28 +03:00

Add Sass docs (variables, mixins, and loops) to most pages (#32747)

* WIP: Mention variables, mixins, and loops in docs

* Add Sass sections to component pages

* add sass docs for forms and content

* Update buttons.md

* Remove empty mixins sections

* Massive update to utilities and some consistency changes

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
Mark Otto
2021-02-10 19:29:59 -08:00
committed by GitHub
parent e50c11b8c6
commit 4c7a3e8adf
100 changed files with 942 additions and 480 deletions
@@ -104,3 +104,9 @@ Add `.accordion-flush` to remove the default `background-color`, some borders, a
## Accessibility
Please read the [collapse accessibility section]({{< docsref "/components/collapse#accessibility" >}}) for more information.
## Sass
### Variables
{{< scss-docs name="accordion-variables" file="scss/_variables.scss" >}}
@@ -71,6 +71,24 @@ You can see this in action with a live demo:
When an alert is dismissed, the element is completely removed from the page structure. If a keyboard user dismisses the alert using the close button, their focus will suddenly be lost and, depending on the browser, reset to the start of the page/document. For this reason, we recommend including additional JavaScript that listens for the `closed.bs.alert` event and programmatically sets `focus()` to the most appropriate location in the page. If you're planning to move focus to a non-interactive element that normally does not receive focus, make sure to add `tabindex="-1"` to the element.
{{< /callout >}}
## Sass
### Variables
{{< scss-docs name="alert-variables" file="scss/_variables.scss" >}}
### Variant mixin
Used in combination with `$theme-colors` to create contextual modifier classes for our alerts.
{{< scss-docs name="alert-variant-mixin" file="scss/mixins/_alert.scss" >}}
### Loop
Loop that generates the modifier classes with the `alert-variant()` mixin.
{{< scss-docs name="alert-modifiers" file="scss/_alert.scss" >}}
## JavaScript behavior
### Triggers
@@ -63,3 +63,9 @@ Use the `.rounded-pill` utility class to make badges more rounded with a larger
<span class="badge rounded-pill bg-{{ .name }}{{ with .contrast_color }} text-{{ . }}{{ end }}">{{ .name | title }}</span>{{- end -}}
{{< /badge.inline >}}
{{< /example >}}
## Sass
### Variables
{{< scss-docs name="badge-variables" file="scss/_variables.scss" >}}
@@ -88,3 +88,9 @@ $breadcrumb-divider: none;
Since breadcrumbs provide a navigation, it's a good idea to add a meaningful label such as `aria-label="breadcrumb"` to describe the type of navigation provided in the `<nav>` element, as well as applying an `aria-current="page"` to the last item of the set to indicate that it represents the current page.
For more information, see the [WAI-ARIA Authoring Practices for the breadcrumb pattern](https://www.w3.org/TR/wai-aria-practices/#breadcrumb).
## Sass
### Variables
{{< scss-docs name="breadcrumb-variables" file="scss/_variables.scss" >}}
@@ -205,3 +205,25 @@ buttons.forEach(function (button) {
button.toggle()
})
```
## Sass
### Variables
{{< scss-docs name="btn-variables" file="scss/_variables.scss" >}}
### Mixins
There are three mixins for buttons: button and button outline variant mixins (both based on `$theme-colors`), plus a button size mixin.
{{< scss-docs name="btn-variant-mixin" file="scss/mixins/_buttons.scss" >}}
{{< scss-docs name="btn-outline-variant-mixin" file="scss/mixins/_buttons.scss" >}}
{{< scss-docs name="btn-size-mixin" file="scss/mixins/_buttons.scss" >}}
### Loops
Button variants (for regular and outline buttons) use their respective mixins with our `$theme-colors` map to generate the modifier classes in `scss/_buttons.scss`.
{{< scss-docs name="btn-variant-loops" file="scss/_buttons.scss" >}}
+6
View File
@@ -721,3 +721,9 @@ Just like with card groups, card footers will automatically line up.
### Masonry
In `v4` we used a CSS-only technique to mimic the behavior of [Masonry](https://masonry.desandro.com/)-like columns, but this technique came with lots of unpleasant [side effects](https://github.com/twbs/bootstrap/pull/28922). If you want to have this type of layout in `v5`, you can just make use of Masonry plugin. **Masonry is not included in Bootstrap**, but we've made a [demo example]({{< docsref "/examples/masonry" >}}) to help you get started.
## Sass
### Variables
{{< scss-docs name="card-variables" file="scss/_variables.scss" >}}
+10 -4
View File
@@ -279,6 +279,16 @@ Add `.carousel-dark` to the `.carousel` for darker controls, indicators, and cap
</div>
{{< /example >}}
## Custom transition
The transition duration of `.carousel-item` can be changed with the `$carousel-transition-duration` Sass variable before compiling or custom styles if you're using the compiled CSS. If multiple transitions are applied, make sure the transform transition is defined first (eg. `transition: transform 2s ease, opacity .5s ease-out`).
## Sass
### Variables
{{< scss-docs name="carousel-variables" file="scss/_variables.scss" >}}
## Usage
### Via data attributes
@@ -446,7 +456,3 @@ myCarousel.addEventListener('slide.bs.carousel', function () {
// do something...
})
```
### Change transition duration
The transition duration of `.carousel-item` can be changed with the `$carousel-transition-duration` Sass variable before compiling or custom styles if you're using the compiled CSS. If multiple transitions are applied, make sure the transform transition is defined first (eg. `transition: transform 2s ease, opacity .5s ease-out`).
@@ -30,3 +30,9 @@ Change the default `.btn-close` to be white with the `.btn-close-white` class. T
<button type="button" class="btn-close btn-close-white" aria-label="Close"></button>
<button type="button" class="btn-close btn-close-white" disabled aria-label="Close"></button>
{{< /example >}}
## Sass
### Variables
{{< scss-docs name="close-variables" file="scss/_variables.scss" >}}
@@ -77,6 +77,18 @@ If your control element is targeting a single collapsible element i.e. the `
Note that Bootstrap's current implementation does not cover the various *optional* keyboard interactions described in the [WAI-ARIA Authoring Practices 1.1 accordion pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#accordion) - you will need to include these yourself with custom JavaScript.
## Sass
### Variables
{{< scss-docs name="collapse-transition" file="scss/_variables.scss" >}}
### Classes
Collapse transition classes can be found in `scss/_transitions.scss` as these are shared across multiple components (collapse and accordion).
{{< scss-docs name="collapse-classes" file="scss/_transitions.scss" >}}
## Usage
The collapse plugin utilizes a few classes to handle the heavy lifting:
@@ -903,6 +903,28 @@ Use `data-bs-offset` or `data-bs-reference` to change the location of the dropdo
</div>
{{< /example >}}
## Sass
### Variables
Variables for all dropdowns:
{{< scss-docs name="dropdown-variables" file="scss/_variables.scss" >}}
Variables for the [dark dropdown](#dark-dropdowns):
{{< scss-docs name="dropdown-dark-variables" file="scss/_variables.scss" >}}
Variables for the CSS-based carets that indicate a dropdown's interactivity:
{{< scss-docs name="caret-variables" file="scss/_variables.scss" >}}
### Mixins
Mixins are used to generate the CSS-based carets and can be found in `scss/mixins/_caret.scss`.
{{< scss-docs name="caret-mixins" file="scss/mixins/_caret.scss" >}}
## Usage
Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the `.show` class on the parent `.dropdown-menu`. The `data-bs-toggle="dropdown"` attribute is relied on for closing dropdown menus at an application level, so it's a good idea to always use it.
@@ -254,6 +254,23 @@ And if you want `<label>`s as the `.list-group-item` for large hit areas, you ca
</div>
{{< /example >}}
## Sass
### Variables
{{< scss-docs name="list-group-variables" file="scss/_variables.scss" >}}
### Mixins
Used in combination with `$theme-colors` to generate the [contextual variant classes](#contextual-classes) for `.list-group-item`s.
{{< scss-docs name="list-group-mixin" file="scss/mixins/_list-group.scss" >}}
### Loop
Loop that generates the modifier classes with the `list-group-item-variant()` mixin.
{{< scss-docs name="list-group-modifiers" file="scss/_list-group.scss" >}}
## JavaScript behavior
+12
View File
@@ -793,6 +793,18 @@ Another override is the option to pop up a modal that covers the user viewport,
</div>
</div>
## Sass
### Variables
{{< scss-docs name="modal-variables" file="scss/_variables.scss" >}}
### Loop
[Responsive fullscreen modals](#fullscreen-modal) are generated via the `$breakpoints` map and a loop in `scss/_modal.scss`.
{{< scss-docs name="modal-fullscreen-loop" file="scss/_modal.scss" >}}
## Usage
The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds `.modal-open` to the `<body>` to override default scrolling behavior and generates a `.modal-backdrop` to provide a click area for dismissing shown modals when clicking outside the modal.
@@ -646,3 +646,17 @@ Sometimes you want to use the collapse plugin to trigger a container element for
{{< /example >}}
When you do this, we recommend including additional JavaScript to move the focus programmatically to the container when it is opened. Otherwise, keyboard users and users of assistive technologies will likely have a hard time finding the newly revealed content - particularly if the container that was opened comes *before* the toggler in the document's structure. We also recommend making sure that the toggler has the `aria-controls` attribute, pointing to the `id` of the content container. In theory, this allows assistive technology users to jump directly from the toggler to the container it controlsbut support for this is currently quite patchy.
## Sass
### Variables
{{< scss-docs name="navbar-variables" file="scss/_variables.scss" >}}
{{< scss-docs name="navbar-theme-variables" file="scss/_variables.scss" >}}
### Loop
[Responsive navbar expand/collapse classes](#responsive-behaviors) (e.g., `.navbar-expand-lg`) are combined with the `$breakpoints` map and generated through a loop in `scss/_navbar.scss`.
{{< scss-docs name="navbar-expand-loop" file="scss/_navbar.scss" >}}
@@ -304,6 +304,12 @@ Add dropdown menus with a little extra HTML and the [dropdowns JavaScript plugin
</ul>
{{< /example >}}
## Sass
### Variables
{{< scss-docs name="nav-variables" file="scss/_variables.scss" >}}
## JavaScript behavior
Use the tab JavaScript plugin—include it individually or through the compiled `bootstrap.js` file—to extend our navigational tabs and pills to create tabbable panes of local content.
@@ -155,3 +155,13 @@ Change the alignment of pagination components with [flexbox utilities]({{< docsr
</ul>
</nav>
{{< /example >}}
## Sass
### Variables
{{< scss-docs name="pagination-variables" file="scss/_variables.scss" >}}
### Mixins
{{< scss-docs name="pagination-mixin" file="scss/mixins/_pagination.scss" >}}
@@ -109,6 +109,12 @@ For disabled popover triggers, you may also prefer `data-bs-trigger="hover focus
</span>
{{< /example >}}
## Sass
### Variables
{{< scss-docs name="popover-variables" file="scss/_variables.scss" >}}
## Usage
Enable popovers via JavaScript:
@@ -137,3 +137,15 @@ The striped gradient can also be animated. Add `.progress-bar-animated` to `.pro
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div>
</div>
```
## Sass
### Variables
{{< scss-docs name="progress-variables" file="scss/_variables.scss" >}}
### Keyframes
Used for creating the CSS animations for `.progress-bar-animated`. Included in `scss/_progress-bar.scss`.
{{< scss-docs name="progress-keyframes" file="scss/_progress.scss" >}}
@@ -171,6 +171,20 @@ Use spinners within buttons to indicate an action is currently processing or tak
</button>
{{< /example >}}
## Sass
### Variables
{{< scss-docs name="spinner-variables" file="scss/_variables.scss" >}}
### Keyframes
Used for creating the CSS animations for our spinners. Included in `scss/_spinners.scss`.
{{< scss-docs name="spinner-border-keyframes" file="scss/_spinners.scss" >}}
{{< scss-docs name="spinner-grow-keyframes" file="scss/_spinners.scss" >}}
[color]: {{< docsref "/utilities/colors" >}}
[display]: {{< docsref "/utilities/display" >}}
+6 -2
View File
@@ -304,9 +304,13 @@ When using `autohide: false`, you must add a close button to allow users to dism
</div>
{{< /example >}}
## JavaScript behavior
## Sass
### Usage
### Variables
{{< scss-docs name="toast-variables" file="scss/_variables.scss" >}}
## Usage
Initialize toasts via JavaScript:
@@ -96,6 +96,12 @@ With an SVG:
</a>
</div>
## Sass
### Variables
{{< scss-docs name="tooltip-variables" file="scss/_variables.scss" >}}
## Usage
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element.