webpack-bootstrap-ui-kit/src/scss/_mixings.scss

248 lines
5.0 KiB
SCSS
Raw Permalink Normal View History

2021-08-09 21:15:55 +02:00
@use "sass:math";
2021-08-18 20:38:12 +02:00
@import "~bootstrap/scss/mixins";
2022-09-12 22:07:08 +02:00
/// Remove the unit of a length
/// @param {Number} $number - Number to remove unit from
/// @return {Number} - Unitless number
@function strip-unit($number) {
@if type-of($number) == 'number' and not unitless($number) {
@return $number / ($number * 0 + 1);
}
@return $number;
}
@function rem($pxValue) {
@return #{strip-unit($pxValue) / strip-unit($html-font-size)}rem;
}
/*.component {
font-size: rem(14px); // or rem(14)
}*/
2019-12-29 06:04:00 +01:00
@mixin hover-disabled() {
2022-09-12 22:07:08 +02:00
&:not(.disabled) {
&.active,
&:active,
&:hover,
&:focus {
@content;
}
}
}
2021-08-18 20:38:12 +02:00
@mixin pseudo($display: block, $pos: absolute, $content: "") {
2022-09-12 22:07:08 +02:00
position: $pos;
display: $display;
content: $content;
}
@mixin responsive-ratio($x, $y, $pseudo: false) {
2022-09-12 22:07:08 +02:00
$padding: unquote(math.div($y, $x) * 100 + "%");
2022-09-12 22:07:08 +02:00
@if $pseudo {
&:before {
width: 100%;
padding-top: $padding;
@include pseudo($pos: relative);
}
} @else {
padding-top: $padding;
}
}
@mixin input-placeholder {
2022-09-12 22:07:08 +02:00
&.placeholder {
@content;
}
2022-09-12 22:07:08 +02:00
&:-moz-placeholder {
@content;
}
2022-09-12 22:07:08 +02:00
&::-moz-placeholder {
@content;
}
2022-09-12 22:07:08 +02:00
&:-ms-input-placeholder {
@content;
}
2022-09-12 22:07:08 +02:00
&::-webkit-input-placeholder {
@content;
}
}
@mixin truncate($truncation-boundary) {
2022-09-12 22:07:08 +02:00
overflow: hidden;
max-width: $truncation-boundary;
white-space: nowrap;
text-overflow: ellipsis;
}
@mixin fix-bold() {
2022-09-12 22:07:08 +02:00
display: inline-flex;
flex-direction: column;
&:before {
font-weight: bold;
visibility: hidden;
overflow: hidden;
height: 0;
content: attr(data-text);
content: attr(data-text) / "";
user-select: none;
pointer-events: none;
}
}
@mixin dropdowns-dark() {
2022-09-12 22:07:08 +02:00
.navbar-dark {
.nav-link {
@include hover-focus {
background: $navbar-dark-hover-background;
}
}
2022-09-12 22:07:08 +02:00
.active > .nav-link,
.nav-link.active {
background: $navbar-dark-active-background;
}
2022-09-12 22:07:08 +02:00
.nav-link.show,
.navbar-nav .show > .nav-link {
color: $navbar-dark-show-color;
background: $navbar-dark-show-background;
}
}
2022-09-12 22:07:08 +02:00
.dropdown-menu.bg-dark {
border-color: $dark;
2022-09-12 22:07:08 +02:00
.nav-link {
color: $navbar-dark-color;
2022-09-12 22:07:08 +02:00
@include hover-focus {
color: $navbar-dark-hover-color;
}
2022-09-12 22:07:08 +02:00
&.disabled {
cursor: default;
color: $navbar-dark-disabled-color;
}
}
2022-09-12 22:07:08 +02:00
.show > .nav-link,
.active > .nav-link,
.nav-link.show,
.nav-link.active {
color: $navbar-dark-active-color;
}
2022-09-12 22:07:08 +02:00
.dropdown-item {
@include hover-focus {
color: $navbar-dark-hover-color;
background: $navbar-dark-hover-background;
}
2022-09-12 22:07:08 +02:00
&.active,
&:active {
background: $navbar-dark-active-background;
}
2022-09-12 22:07:08 +02:00
.nav-link {
background: none;
}
}
}
}
@mixin dropdown-hovers() {
2022-09-12 22:07:08 +02:00
.dropdown.show {
.dropdown {
&:hover,
&.active,
&:focus {
> .dropdown-menu {
display: block;
}
}
}
2021-08-18 20:38:12 +02:00
}
2022-09-12 22:07:08 +02:00
@media only screen and (min-width: map-get($grid-breakpoints, "md")) {
.dropdown-hover ul li {
position: relative;
}
2022-09-12 22:07:08 +02:00
.dropdown-hover ul li {
&:hover,
&.active,
&:focus {
> .dropdown-toggle::after {
transform: rotate(-90deg);
}
> ul {
display: block;
}
}
}
2022-09-12 22:07:08 +02:00
.dropdown-hover ul ul {
position: absolute;
top: 100%;
left: 0;
display: none;
min-width: 250px;
}
2022-09-12 22:07:08 +02:00
.dropdown-hover ul ul li {
position: relative;
}
2022-09-12 22:07:08 +02:00
.dropdown-hover ul ul li {
&:hover,
&.active,
&:focus {
> ul {
display: block;
}
}
}
2022-09-12 22:07:08 +02:00
.dropdown-hover ul ul ul {
position: absolute;
top: 0;
left: 100%;
display: none;
min-width: 250px;
}
2022-09-12 22:07:08 +02:00
.dropdown-hover ul ul ul li {
position: relative;
}
2022-09-12 22:07:08 +02:00
.dropdown-hover ul ul ul li {
&:hover,
&.active,
&:focus {
ul {
display: block;
}
}
}
2022-09-12 22:07:08 +02:00
.dropdown-hover ul ul ul ul {
position: absolute;
z-index: 1;
top: 0;
left: -100%;
display: none;
min-width: 250px;
}
}
}