-
Notifications
You must be signed in to change notification settings - Fork 8
/
devcards.clj
29 lines (26 loc) · 1.09 KB
/
devcards.clj
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
(ns dumdom.devcards
"Devcards helpers for dumdom. dumdom.devcards/defcard is a drop-in replacement
for devcards.core/defcard that supports dumdom components.
The macro and helper function were lifted from devcards, and lightly adjusted
to allow for dumdom components to automatically be wrapped in React elements,
allowing them to be seamlessly rendered by devcards."
(:require [devcards.core :as devcards]
[devcards.util.utils :as utils]))
(defn card
([vname docu main-obj initial-data options]
`(devcards.core/defcard* ~(symbol (name vname))
(devcards.core/card-base
{:name ~(name vname)
:documentation ~docu
:main-obj (dumdom.devcards/reactify ~main-obj)
:initial-data ~initial-data
:options ~options})))
([vname docu main-obj initial-data]
(card vname docu main-obj initial-data {}))
([vname docu main-obj]
(card vname docu main-obj {} {}))
([vname docu]
(card vname docu nil {} {})))
(defmacro defcard [& expr]
(when (utils/devcards-active?)
(apply dumdom.devcards/card (devcards/parse-card-args expr 'card))))