Skip to content

Instantly share code, notes, and snippets.

@0xqd
Created December 19, 2015 14:53
Show Gist options
  • Save 0xqd/2505dcff4f53c4b9ceeb to your computer and use it in GitHub Desktop.
Save 0xqd/2505dcff4f53c4b9ceeb to your computer and use it in GitHub Desktop.
(defn accordion-test
[x]
(let [{:keys [title content active?]} x]
[:div.accordion
{:class (when active? "active")}
[:div.title
{:on-click #(prn "something")
:style {:cursor "pointer"}}
title]
[:div.content
{:style {:max-height 0
:overflow "hidden"
:transition "all .15s ease"}}
content]]))
(accordion-test {:a "a"
:b "b"})
(defui Accordions
Object
(render
[this]
(let [accordions [{:title "Title 1"
:content "Content 1"
:active? true}
{:title "Title 2"
:content "Content 2"
:active? false}
]]
(sab/html
[:div.accordions
(map #(accordion-test %) accordions)]))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment