forked from scientific-python/scientific-python-hugo-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdropdown.html
More file actions
186 lines (157 loc) · 4.28 KB
/
dropdown.html
File metadata and controls
186 lines (157 loc) · 4.28 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
{{/*
doc: Dropdowns
{{< dropdown >}}
body = 'And with no title and some content!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'With a title'
body = 'And some content!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'With a title and icon'
icon = 'fa-solid fa-lock-open'
body = 'And some content and an icon!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'A primary color dropdown'
icon = 'fa-solid fa-lock-open'
color = 'primary'
body = 'And some content and an icon!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'A secondary color dropdown'
icon = 'fa-solid fa-eye'
color = 'secondary'
body = 'And some content and an icon!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'A success color dropdown'
icon = 'fa-solid fa-check'
color = 'success'
body = 'And some content and an icon!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'A warning color dropdown'
icon = 'fa-solid fa-exclamation'
color = 'warning'
body = 'And some content and an icon!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'A danger color dropdown'
icon = 'fa-solid fa-exclamation-triangle'
color = 'danger'
body = 'And some content and an icon!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'Open dropdown by default'
icon = 'fa-solid fa-eye'
color = 'info'
open = true
body = 'This dropdown is open by default!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'Fade in animation'
icon = 'fa-solid fa-magic'
animate = 'fade-in'
body = 'This dropdown fades in when opened!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'Fade in and slide down animation'
icon = 'fa-solid fa-chart-line'
animate = 'fade-in-slide-down'
body = 'This dropdown fades in and slides down when opened!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'Using chevron: down-up'
icon = 'fa-solid fa-cog'
chevron = 'down-up'
body = 'Notice the different chevron direction when opened!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'Custom chevron with a fade-in animation'
icon = 'fa-solid fa-star'
chevron = 'down-up'
animate = 'fade-in'
color = 'warning'
body = 'Combining different features!'
{{< /dropdown >}}
{{< dropdown >}}
title = 'Multi-line content'
icon = 'fa-solid fa-align-left'
body = '''
This is multi-line content.
It can include **markdown** and multiple paragraphs.
And even lists:
- Item 1
- Item 2
- Item 3
'''
{{< /dropdown >}}
{{< dropdown >}}
title = 'Dropdown with code'
icon = 'fa-solid fa-code'
color = 'success'
body = '''
Here's some code inside a dropdown:
```python
def hello_world():
print("Hello from a dropdown!")
return 42
```
And more content after the code.
'''
{{< /dropdown >}}
{{< dropdown >}}
title = 'Nested dropdowns'
icon = 'fa-solid fa-folder'
body = '''
This is a dropdown with a dropdown inside it.
{{< dropdown >}}
title = 'Inner dropdown'
icon = 'fa-solid fa-code'
body = '''
I'm inside a dropdown in a dropdown!
'''
{{< /dropdown >}}
And here is some more content after the inner dropdown.
'''
{{< /dropdown >}}
*/}}
{{- $data := .Inner | transform.Unmarshal -}}
{{- $chevronClass := "sd-summary-chevron-right" -}}
{{- $chevronIcon := "fa-chevron-right" -}}
{{- if eq $data.chevron "down-up" -}}
{{- $chevronClass = "sd-summary-chevron-down" -}}
{{- $chevronIcon = "fa-chevron-down" -}}
{{- end -}}
{{- $detailsClasses := slice "sd-sphinx-override" "sd-dropdown" "sd-card" "sd-mb-3" -}}
{{- with $data.animate -}}
{{- $detailsClasses = $detailsClasses | append (printf "sd-%s" .) -}}
{{- end -}}
<details class="{{ delimit $detailsClasses " " }}"{{ if $data.open }} open="open"{{ end }}>
{{- $summaryClasses := slice "sd-summary-title" "sd-card-header" -}}
{{- with $data.color -}}
{{- $summaryClasses = $summaryClasses | append (printf "sd-bg-%s" .) -}}
{{- $summaryClasses = $summaryClasses | append (printf "sd-bg-text-%s" .) -}}
{{- end -}}
<summary class="{{ delimit $summaryClasses " " }}">
{{- with $data.icon }}
<span class="sd-summary-icon"><i class="fa {{ . }}"></i></span>
{{- end }}
<span class="sd-summary-text">
{{- with $data.title }}
{{- . }}
{{- else }}
<i class="fas fa-ellipsis-h no-title sd-octicon"></i>
{{- end }}
</span>
<span class="sd-summary-state-marker {{ $chevronClass }}">
<i class="fas {{ $chevronIcon }}"></i>
</span>
</summary>
<div class="sd-summary-content sd-card-body">
{{- with (trim $data.body "\n") }}
{{- . | markdownify }}
{{- end }}
</div>
</details>