pico/scss/components/_accordion.scss

72 lines
1.3 KiB
SCSS
Raw Normal View History

2019-11-27 15:31:49 +07:00
/**
* Accordion (<details>)
* Inspiration: https://codepen.io/koca/pen/RyeLLV
*/
details {
display: block;
2020-09-29 08:38:35 +07:00
margin-bottom: var(--spacing-typography);
padding-bottom: calc(var(--spacing-typography) / 2);
2019-11-27 15:31:49 +07:00
border-bottom: 1px solid var(--muted-border);
summary {
line-height: 1rem;
2019-11-27 15:31:49 +07:00
list-style-type: none;
cursor: pointer;
// Reset marker
&::-webkit-details-marker {
display: none;
}
&::marker {
display: none;
}
&::-moz-list-bullet {
list-style-type: none;
}
// Marker
&::after {
display: inline-block;
width: 1rem;
height: 1rem;
float: right;
transform: rotate(-90deg);
2020-09-29 08:38:35 +07:00
background-image: var(--icon-chevron);
2019-11-27 15:31:49 +07:00
background-position: center;
background-repeat: no-repeat;
background-size: 1rem auto;
content: '';
2020-09-29 08:38:35 +07:00
@if $enable-transitions {
transition: transform var(--transition);
}
2019-11-27 15:31:49 +07:00
}
&:focus {
outline: none;
}
2019-11-27 18:35:03 +07:00
~ * {
2020-09-29 08:38:35 +07:00
margin-top: calc(var(--spacing-typography) / 2);
2019-11-27 18:35:03 +07:00
~ * {
margin-top: 0;
}
}
2019-11-27 15:31:49 +07:00
}
// Open
&[open] {
2021-06-30 11:52:49 +07:00
> summary {
2020-09-29 08:38:35 +07:00
margin-bottom: calc(var(--spacing-typography) / 4);
2019-11-27 15:31:49 +07:00
color: var(--muted-text);
&::after {
transform: rotate(0);
}
}
}
}