|
31 | 31 | body = 'And some content and an icon!'
|
32 | 32 | {{< /dropdown >}}
|
33 | 33 |
|
| 34 | +{{< dropdown >}} |
| 35 | +title = 'Open dropdown by default' |
| 36 | +icon = 'fa-solid fa-eye' |
| 37 | +color = 'info' |
| 38 | +open = true |
| 39 | +body = 'This dropdown is open by default!' |
| 40 | +{{< /dropdown >}} |
| 41 | + |
| 42 | +{{< dropdown >}} |
| 43 | +title = 'Fade in animation' |
| 44 | +icon = 'fa-solid fa-magic' |
| 45 | +animate = 'fade-in' |
| 46 | +body = 'This dropdown fades in when opened!' |
| 47 | +{{< /dropdown >}} |
| 48 | + |
| 49 | +{{< dropdown >}} |
| 50 | +title = 'Fade in and slide down animation' |
| 51 | +icon = 'fa-solid fa-chart-line' |
| 52 | +animate = 'fade-in-slide-down' |
| 53 | +body = 'This dropdown fades in and slides down when opened!' |
| 54 | +{{< /dropdown >}} |
| 55 | + |
| 56 | +{{< dropdown >}} |
| 57 | +title = 'Using chevron: down-up' |
| 58 | +icon = 'fa-solid fa-cog' |
| 59 | +chevron = 'down-up' |
| 60 | +body = 'Notice the different chevron direction!' |
| 61 | +{{< /dropdown >}} |
| 62 | + |
| 63 | +{{< dropdown >}} |
| 64 | +title = 'Custom chevron with animation' |
| 65 | +icon = 'fa-solid fa-star' |
| 66 | +chevron = 'down-up' |
| 67 | +animate = 'fade-in' |
| 68 | +color = 'warning' |
| 69 | +body = 'Combining different features!' |
| 70 | +{{< /dropdown >}} |
| 71 | + |
| 72 | +{{< dropdown >}} |
| 73 | +title = 'Multi-line content' |
| 74 | +icon = 'fa-solid fa-align-left' |
| 75 | +body = ''' |
| 76 | +This is multi-line content. |
| 77 | + |
| 78 | +It can include **markdown** and multiple paragraphs. |
| 79 | +And even lists: |
| 80 | + |
| 81 | +- Item 1 |
| 82 | +- Item 2 |
| 83 | +- Item 3 |
| 84 | +''' |
| 85 | +{{< /dropdown >}} |
| 86 | + |
| 87 | +{{< dropdown >}} |
| 88 | +title = 'Dropdown with code' |
| 89 | +icon = 'fa-solid fa-code' |
| 90 | +color = 'success' |
| 91 | +body = ''' |
| 92 | +Here's some code inside a dropdown: |
| 93 | + |
| 94 | +```python |
| 95 | +def hello_world(): |
| 96 | + print("Hello from a dropdown!") |
| 97 | + return 42 |
| 98 | +``` |
| 99 | + |
| 100 | +And more content after the code. |
| 101 | +''' |
| 102 | +{{< /dropdown >}} |
| 103 | + |
| 104 | +{{< dropdown >}} |
| 105 | +title = 'Nested dropdown' |
| 106 | +icon = 'fa-solid fa-folder' |
| 107 | +body = ''' |
| 108 | +This is a dropdown with a nested dropdown inside it. |
| 109 | + |
| 110 | +{{< dropdown >}} |
| 111 | +title = 'Nested dropdown' |
| 112 | +icon = 'fa-solid fa-code' |
| 113 | +body = ''' |
| 114 | +Inside a dropdown in a dropdown! |
| 115 | +''' |
| 116 | +{{< /dropdown >}} |
| 117 | + |
| 118 | +And more content after the inner dropdown. |
| 119 | +''' |
| 120 | +{{< /dropdown >}} |
| 121 | + |
34 | 122 | */}}
|
35 | 123 |
|
36 | 124 | {{- $data := .Inner | transform.Unmarshal -}}
|
37 |
| -<details class="sd-card sd-dropdown sd-mb-3"> |
38 |
| - {{- with $data.color }} |
39 |
| - <summary class="sd-summary-title sd-card-header sd-bg-{{ . }} sd-bg-text-{{ . }}"> |
40 |
| - {{- else }} |
41 |
| - <summary class="sd-summary-title sd-card-header"> |
42 |
| - {{- end }} |
43 |
| - {{- with $data.icon }} |
44 |
| - <span class="sd-summary-icon"><i class="fa {{ . }}"></i></span> |
45 |
| - {{- end }} |
46 |
| - {{- with $data.title }} |
47 |
| - {{- . }} |
48 |
| - {{- else }} |
49 |
| - <i class="fas fa-ellipsis-h"></i> |
50 |
| - {{- end }} |
51 |
| - </summary> |
52 |
| - <div class="sd-summary-content sd-card-body"> |
53 |
| - {{- with (trim $data.body "\n") }} |
54 |
| - {{- . | markdownify }} |
| 125 | + |
| 126 | +{{- $chevronClass := "sd-summary-chevron-right" -}} |
| 127 | +{{- $chevronIcon := "fa-chevron-right" -}} |
| 128 | +{{- if eq $data.chevron "down-up" -}} |
| 129 | + {{- $chevronClass = "sd-summary-chevron-down" -}} |
| 130 | + {{- $chevronIcon = "fa-chevron-down" -}} |
| 131 | +{{- end -}} |
| 132 | + |
| 133 | +{{- $detailsClasses := slice "sd-sphinx-override" "sd-dropdown" "sd-card" "sd-mb-3" -}} |
| 134 | +{{- with $data.animate -}} |
| 135 | + {{- $detailsClasses = $detailsClasses | append (printf "sd-%s" .) -}} |
| 136 | +{{- end -}} |
| 137 | + |
| 138 | +<details class="{{ delimit $detailsClasses " " }}"{{ if $data.open }} open="open"{{ end }}> |
| 139 | + {{- $summaryClasses := slice "sd-summary-title" "sd-card-header" -}} |
| 140 | + {{- with $data.color -}} |
| 141 | + {{- $summaryClasses = $summaryClasses | append (printf "sd-bg-%s" .) -}} |
| 142 | + {{- $summaryClasses = $summaryClasses | append (printf "sd-bg-text-%s" .) -}} |
| 143 | + {{- end -}} |
| 144 | + |
| 145 | + <summary class="{{ delimit $summaryClasses " " }}"> |
| 146 | + {{- with $data.icon }} |
| 147 | + <span class="sd-summary-icon"><i class="fa {{ . }}"></i></span> |
55 | 148 | {{- end }}
|
56 |
| - </div> |
57 |
| -</details> |
| 149 | + <span class="sd-summary-text"> |
| 150 | + {{- with $data.title }} |
| 151 | + {{- . }} |
| 152 | + {{- else }} |
| 153 | + <i class="fas fa-ellipsis-h no-title sd-octicon"></i> |
| 154 | + {{- end }} |
| 155 | + </span> |
| 156 | + <span class="sd-summary-state-marker {{ $chevronClass }}"> |
| 157 | + <i class="fas {{ $chevronIcon }}"></i> |
| 158 | + </span> |
| 159 | + </summary> |
| 160 | + <div class="sd-summary-content sd-card-body docutils"> |
| 161 | + {{- with (trim $data.body "\n") -}} |
| 162 | + {{- . | markdownify -}} |
| 163 | + {{- end -}} |
| 164 | + |
| 165 | + <summary class="{{ delimit $summaryClasses " " }}"> |
| 166 | + {{- with $data.icon }} |
| 167 | + <span class="sd-summary-icon"><i class="fa {{ . }}"></i></span> |
| 168 | + {{- end }} |
| 169 | + <span class="sd-summary-text"> |
| 170 | + {{- with $data.title }} |
| 171 | + {{- . }} |
| 172 | + {{- else }} |
| 173 | + <i class="fas fa-ellipsis-h no-title sd-octicon"></i> |
| 174 | + {{- end }} |
| 175 | + </span> |
| 176 | + <span class="sd-summary-state-marker {{ $chevronClass }}"> |
| 177 | + <i class="fas {{ $chevronIcon }}"></i> |
| 178 | + </span> |
| 179 | + </summary> |
| 180 | + <div class="sd-summary-content sd-card-body docutils"> |
| 181 | + {{- with (trim $data.body "\n") -}} |
| 182 | + {{- . | markdownify -}} |
| 183 | + {{- end -}} |
| 184 | + </div> |
| 185 | + </details> |
0 commit comments