mirror of
https://github.com/twbs/bootstrap.git
synced 2025-12-28 13:40:43 +00:00
* Add custom property prefixing postcss plugin * Remove $prefix variable, replace with PostCSS plugin to prefix CSS variables
161 lines
4.8 KiB
SCSS
161 lines
4.8 KiB
SCSS
@use "sass:map";
|
|
@use "config" as *;
|
|
@use "variables" as *;
|
|
@use "mixins/box-shadow" as *;
|
|
@use "mixins/transition" as *;
|
|
@use "mixins/backdrop" as *;
|
|
@use "layout/breakpoints" as *;
|
|
|
|
%offcanvas-css-vars {
|
|
// scss-docs-start offcanvas-css-vars
|
|
--offcanvas-zindex: #{$zindex-offcanvas};
|
|
--offcanvas-width: #{$offcanvas-horizontal-width};
|
|
--offcanvas-height: #{$offcanvas-vertical-height};
|
|
--offcanvas-padding-x: #{$offcanvas-padding-x};
|
|
--offcanvas-padding-y: #{$offcanvas-padding-y};
|
|
--offcanvas-color: #{$offcanvas-color};
|
|
--offcanvas-bg: #{$offcanvas-bg-color};
|
|
--offcanvas-border-width: #{$offcanvas-border-width};
|
|
--offcanvas-border-color: #{$offcanvas-border-color};
|
|
--offcanvas-box-shadow: #{$offcanvas-box-shadow};
|
|
--offcanvas-transition: #{transform $offcanvas-transition-duration ease-in-out};
|
|
--offcanvas-title-line-height: #{$offcanvas-title-line-height};
|
|
// scss-docs-end offcanvas-css-vars
|
|
}
|
|
|
|
@layer components {
|
|
@each $breakpoint in map.keys($grid-breakpoints) {
|
|
$next: breakpoint-next($breakpoint, $grid-breakpoints);
|
|
$infix: breakpoint-infix($next, $grid-breakpoints);
|
|
|
|
.offcanvas#{$infix} {
|
|
@extend %offcanvas-css-vars;
|
|
}
|
|
}
|
|
|
|
@each $breakpoint in map.keys($grid-breakpoints) {
|
|
$next: breakpoint-next($breakpoint, $grid-breakpoints);
|
|
$infix: breakpoint-infix($next, $grid-breakpoints);
|
|
|
|
.offcanvas#{$infix} {
|
|
@include media-breakpoint-down($next) {
|
|
position: fixed;
|
|
bottom: 0;
|
|
z-index: var(--offcanvas-zindex);
|
|
display: flex;
|
|
flex-direction: column;
|
|
max-width: 100%;
|
|
color: var(--offcanvas-color);
|
|
visibility: hidden;
|
|
background-color: var(--offcanvas-bg);
|
|
background-clip: padding-box;
|
|
outline: 0;
|
|
@include box-shadow(var(--offcanvas-box-shadow));
|
|
@include transition(var(--offcanvas-transition));
|
|
|
|
&.offcanvas-start {
|
|
inset-block: 0;
|
|
inset-inline-start: 0;
|
|
width: var(--offcanvas-width);
|
|
border-inline-end: var(--offcanvas-border-width) solid var(--offcanvas-border-color);
|
|
transform: translateX(-100%);
|
|
|
|
:root:dir(rtl) & {
|
|
transform: translateX(100%);
|
|
}
|
|
}
|
|
|
|
&.offcanvas-end {
|
|
inset-block: 0;
|
|
inset-inline-end: 0;
|
|
width: var(--offcanvas-width);
|
|
border-inline-start: var(--offcanvas-border-width) solid var(--offcanvas-border-color);
|
|
transform: translateX(100%);
|
|
|
|
:root:dir(rtl) & {
|
|
transform: translateX(-100%);
|
|
}
|
|
}
|
|
|
|
&.offcanvas-top {
|
|
inset: 0 0 auto;
|
|
height: var(--offcanvas-height);
|
|
max-height: 100%;
|
|
border-block-end: var(--offcanvas-border-width) solid var(--offcanvas-border-color);
|
|
transform: translateY(-100%);
|
|
}
|
|
|
|
&.offcanvas-bottom {
|
|
inset: auto 0 0;
|
|
height: var(--offcanvas-height);
|
|
max-height: 100%;
|
|
border-block-start: var(--offcanvas-border-width) solid var(--offcanvas-border-color);
|
|
transform: translateY(100%);
|
|
}
|
|
|
|
&.showing,
|
|
&.show:not(.hiding) {
|
|
transform: none;
|
|
}
|
|
|
|
&.showing,
|
|
&.hiding,
|
|
&.show {
|
|
visibility: visible;
|
|
}
|
|
}
|
|
|
|
@if not ($infix == "") {
|
|
@include media-breakpoint-up($next) {
|
|
--offcanvas-height: auto;
|
|
--offcanvas-border-width: 0;
|
|
background-color: transparent !important; // stylelint-disable-line declaration-no-important
|
|
|
|
.offcanvas-header {
|
|
display: none;
|
|
}
|
|
|
|
.offcanvas-body {
|
|
display: flex;
|
|
flex-grow: 0;
|
|
padding: 0;
|
|
overflow-y: visible;
|
|
// Reset `background-color` in case `.bg-*` classes are used in offcanvas
|
|
background-color: transparent !important; // stylelint-disable-line declaration-no-important
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.offcanvas-backdrop {
|
|
@include overlay-backdrop($zindex-offcanvas-backdrop, $offcanvas-backdrop-bg, $offcanvas-backdrop-opacity);
|
|
}
|
|
|
|
.offcanvas-header {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: var(--offcanvas-padding-y) var(--offcanvas-padding-x);
|
|
|
|
.btn-close {
|
|
padding: calc(var(--offcanvas-padding-y) * .5) calc(var(--offcanvas-padding-x) * .5);
|
|
// Split properties to avoid invalid calc() function if value is 0
|
|
margin-inline-start: auto;
|
|
margin-inline-end: calc(-.5 * var(--offcanvas-padding-x));
|
|
margin-top: calc(-.5 * var(--offcanvas-padding-y));
|
|
margin-bottom: calc(-.5 * var(--offcanvas-padding-y));
|
|
}
|
|
}
|
|
|
|
.offcanvas-title {
|
|
margin-bottom: 0;
|
|
line-height: var(--offcanvas-title-line-height);
|
|
}
|
|
|
|
.offcanvas-body {
|
|
flex-grow: 1;
|
|
padding: var(--offcanvas-padding-y) var(--offcanvas-padding-x);
|
|
overflow-y: auto;
|
|
}
|
|
}
|