bulma/sass/components/dropdown.scss

174 lines
5.5 KiB
SCSS
Raw Permalink Normal View History

2024-03-21 16:11:54 +00:00
@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;
2024-09-18 16:48:30 +00:00
$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;
2024-03-21 16:11:54 +00:00
$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 {
2024-09-18 16:48:30 +00:00
@include cv.register-vars(
(
"dropdown-item-color": #{$dropdown-item-color},
)
2024-03-21 16:11:54 +00:00
);
2024-09-18 16:48:30 +00:00
color: cv.getVar("dropdown-item-color");
2024-03-21 16:11:54 +00:00
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 {
2024-09-18 16:48:30 +00:00
@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},
2024-03-21 16:11:54 +00:00
)
);
2024-09-18 16:48:30 +00:00
background-color: cv.getVar("dropdown-item-background-color");
2024-03-21 16:11:54 +00:00
padding-inline-end: 3rem;
text-align: inherit;
white-space: nowrap;
width: 100%;
&:hover {
2024-09-18 16:48:30 +00:00
background-color: cv.getVar("dropdown-item-hover-background-color");
2024-03-21 16:11:54 +00:00
}
&:active {
2024-09-18 16:48:30 +00:00
background-color: cv.getVar("dropdown-item-active-background-color");
2024-03-21 16:11:54 +00:00
}
&.#{iv.$class-prefix}is-active,
&.#{iv.$class-prefix}is-selected {
2024-09-18 16:48:30 +00:00
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"
);
}
2024-03-21 16:11:54 +00:00
}
}
.#{iv.$class-prefix}dropdown-divider {
background-color: cv.getVar("dropdown-divider-background-color");
border: none;
display: block;
height: 1px;
margin: 0.5rem 0;
}