Skip to content

Commit

Permalink
Transpose row-paths comprehension
Browse files Browse the repository at this point in the history
Now we iterate column-paths for each row-path.
This could make optimizations possible in the calling code.
  • Loading branch information
kimo-k committed Jun 5, 2024
1 parent 4ed4b33 commit de4a5cc
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/re_com/nested_grid.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -877,24 +877,24 @@
(= x (dec row-depth)) (conj :right))}]]
^{:key [::header-spacer x y]}
[u/part header-spacer-wrapper props header-spacer-wrapper-part])
cells (doall
(for [column-path showing-column-paths
row-path showing-row-paths
:let [props (merge {:column-path column-path
:row-path row-path
:cell cell
:theme theme
:edge (cond-> #{}
(= column-path (first showing-column-paths)) (conj :left)
(= column-path (last showing-column-paths)) (conj :right)
(= row-path (first showing-row-paths)) (conj :top)
(= row-path (last showing-row-paths)) (conj :bottom)
(cell-section-left? column-path) (conj :column-section-left)
(cell-section-right? column-path) (conj :column-section-right))}
(when cell-value
{:cell-value cell-value}))]]
^{:key [::cell-wrapper (or [column-path row-path] (gensym))]}
[u/part cell-wrapper props cell-wrapper-part]))
cells (vec
(for [row-path showing-row-paths]
(vec (for [column-path showing-column-paths
:let [props (merge {:column-path column-path
:row-path row-path
:cell cell
:theme theme
:edge (cond-> #{}
(= column-path (first showing-column-paths)) (conj :left)
(= column-path (last showing-column-paths)) (conj :right)
(= row-path (first showing-row-paths)) (conj :top)
(= row-path (last showing-row-paths)) (conj :bottom)
(cell-section-left? column-path) (conj :column-section-left)
(cell-section-right? column-path) (conj :column-section-right))}
(when cell-value
{:cell-value cell-value}))]]
^{:key [::cell-wrapper (or [column-path row-path] (gensym))]}
[u/part cell-wrapper props cell-wrapper-part]))))
zebra-stripes (for [i (filter even? (range 1 (inc (count row-paths))))]
^{:key [::zebra-stripe i]}
[:div
Expand Down

0 comments on commit de4a5cc

Please sign in to comment.