picocss/scss/components/_accordion.scss

117 lines
2.3 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
@if map.get($modules, "components/accordion") {
/**
* Accordion (<details>)
*/
2019-11-27 15:31:49 +07:00
2022-10-23 10:47:50 +07:00
details {
display: block;
margin-bottom: var(#{$}spacing);
2022-10-23 10:47:50 +07:00
summary {
line-height: 1rem;
2019-11-27 15:31:49 +07:00
list-style-type: none;
2022-10-23 10:47:50 +07:00
cursor: pointer;
2019-11-27 15:31:49 +07:00
2022-10-23 10:47:50 +07:00
&:not([role]) {
color: var(#{$}accordion-close-summary-color);
}
2020-09-29 08:38:35 +07:00
2022-10-22 13:11:51 +07:00
@if $enable-transitions {
2022-10-23 10:47:50 +07:00
transition: color var(#{$}transition);
2020-09-29 08:38:35 +07:00
}
2019-11-27 15:31:49 +07:00
2022-10-23 10:47:50 +07:00
// Reset marker
&::-webkit-details-marker {
display: none;
}
2022-01-23 12:45:00 +07:00
2022-10-23 10:47:50 +07:00
&::marker {
display: none;
2022-01-23 12:45:00 +07:00
}
2019-11-27 18:35:03 +07:00
2022-10-23 10:47:50 +07:00
&::-moz-list-bullet {
list-style-type: none;
}
2022-03-06 09:37:03 +07:00
2022-01-23 12:45:00 +07:00
// Marker
&::after {
2022-10-23 10:47:50 +07:00
display: block;
width: 1rem;
height: 1rem;
margin-inline-start: calc(var(#{$}spacing, 1rem) * 0.5);
float: right;
transform: rotate(-90deg);
background-image: var(#{$}icon-chevron);
background-position: right center;
background-size: 1rem auto;
background-repeat: no-repeat;
content: "";
@if $enable-transitions {
transition: transform var(#{$}transition);
}
2022-01-23 12:45:00 +07:00
}
2019-11-27 18:35:03 +07:00
2022-10-23 10:47:50 +07:00
&:focus {
outline: none;
2023-01-01 14:00:33 +07:00
&:not([role]) {
2022-10-23 10:47:50 +07:00
color: var(#{$}accordion-active-summary-color);
}
}
2023-01-01 14:00:33 +07:00
&:focus-visible {
&:not([role]) {
2023-01-28 12:22:55 +07:00
outline: var(#{$}outline-width) solid var(#{$}primary-focus);
outline-offset: calc(var(#{$}spacing, 1rem) * 0.5);
2023-01-01 14:00:33 +07:00
color: var(#{$}primary);
}
}
2022-10-23 10:47:50 +07:00
// Type button
&[role="button"] {
width: 100%;
text-align: left;
// Marker
&::after {
height: calc(1rem * var(#{$}line-height, 1.5));
2022-01-23 12:45:00 +07:00
}
2019-11-27 18:35:03 +07:00
}
}
2019-11-27 15:31:49 +07:00
2022-10-23 10:47:50 +07:00
// Open
&[open] {
> summary {
2023-01-01 14:00:33 +07:00
margin-bottom: var(#{$}spacing);
2021-07-02 16:54:41 +07:00
2022-10-23 10:47:50 +07:00
&:not([role]) {
&:not(:focus) {
color: var(#{$}accordion-open-summary-color);
}
2022-01-23 12:45:00 +07:00
}
2019-11-27 15:31:49 +07:00
2022-10-23 10:47:50 +07:00
&::after {
transform: rotate(0);
}
2022-03-06 09:37:03 +07:00
}
2019-11-27 15:31:49 +07:00
}
}
2021-10-24 02:06:00 +07:00
2022-10-23 10:47:50 +07:00
[dir="rtl"] {
details {
summary {
text-align: right;
2022-01-23 12:45:00 +07:00
2022-10-23 10:47:50 +07:00
&::after {
float: left;
background-position: left center;
}
2021-10-24 02:06:00 +07:00
}
}
}
2022-10-15 23:22:12 +07:00
}