picocss/scss/components/_accordion.scss

119 lines
2.5 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
2024-01-25 01:42:54 +07:00
#{$parent-selector} details {
2022-10-23 10:47:50 +07:00
display: block;
2023-12-28 13:21:52 +07:00
margin-bottom: var(#{$css-var-prefix}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-22 13:11:51 +07:00
@if $enable-transitions {
2023-12-28 13:21:52 +07:00
transition: color var(#{$css-var-prefix}transition);
2020-09-29 08:38:35 +07:00
}
2019-11-27 15:31:49 +07:00
&:not([role]) {
color: var(#{$css-var-prefix}accordion-close-summary-color);
}
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;
2023-12-28 13:21:52 +07:00
margin-inline-start: calc(var(#{$css-var-prefix}spacing, 1rem) * 0.5);
2022-10-23 10:47:50 +07:00
float: right;
transform: rotate(-90deg);
2023-12-28 13:21:52 +07:00
background-image: var(#{$css-var-prefix}icon-chevron);
2022-10-23 10:47:50 +07:00
background-position: right center;
background-size: 1rem auto;
background-repeat: no-repeat;
content: "";
@if $enable-transitions {
2023-12-28 13:21:52 +07:00
transition: transform var(#{$css-var-prefix}transition);
2022-10-23 10:47:50 +07:00
}
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]) {
2023-12-28 13:21:52 +07:00
color: var(#{$css-var-prefix}accordion-active-summary-color);
2022-10-23 10:47:50 +07:00
}
}
2023-01-01 14:00:33 +07:00
&:focus-visible {
&:not([role]) {
2023-12-28 13:21:52 +07:00
outline: var(#{$css-var-prefix}outline-width) solid var(#{$css-var-prefix}primary-focus);
outline-offset: calc(var(#{$css-var-prefix}spacing, 1rem) * 0.5);
color: var(#{$css-var-prefix}primary);
2023-01-01 14:00:33 +07:00
}
}
2022-10-23 10:47:50 +07:00
// Type button
&[role="button"] {
width: 100%;
text-align: left;
// Marker
&::after {
2023-12-28 13:21:52 +07:00
height: calc(1rem * var(#{$css-var-prefix}line-height, 1.5));
2022-01-23 12:45:00 +07:00
}
2019-11-27 18:35:03 +07:00
}
}
2024-11-11 22:10:47 -05:00
//!
//!
//!
2022-10-23 10:47:50 +07:00
// Open
&[open] {
> summary {
2023-12-28 13:21:52 +07:00
margin-bottom: var(#{$css-var-prefix}spacing);
2021-07-02 16:54:41 +07:00
2022-10-23 10:47:50 +07:00
&:not([role]) {
&:not(:focus) {
2023-12-28 13:21:52 +07:00
color: var(#{$css-var-prefix}accordion-open-summary-color);
2022-10-23 10:47:50 +07:00
}
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"] {
2024-01-25 01:42:54 +07:00
#{$parent-selector} details {
2022-10-23 10:47:50 +07:00
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
}