-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
collapse.css
97 lines (93 loc) · 3.05 KB
/
collapse.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
.collapse {
@apply rounded-box w-full;
}
details.collapse {
@apply w-full;
& summary {
@apply relative block;
&::-webkit-details-marker {
@apply hidden;
}
}
}
.collapse:focus-visible {
@apply outline-base-content outline outline-2 outline-offset-2;
}
details.collapse summary {
@apply outline-none;
}
.collapse:has(.collapse-title:focus-visible),
.collapse:has(> input[type="checkbox"]:focus-visible),
.collapse:has(> input[type="radio"]:focus-visible) {
@apply outline-base-content outline outline-2 outline-offset-2;
}
.collapse-arrow > .collapse-title:after {
@apply absolute block h-2 w-2 translate-y-[-100%] rotate-[45deg] transition-all ease-out;
transition-duration: 0.2s;
top: 1.9rem;
inset-inline-end: 1.4rem;
content: "";
transform-origin: 75% 75%;
box-shadow: 2px 2px;
pointer-events: none;
}
.collapse-plus > .collapse-title:after {
@apply absolute block h-2 w-2 transition-all duration-300 ease-out;
top: 0.9rem;
inset-inline-end: 1.4rem;
content: "+";
pointer-events: none;
}
.collapse:not(.collapse-open):not(.collapse-close) > input[type="checkbox"],
.collapse:not(.collapse-open):not(.collapse-close) > input[type="radio"]:not(:checked),
.collapse:not(.collapse-open):not(.collapse-close) > .collapse-title {
@apply cursor-pointer;
}
.collapse:focus:not(.collapse-open):not(.collapse-close):not(.collapse[open]) > .collapse-title {
cursor: unset;
}
.collapse-title {
@apply relative;
}
:where(.collapse > input[type="checkbox"]),
:where(.collapse > input[type="radio"]) {
z-index: 1;
}
.collapse-title,
:where(.collapse > input[type="checkbox"]),
:where(.collapse > input[type="radio"]) {
@apply p-4 pe-12;
min-height: 3.75rem;
transition: background-color 0.2s ease-out;
}
.collapse-content {
@apply px-4;
cursor: unset;
transition:
padding 0.2s ease-out,
background-color 0.2s ease-out;
}
.collapse[open] > :where(.collapse-content),
.collapse-open > :where(.collapse-content),
.collapse:focus:not(.collapse-close) > :where(.collapse-content),
.collapse:not(.collapse-close) > :where(input[type="checkbox"]:checked ~ .collapse-content),
.collapse:not(.collapse-close) > :where(input[type="radio"]:checked ~ .collapse-content) {
@apply pb-4;
transition:
padding 0.2s ease-out,
background-color 0.2s ease-out;
}
.collapse[open].collapse-arrow > .collapse-title:after,
.collapse-open.collapse-arrow > .collapse-title:after,
.collapse-arrow:focus:not(.collapse-close) > .collapse-title:after,
.collapse-arrow:not(.collapse-close) > input[type="checkbox"]:checked ~ .collapse-title:after,
.collapse-arrow:not(.collapse-close) > input[type="radio"]:checked ~ .collapse-title:after {
@apply translate-y-[-50%] rotate-[225deg];
}
.collapse[open].collapse-plus > .collapse-title:after,
.collapse-open.collapse-plus > .collapse-title:after,
.collapse-plus:focus:not(.collapse-close) > .collapse-title:after,
.collapse-plus:not(.collapse-close) > input[type="checkbox"]:checked ~ .collapse-title:after,
.collapse-plus:not(.collapse-close) > input[type="radio"]:checked ~ .collapse-title:after {
content: "−";
}