pico/scss/forms/_input-range.scss

97 lines
1.9 KiB
SCSS
Raw Normal View History

2022-10-23 10:47:50 +07:00
@use "sass:map";
2022-10-22 13:11:51 +07:00
@use "../settings" as *;
2022-10-22 11:44:10 +07:00
2022-10-23 10:47:50 +07:00
// Config
2023-03-18 08:22:05 +07:00
$height-track: 0.375rem;
2022-10-23 10:47:50 +07:00
$height-thumb: 1.25rem;
$border-thumb: 2px;
2022-10-22 11:44:10 +07:00
2022-10-23 10:47:50 +07:00
// Slider Track
@mixin slider-track {
2022-10-22 11:44:10 +07:00
width: 100%;
2022-10-23 10:47:50 +07:00
height: $height-track;
border-radius: var(#{$}border-radius);
background-color: var(#{$}range-border-color);
2022-10-22 11:44:10 +07:00
2022-10-23 10:47:50 +07:00
@if $enable-transitions {
transition: background-color var(#{$}transition), box-shadow var(#{$}transition);
2022-10-22 11:44:10 +07:00
}
2022-10-23 10:47:50 +07:00
}
2022-10-22 11:44:10 +07:00
2022-10-23 10:47:50 +07:00
// Slider Thumb
@mixin slider-thumb {
-webkit-appearance: none;
width: $height-thumb;
height: $height-thumb;
margin-top: #{(-($height-thumb * 0.5) + ($height-track * 0.5))};
border: $border-thumb solid var(#{$}range-thumb-border-color);
border-radius: 50%;
background-color: var(#{$}range-thumb-color);
cursor: pointer;
@if $enable-transitions {
transition: background-color var(#{$}transition), transform var(#{$}transition);
2022-10-22 11:44:10 +07:00
}
2022-10-23 10:47:50 +07:00
}
2022-10-22 11:44:10 +07:00
2022-10-23 10:47:50 +07:00
@if map.get($modules, "forms/input-range") {
/**
* Input type range
*/
2022-10-22 11:44:10 +07:00
2022-10-23 10:47:50 +07:00
[type="range"] {
// Styles
2022-10-22 11:44:10 +07:00
-webkit-appearance: none;
2022-10-23 10:47:50 +07:00
-moz-appearance: none;
appearance: none;
width: 100%;
2022-10-22 11:44:10 +07:00
height: $height-thumb;
2022-10-23 10:47:50 +07:00
background: none;
2022-10-22 11:44:10 +07:00
2022-10-23 10:47:50 +07:00
&::-webkit-slider-runnable-track {
@include slider-track;
}
2022-10-22 11:44:10 +07:00
2022-10-23 10:47:50 +07:00
&::-moz-range-track {
@include slider-track;
}
2022-10-22 11:44:10 +07:00
2022-10-23 10:47:50 +07:00
&::-ms-track {
@include slider-track;
}
2022-10-22 11:44:10 +07:00
&::-webkit-slider-thumb {
2022-10-23 10:47:50 +07:00
@include slider-thumb;
2022-10-22 11:44:10 +07:00
}
&::-moz-range-thumb {
2022-10-23 10:47:50 +07:00
@include slider-thumb;
2022-10-22 11:44:10 +07:00
}
&::-ms-thumb {
2022-10-23 10:47:50 +07:00
@include slider-thumb;
}
2023-03-18 08:22:05 +07:00
&:active,
&:focus-within {
2022-10-23 10:47:50 +07:00
#{$✨}range-border-color: var(#{$}range-active-border-color);
2023-03-18 08:22:05 +07:00
#{$✨}range-thumb-color: var(#{$}range-thumb-active-color);
2022-10-23 10:47:50 +07:00
}
&:active {
// Slider Thumb
&::-webkit-slider-thumb {
transform: scale(1.25);
}
&::-moz-range-thumb {
transform: scale(1.25);
}
&::-ms-thumb {
transform: scale(1.25);
}
2022-10-22 11:44:10 +07:00
}
}
}