Fork me on GitHub
Eccentric J08:06:30

Does anyone have or know of any examples of using spec with reagent views?

Joe Lane15:07:28

Hey @jayzawrotny, I'm a little late to the party, but I found this blog post to be very apropos


@jayzawrotny I do have one example from a commercial app I've worked on for the last few years:

(s/fdef dre.components.widget/widget
     :req-un [::title ;; title in header
              ::content ;; Contents to show in widget. It must be a Hiccup
              ;; vector. Widget does not support varying arguments in
              ;; content, they are for initialization only.
     :opt-un [::id ;; unique identifier for widget (page wide, not app
              ;; wide)
              ::icon ;; icon to show in header
              ::widget-class ;; CSS class
              ::collapsable? ;; If it can be collapsed
              ::init-collapsed? ;; initialize the widget in a collapsed
              ;; state?
              ::help ;; help contents which are shown in modal
              ::controls ;; Arbitrary component rendered in the
              ;; header. What it does is up to you.
              ::selections ;; coll of dropdown/tabs
              ::dropdown ;; convenience option, singular version of
              ;; selections with
              ;; {:type :dropdown, :id :dropdown} by default
              ::tabs ;; convenience option, singular version of selections
              ;; with {:type :tabs, :id :tabs}
              ::loading? ;; Whether or not to display a loading indicator
              ::locked? ;; Whether or not content modifications are possible
              ::menu ;; menu
   (fn [{:keys [opts]}]
     (if-let [unexpected
              (seq (apply dissoc opts expected-keys))]
         (warn "Unexpected options" unexpected)


@jayzawrotny This is about the only Reagent component I've spec-ed because it has so many options


Not sure if it's useful, but this is the app: (this is a free preview of it)

Eccentric J18:06:03

Thanks @borkdude this really helps!