bulma/sass/components/dropdown.scss
2024-09-18 17:48:30 +01:00

174 lines
5.5 KiB
SCSS

@use "../utilities/css-variables" as cv;
@use "../utilities/initial-variables" as iv;
@use "../utilities/extends";
@use "../utilities/mixins" as mx;
$dropdown-menu-min-width: 12rem !default;
$dropdown-content-background-color: cv.getVar("scheme-main") !default;
$dropdown-content-offset: 0.25rem !default;
$dropdown-content-padding-bottom: 0.5rem !default;
$dropdown-content-padding-top: 0.5rem !default;
$dropdown-content-radius: cv.getVar("radius") !default;
$dropdown-content-shadow: cv.getVar("shadow") !default;
$dropdown-content-z: 20 !default;
$dropdown-item-background-color: cv.getVar("scheme-main") !default;
$dropdown-item-color: cv.getVar("text-strong") !default;
$dropdown-item-hover-background-color: hsl(
from #{cv.getVar("dropdown-item-background-color")} h s calc(l + #{cv.getVar(
"hover-background-l-delta"
)})
) !default;
$dropdown-item-active-background-color: hsl(
from #{cv.getVar("dropdown-item-background-color")} h s calc(l + #{cv.getVar(
"active-background-l-delta"
)})
) !default;
$dropdown-item-selected-background-color: cv.getVar("link") !default;
$dropdown-item-selected-color: cv.getVar("link-invert") !default;
$dropdown-item-selected-hover-background-color: hsl(
from #{cv.getVar("dropdown-item-selected-background-color")} h s calc(l + #{cv.getVar(
"hover-background-l-delta"
)})
) !default;
$dropdown-item-selected-active-background-color: hsl(
from #{cv.getVar("dropdown-item-selected-background-color")} h s calc(l + #{cv.getVar(
"active-background-l-delta"
)})
) !default;
$dropdown-divider-background-color: cv.getVar("border-weak") !default;
.#{iv.$class-prefix}dropdown {
// prettier-ignore-start
@include cv.register-vars(
(
"dropdown-menu-min-width": #{$dropdown-menu-min-width},
"dropdown-content-background-color": #{$dropdown-content-background-color},
"dropdown-content-offset": #{$dropdown-content-offset},
"dropdown-content-padding-bottom": #{$dropdown-content-padding-bottom},
"dropdown-content-padding-top": #{$dropdown-content-padding-top},
"dropdown-content-radius": #{$dropdown-content-radius},
"dropdown-content-shadow": #{$dropdown-content-shadow},
"dropdown-content-z": #{$dropdown-content-z},
"dropdown-divider-background-color": #{$dropdown-divider-background-color},
)
);
// prettier-ignore-end
}
.#{iv.$class-prefix}dropdown {
display: inline-flex;
position: relative;
vertical-align: top;
&.#{iv.$class-prefix}is-active,
&.#{iv.$class-prefix}is-hoverable:hover {
.#{iv.$class-prefix}dropdown-menu {
display: block;
}
}
&.#{iv.$class-prefix}is-right {
.#{iv.$class-prefix}dropdown-menu {
left: auto;
right: 0;
}
}
&.#{iv.$class-prefix}is-up {
.#{iv.$class-prefix}dropdown-menu {
bottom: 100%;
padding-bottom: cv.getVar("dropdown-content-offset");
padding-top: initial;
top: auto;
}
}
}
.#{iv.$class-prefix}dropdown-menu {
display: none;
@include mx.ltr-position(0, false);
min-width: cv.getVar("dropdown-menu-min-width");
padding-top: cv.getVar("dropdown-content-offset");
position: absolute;
top: 100%;
z-index: cv.getVar("dropdown-content-z");
}
.#{iv.$class-prefix}dropdown-content {
background-color: cv.getVar("dropdown-content-background-color");
border-radius: cv.getVar("dropdown-content-radius");
box-shadow: cv.getVar("dropdown-content-shadow");
padding-bottom: cv.getVar("dropdown-content-padding-bottom");
padding-top: cv.getVar("dropdown-content-padding-top");
}
.#{iv.$class-prefix}dropdown-item {
@include cv.register-vars(
(
"dropdown-item-color": #{$dropdown-item-color},
)
);
color: cv.getVar("dropdown-item-color");
display: block;
font-size: 0.875rem;
line-height: 1.5;
padding: 0.375rem 1rem;
}
a.#{iv.$class-prefix}dropdown-item,
button.#{iv.$class-prefix}dropdown-item {
@include cv.register-vars(
(
"dropdown-item-background-color": #{$dropdown-item-background-color},
"dropdown-item-hover-background-color": #{$dropdown-item-hover-background-color},
"dropdown-item-active-background-color": #{$dropdown-item-active-background-color},
"dropdown-item-selected-background-color": #{$dropdown-item-selected-background-color},
"dropdown-item-selected-color": #{$dropdown-item-selected-color},
"dropdown-item-selected-hover-background-color": #{$dropdown-item-selected-hover-background-color},
"dropdown-item-selected-active-background-color": #{$dropdown-item-selected-active-background-color},
)
);
background-color: cv.getVar("dropdown-item-background-color");
padding-inline-end: 3rem;
text-align: inherit;
white-space: nowrap;
width: 100%;
&:hover {
background-color: cv.getVar("dropdown-item-hover-background-color");
}
&:active {
background-color: cv.getVar("dropdown-item-active-background-color");
}
&.#{iv.$class-prefix}is-active,
&.#{iv.$class-prefix}is-selected {
background-color: cv.getVar("dropdown-item-selected-background-color");
color: cv.getVar("dropdown-item-selected-color");
&:hover {
background-color: cv.getVar(
"dropdown-item-selected-hover-background-color"
);
}
&:active {
background-color: cv.getVar(
"dropdown-item-selected-active-background-color"
);
}
}
}
.#{iv.$class-prefix}dropdown-divider {
background-color: cv.getVar("dropdown-divider-background-color");
border: none;
display: block;
height: 1px;
margin: 0.5rem 0;
}