Skip to content

Commit 4dc6d6b

Browse files
committed
[nested-v-grid] Condense app demos
1 parent 7b48888 commit 4dc6d6b

File tree

1 file changed

+52
-60
lines changed

1 file changed

+52
-60
lines changed

src/re_demo/nested_v_grid.cljs

Lines changed: 52 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -233,60 +233,6 @@
233233
:three {:right 3 :label "3"}
234234
:four {:right 4 :label "4"}})
235235

236-
(defn multimodal-demo []
237-
[rc/v-box
238-
:gap "12px"
239-
:children
240-
[(let [{:keys [add multiply lookup]} operators
241-
{:keys [one two three four]} operands]
242-
[nested-v-grid
243-
{:column-tree [{:id "left"}
244-
[add [one] [two]]
245-
[multiply [one] [two]]
246-
[lookup [one] [two]]]
247-
:row-tree [{:id "right"} [three] [four]]
248-
:parts {:cell {:style {:text-align "center"}}}
249-
:cell-label (fn [{:keys [column-path row-path]}]
250-
(let [{:keys [operator left right]}
251-
(->> (into row-path column-path)
252-
(apply merge))]
253-
(operator left right)))}])
254-
[source-reference
255-
"for above nested-grid"
256-
"src/re_demo/nested_grid.cljs"]
257-
[rc/p "Here, we use " [:i "specs"] " like " [:code "multiply"]
258-
" and " [:code "lookup"] " to build a multi-modal view of the source data."
259-
" In other words, a " [:code ":column-spec"] " or " [:code ":row-spec"] " can express not just " [:i "what"] " to show in the cell, but also " [:i "how"] " to show it."]
260-
[rdu/code
261-
"(def lookup-table
262-
[[\"🚓\" \"🛵\" \"🚲\" \"🛻\" \"🚚\"] [\"🍐\" \"🍎\" \"🍌\" \"🥝\" \"🍇\"]
263-
[\"🐕\" \"🐎\" \"🧸\" \"🐈\" \"🐟\"]])"
264-
"(def operators
265-
{:add {:operator + :label \"Addition\"}
266-
:multiply {:operator * :label \"Multiplication\"}
267-
:lookup {:operator (fn [l r]
268-
(get-in lookup-table [l r]))
269-
:label \"Lookup\"}})"
270-
"(def operands
271-
{:one {:left 1 :label \"1\"}
272-
:two {:left 2 :label \"2\"}
273-
:three {:right 3 :label \"3\"}
274-
:four {:right 4 :label \"4\"}})"
275-
"(let [{:keys [add multiply lookup]} operators
276-
{:keys [one two three four]} operands]
277-
[nested-v-grid
278-
{:column-tree [{:id \"left\"}
279-
[add [one] [two]]
280-
[multiply [one] [two]]
281-
[lookup [one] [two]]]
282-
:row-tree [{:id \"right\"} [three] [four]]
283-
:parts {:cell {:style {:text-align \"center\"}}}
284-
:cell-label (fn [{:keys [column-path row-path]}]
285-
(let [{:keys [operator left right]}
286-
(->> (into row-path column-path)
287-
(apply merge))]
288-
(operator left right)))}])"]]])
289-
290236
(def lorem-ipsum ["Lorem" "ipsum" "dolor" "sit" "amet" " consectetur" "adipiscing" "elit" " sed"
291237
"do" "eiusmod" "tempor" "incididunt" "ut" "labore" "et" "dolore" "magna"
292238
"aliqua."])
@@ -665,7 +611,57 @@
665611
[rc/v-box
666612
:gap "12px"
667613
:children
668-
[[nested-v-grid
614+
[(let [{:keys [add multiply lookup]} operators
615+
{:keys [one two three four]} operands]
616+
[nested-v-grid
617+
{:column-tree [{:id "left"}
618+
[add [one] [two]]
619+
[multiply [one] [two]]
620+
[lookup [one] [two]]]
621+
:row-tree [{:id "right"} [three] [four]]
622+
:parts {:cell {:style {:text-align "center"}}}
623+
:cell-label (fn [{:keys [column-path row-path]}]
624+
(let [{:keys [operator left right]}
625+
(->> (into row-path column-path)
626+
(apply merge))]
627+
(operator left right)))}])
628+
[source-reference
629+
"for above nested-grid"
630+
"src/re_demo/nested_grid.cljs"]
631+
[rc/p "Here, we use " [:i "specs"] " like " [:code "multiply"]
632+
" and " [:code "lookup"] " to build a multi-modal view of the source data."
633+
" In other words, a " [:code ":column-spec"] " or " [:code ":row-spec"] " can express not just " [:i "what"] " to show in the cell, but also " [:i "how"] " to show it."]
634+
[rdu/code
635+
"(def lookup-table
636+
[[\"🚓\" \"🛵\" \"🚲\" \"🛻\" \"🚚\"] [\"🍐\" \"🍎\" \"🍌\" \"🥝\" \"🍇\"]
637+
[\"🐕\" \"🐎\" \"🧸\" \"🐈\" \"🐟\"]])"
638+
"(def operators
639+
{:add {:operator + :label \"Addition\"}
640+
:multiply {:operator * :label \"Multiplication\"}
641+
:lookup {:operator (fn [l r]
642+
(get-in lookup-table [l r]))
643+
:label \"Lookup\"}})"
644+
"(def operands
645+
{:one {:left 1 :label \"1\"}
646+
:two {:left 2 :label \"2\"}
647+
:three {:right 3 :label \"3\"}
648+
:four {:right 4 :label \"4\"}})"
649+
"(let [{:keys [add multiply lookup]} operators
650+
{:keys [one two three four]} operands]
651+
[nested-v-grid
652+
{:column-tree [{:id \"left\"}
653+
[add [one] [two]]
654+
[multiply [one] [two]]
655+
[lookup [one] [two]]]
656+
:row-tree [{:id \"right\"} [three] [four]]
657+
:parts {:cell {:style {:text-align \"center\"}}}
658+
:cell-label (fn [{:keys [column-path row-path]}]
659+
(let [{:keys [operator left right]}
660+
(->> (into row-path column-path)
661+
(apply merge))]
662+
(operator left right)))}])"]
663+
[rc/line]
664+
[nested-v-grid
669665
{:row-header-width 85
670666
:show-root-headers? false
671667
:column-tree [:root 1 2 3]
@@ -1027,11 +1023,7 @@
10271023
(defn demos []
10281024
(let [tabs [{:id :options :label "Options" :view options-demo}
10291025
{:id :basic :label "Basics" :view basic-demo}
1030-
#_{:id :internals :label "Internals" :view internals-demo}
1031-
{:id :multimodal :label "Multimodal" :view multimodal-demo}
1032-
{:id :app :label "Applications" :view app-demo}
1033-
#_{:id :v-grid :label "Virtualization" :view virtualization-demo}
1034-
#_{:id :style :label "Style" :view style-demo}]
1026+
{:id :app :label "Applications" :view app-demo}]
10351027
!tab-id (r/atom (:id (first tabs)))
10361028
!tab (r/reaction (u/item-for-id @!tab-id tabs))]
10371029
(fn []

0 commit comments

Comments
 (0)