summaryrefslogtreecommitdiff
path: root/docs/src/components/Examples/CollapsibleReadme.astro
blob: 679b467d36cebdecdffca8fb4d50489dc913d7d9 (plain) (blame)
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
---
import {Markdown} from 'astro/components'
export interface Props{
    label:string;
    readme:string;
}
const {label,readme} = Astro.props
---
    <div class="wrap-collapsible">
        <input type="checkbox" id="collapsible" class="toggle">
        <label for="collapsible" class="lbl-toggle">{label}</label>
        <div class="collapsible-content">
            <div class="content-inner">
                <Markdown content = {readme} />
            </div>
        </div>
    </div>



<style lang="css">
.wrap-collabsible {
  margin-bottom: 1.2rem 0;
  will-change: auto;
  scroll-behavior: smooth;
}

input[type='checkbox'] {
  display: none;
}

.lbl-toggle {
  display: block;

  font-weight: bold;
  font-family: monospace;
  font-size: xx-large;
  text-transform: uppercase;
  text-align: left;

  padding: 1rem;

  color: var(--theme-color);
  background: var(--theme-background);

  cursor: pointer;

  border-radius: 7px;
  transition: all 0.25s ease-out;
}

.lbl-toggle:hover {
  color: #7C5A0B;
}

.lbl-toggle::before {
  content: ' ';
  display: inline-block;

  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 5px solid currentColor;
  vertical-align: middle;
  margin-right: .7rem;
  transform: translateY(-2px);

  transition: transform .2s ease-out;
}

.toggle:checked + .lbl-toggle::before {
  transform: rotate(90deg) translateX(-3px);
}

.collapsible-content {
  max-height: 0px;
  overflow: hidden;
  transition: max-height 1.5s ease-in;
  will-change: transform;
}

.toggle:checked + .lbl-toggle + .collapsible-content {
  max-height: 100%;

}

.toggle:checked + .lbl-toggle {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.collapsible-content .content-inner {
  padding: .5rem 1rem;
}

</style>