pico/scss/components/_progress.scss

103 lines
2.6 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-23 10:47:50 +07:00
@if map.get($modules, "components/progress") {
/**
* Progress
*/
2020-09-30 10:28:06 +07:00
2022-10-23 10:47:50 +07:00
// Reboot based on :
// - normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css
// - sanitize.css v13.0.0 | CC0 1.0 Universal | github.com/csstools/sanitize.css
//
2020-09-30 10:28:06 +07:00
2022-10-23 10:47:50 +07:00
// 1. Add the correct display in Edge 18- and IE
// 2. Add the correct vertical alignment in Chrome, Edge, and Firefox
2024-01-25 01:42:54 +07:00
#{$parent-selector} progress {
2022-10-23 10:47:50 +07:00
display: inline-block; // 1
vertical-align: baseline; // 2
}
2020-09-30 10:28:06 +07:00
2022-10-23 10:47:50 +07:00
// Pico
//
2021-07-02 16:54:41 +07:00
2024-01-25 01:42:54 +07:00
#{$parent-selector} progress {
2022-10-23 10:47:50 +07:00
// Reset the default appearance
-webkit-appearance: none;
-moz-appearance: none;
2020-09-30 10:28:06 +07:00
2022-10-23 10:47:50 +07:00
// Styles
display: inline-block;
appearance: none;
width: 100%;
height: 0.5rem;
2023-12-28 13:21:52 +07:00
margin-bottom: calc(var(#{$css-var-prefix}spacing) * 0.5);
2022-10-23 10:47:50 +07:00
overflow: hidden;
2020-09-30 10:28:06 +07:00
2022-10-23 10:47:50 +07:00
// Remove Firefox and Opera border
border: 0;
2023-12-28 13:21:52 +07:00
border-radius: var(#{$css-var-prefix}border-radius);
background-color: var(#{$css-var-prefix}progress-background-color);
2020-09-30 10:28:06 +07:00
2022-10-23 10:47:50 +07:00
// IE10 uses `color` to set the bar background-color
2023-12-28 13:21:52 +07:00
color: var(#{$css-var-prefix}progress-color);
2020-09-30 10:28:06 +07:00
2022-10-23 10:47:50 +07:00
&::-webkit-progress-bar {
2023-12-28 13:21:52 +07:00
border-radius: var(#{$css-var-prefix}border-radius);
2022-10-23 10:47:50 +07:00
background: none;
}
2023-02-15 00:14:05 +07:00
2022-10-23 10:47:50 +07:00
&[value]::-webkit-progress-value {
2023-12-28 13:21:52 +07:00
background-color: var(#{$css-var-prefix}progress-color);
2023-03-19 01:51:08 +07:00
@if $enable-transitions {
2023-12-28 13:21:52 +07:00
transition: inline-size var(#{$css-var-prefix}transition);
2023-03-19 01:51:08 +07:00
}
2022-10-23 10:47:50 +07:00
}
2023-02-15 00:14:05 +07:00
2022-10-23 10:47:50 +07:00
&::-moz-progress-bar {
2023-12-28 13:21:52 +07:00
background-color: var(#{$css-var-prefix}progress-color);
2022-10-23 10:47:50 +07:00
}
2020-09-30 10:28:06 +07:00
2022-10-23 10:47:50 +07:00
// Indeterminate state
@media (prefers-reduced-motion: no-preference) {
&:indeterminate {
2023-12-28 13:21:52 +07:00
background: var(#{$css-var-prefix}progress-background-color)
2022-10-23 10:47:50 +07:00
linear-gradient(
to right,
2023-12-28 13:21:52 +07:00
var(#{$css-var-prefix}progress-color) 30%,
var(#{$css-var-prefix}progress-background-color) 30%
2022-10-23 10:47:50 +07:00
)
top left / 150% 150% no-repeat;
animation: progress-indeterminate 1s linear infinite;
2020-09-30 10:28:06 +07:00
2022-10-23 10:47:50 +07:00
&[value]::-webkit-progress-value {
background-color: transparent;
}
2023-02-15 00:14:05 +07:00
2022-10-23 10:47:50 +07:00
&::-moz-progress-bar {
background-color: transparent;
}
}
2020-09-30 10:28:06 +07:00
}
}
2022-10-23 10:47:50 +07:00
[dir="rtl"] {
@media (prefers-reduced-motion: no-preference) {
2024-01-25 01:42:54 +07:00
#{$parent-selector} progress:indeterminate {
2022-10-23 10:47:50 +07:00
animation-direction: reverse;
}
2022-02-06 10:25:10 +07:00
}
}
2022-10-23 10:47:50 +07:00
@keyframes progress-indeterminate {
0% {
background-position: 200% 0;
}
2023-02-15 00:14:05 +07:00
2022-10-23 10:47:50 +07:00
100% {
background-position: -200% 0;
}
2020-09-30 10:28:06 +07:00
}
2022-10-15 23:22:12 +07:00
}