diff options
Diffstat (limited to 'site/content/docs')
| -rw-r--r-- | site/content/docs/4.3/forms/validation.md | 28 | ||||
| -rw-r--r-- | site/content/docs/4.3/getting-started/theming.md | 39 | ||||
| -rw-r--r-- | site/content/docs/4.3/helpers/clearfix.md | 18 | ||||
| -rw-r--r-- | site/content/docs/4.3/helpers/embed.md | 21 |
4 files changed, 22 insertions, 84 deletions
diff --git a/site/content/docs/4.3/forms/validation.md b/site/content/docs/4.3/forms/validation.md index 2d6e2cab1..4613a6d74 100644 --- a/site/content/docs/4.3/forms/validation.md +++ b/site/content/docs/4.3/forms/validation.md @@ -370,24 +370,10 @@ Validation states can be customized via Sass with the `$form-validation-states` Please note that we do not recommend customizing these values without also modifying the `form-validation-state` mixin. -{{< highlight scss >}} -// Sass map from `_variables.scss` -// Override this and recompile your Sass to generate different states -$form-validation-states: ( - "valid": ( - "color": $form-feedback-valid-color, - "icon": $form-feedback-icon-valid - ), - "invalid": ( - "color": $form-feedback-invalid-color, - "icon": $form-feedback-icon-invalid - ) -); - -// Loop from `_forms.scss` -// Any modifications to the above Sass map will be reflected in your compiled -// CSS via this loop. -@each $state, $data in $form-validation-states { - @include form-validation-state($state, map-get($data, color), map-get($data, icon)); -} -{{< /highlight >}} +This is the Sass map from `_variables.scss`. Override this and recompile your Sass to generate different states: + +{{< scss-docs name="form-validation-states" file="scss/_variables.scss" >}} + +This is the loop from `forms/_validation.scss.scss`. Any modifications to the above Sass map will be reflected in your compiled CSS via this loop: + +{{< scss-docs name="form-validation-states-loop" file="scss/forms/_validation.scss" >}} diff --git a/site/content/docs/4.3/getting-started/theming.md b/site/content/docs/4.3/getting-started/theming.md index e6ed6c198..7e5b984b8 100644 --- a/site/content/docs/4.3/getting-started/theming.md +++ b/site/content/docs/4.3/getting-started/theming.md @@ -172,14 +172,7 @@ In Bootstrap 5, we've dropped the `color()`, `theme-color()` and `gray()` functi We also have a function for getting a particular _level_ of color. Negative level values will lighten the color, while higher levels will darken. -{{< highlight scss >}} -@function color-level($color: $primary, $level: 0) { - $color-base: if($level > 0, #000, #fff); - $level: abs($level); - - @return mix($color-base, $color, $level * $theme-color-interval); -} -{{< /highlight >}} +{{< scss-docs name="color-level" file="scss/_functions.scss" >}} In practice, you'd call the function and pass in two parameters: the name of the color from `$theme-colors` (e.g., primary or danger) and a numeric level. @@ -389,37 +382,17 @@ Many of Bootstrap's components and utilities are built with `@each` loops that i Many of Bootstrap's components are built with a base-modifier class approach. This means the bulk of the styling is contained to a base class (e.g., `.btn`) while style variations are confined to modifier classes (e.g., `.btn-danger`). These modifier classes are built from the `$theme-colors` map to make customizing the number and name of our modifier classes. -Here are two examples of how we loop over the `$theme-colors` map to generate modifiers to the `.alert` component and all our `.bg-*` background utilities. +Here are two examples of how we loop over the `$theme-colors` map to generate modifiers to the `.alert` and `.list-group` components. -{{< highlight scss >}} -// Generate alert modifier classes -@each $color, $value in $theme-colors { - .alert-#{$color} { - @include alert-variant(color-level($color, -10), color-level($color, -9), color-level($color, 6)); - } -} +{{< scss-docs name="alert-modifiers" file="scss/_alert.scss" >}} -// Generate `.bg-*` color utilities -@each $color, $value in $theme-colors { - @include bg-variant('.bg-#{$color}', $value); -} -{{< /highlight >}} +{{< scss-docs name="list-group-modifiers" file="scss/_list-group.scss" >}} ### Responsive -These Sass loops aren't limited to color maps, either. You can also generate responsive variations of your components or utilities. Take for example our responsive text alignment utilities where we mix an `@each` loop for the `$grid-breakpoints` Sass map with a media query include. - -{{< highlight scss >}} -@each $breakpoint in map-keys($grid-breakpoints) { - @include media-breakpoint-up($breakpoint) { - $infix: breakpoint-infix($breakpoint, $grid-breakpoints); +These Sass loops aren't limited to color maps, either. You can also generate responsive variations of your components. Take for example our responsive alignment of the dropdowns where we mix an `@each` loop for the `$grid-breakpoints` Sass map with a media query include. - .text#{$infix}-left { text-align: left !important; } - .text#{$infix}-right { text-align: right !important; } - .text#{$infix}-center { text-align: center !important; } - } -} -{{< /highlight >}} +{{< scss-docs name="responsive-breakpoints" file="scss/_dropdown.scss" >}} Should you need to modify your `$grid-breakpoints`, your changes will apply to all the loops iterating over that map. diff --git a/site/content/docs/4.3/helpers/clearfix.md b/site/content/docs/4.3/helpers/clearfix.md index bbae9a359..362fdc2b8 100644 --- a/site/content/docs/4.3/helpers/clearfix.md +++ b/site/content/docs/4.3/helpers/clearfix.md @@ -8,21 +8,19 @@ aliases: "/docs/4.3/helpers/" Easily clear `float`s by adding `.clearfix` **to the parent element**. Can also be used as a mixin. +Use in HTML: + {{< highlight html >}} <div class="clearfix">...</div> {{< /highlight >}} -{{< highlight scss >}} -// Mixin itself -@mixin clearfix() { - &::after { - display: block; - content: ""; - clear: both; - } -} +The mixin source code: -// Usage as a mixin +{{< scss-docs name="clearfix" file="scss/mixins/_clearfix.scss" >}} + +Use the mixin in SCSS: + +{{< highlight scss >}} .element { @include clearfix; } diff --git a/site/content/docs/4.3/helpers/embed.md b/site/content/docs/4.3/helpers/embed.md index dcc7ddad6..30914b2d6 100644 --- a/site/content/docs/4.3/helpers/embed.md +++ b/site/content/docs/4.3/helpers/embed.md @@ -50,23 +50,4 @@ Aspect ratios can be customized with modifier classes. By default the following Within `_variables.scss`, you can change the aspect ratios you want to use. Here's an example of the `$embed-responsive-aspect-ratios` map: -{{< highlight scss >}} -$embed-responsive-aspect-ratios: ( - "21by9": ( - x: 21, - y: 9 - ), - "16by9": ( - x: 16, - y: 9 - ), - "4by3": ( - x: 4, - y: 3 - ), - "1by1": ( - x: 1, - y: 1 - ) -); -{{< /highlight >}} +{{< scss-docs name="embed-responsive-aspect-ratios" file="scss/_variables.scss" >}} |
