From b8cd4abfef95bdceff2a17d0d265caeb1620e513 Mon Sep 17 00:00:00 2001 From: Jarrod Millman Date: Fri, 9 Feb 2024 15:47:41 -0800 Subject: [PATCH] Add dropdown in card --- layouts/shortcodes/card.html | 11 +++++++++++ layouts/shortcodes/dropdown.html | 26 ++++++++++++-------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/layouts/shortcodes/card.html b/layouts/shortcodes/card.html index 7a8707f0..3299c530 100644 --- a/layouts/shortcodes/card.html +++ b/layouts/shortcodes/card.html @@ -23,6 +23,17 @@ ''' {{< /card >}} +{{< card >}} +title = 'A card with a dropdown menu' +body = ''' +{{< dropdown >}} +title = 'Click to expand dropdown' +icon = 'eye' +body = 'Hidden content' +{{< /dropdown >}} +''' +{{< /card >}} + {{< card >}} title = 'A clickable card' link = 'https://example.com' diff --git a/layouts/shortcodes/dropdown.html b/layouts/shortcodes/dropdown.html index 0094dc86..876291ff 100644 --- a/layouts/shortcodes/dropdown.html +++ b/layouts/shortcodes/dropdown.html @@ -34,30 +34,28 @@ */}} {{- $data := .Inner | transform.Unmarshal -}} -
- {{ with $data.color }} + {{- with $data.color }} - {{ else }} + {{- else }} - {{ end }} - {{ with $data.icon }} + {{- end }} + {{- with $data.icon }} - {{ end }} - {{ with $data.title }} - {{ . }} - {{ else }} + {{- end }} + {{- with $data.title }} + {{- . }} + {{- else }} - {{ end }} + {{- end }}
-
- {{ with (trim $data.body "\n") }} - {{ . | markdownify }} - {{ end }} + {{- with (trim $data.body "\n") }} + {{- . | markdownify }} + {{- end }}