Skip to content

Commit 75a05de

Browse files
committed
[nested-v-grid] Fix layout & pathing bugs
1 parent 6422a17 commit 75a05de

File tree

5 files changed

+26
-24
lines changed

5 files changed

+26
-24
lines changed

run/resources/public/assets/css/re-com.css

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,9 +1565,8 @@ code {
15651565
font-size: 13px;
15661566
background-color: #eee;
15671567
color: #777;
1568-
padding-top: 3px;
15691568
padding-right: 3px;
1570-
padding-left: 3px;
1569+
padding-left: 6px;
15711570
text-align: left;
15721571
border-bottom: thin solid #ccc;
15731572
border-left: thin solid #ccc;
@@ -1585,15 +1584,13 @@ code {
15851584
}
15861585

15871586
.rc-nested-v-grid-column-header-grid > div:not(.rc-nested-v-grid-resizer) {
1587+
overflow: hidden;
15881588
text-overflow: ellipsis;
15891589
white-space: nowrap;
15901590
user-select: none;
15911591
font-size: 13px;
15921592
background-color: #eee;
15931593
color: #777;
1594-
padding-top: 3px;
1595-
padding-right: 3px;
1596-
padding-left: 3px;
15971594
text-align: center;
15981595
border-top: thin solid #ccc;
15991596
border-right: thin solid #ccc;

src/re_com/nested_v_grid.cljs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@
650650
path-ct (count column-path)
651651
end-path (some #(when (= (count %) path-ct) %)
652652
(drop (inc i) @column-paths))
653-
{:keys [branch-end?]} (meta column-path)
653+
{:keys [branch-end? branch? leaf?]} (meta column-path)
654654
column-path-prop (cond-> column-path (not show-root-headers?) (subvec 1))]
655655
#_#_:when (not branch-end?)
656656
:let [props {:part ::column-header
@@ -659,7 +659,10 @@
659659
:branch-end? branch-end?
660660
:keypath (get @column-keypaths i)
661661
:style {:grid-column-start (ngu/path->grid-line-name column-path)
662-
:grid-column-end (ngu/path->grid-line-name end-path)
662+
:grid-column-end (cond
663+
end-path (ngu/path->grid-line-name end-path)
664+
leaf? "span 1"
665+
:else "-1")
663666
:grid-row-start (cond-> (count column-path)
664667
branch-end? dec
665668
(not show-root-headers?) dec)
@@ -705,10 +708,16 @@
705708
cells
706709
(for [row-path @row-paths
707710
column-path @column-paths
708-
:when (and ((some-fn :leaf? :show?) (meta row-path))
709-
((some-fn :leaf? :show?) (meta column-path)))
710-
:let [props {:row-path (cond-> row-path show-root-headers? (subvec 1))
711-
:column-path (cond-> column-path show-root-headers? (subvec 1))
711+
:let [row-meta (meta row-path)
712+
column-meta (meta column-path)]
713+
:when (and ((some-fn :leaf? :show?) row-meta)
714+
((some-fn :leaf? :show?) column-meta))
715+
:let [props {:row-path (cond-> row-path
716+
(not show-root-headers?) (subvec 1)
717+
(:branch-end? row-meta) pop)
718+
:column-path (cond-> column-path
719+
(not show-root-headers?) (subvec 1)
720+
(:branch-end? column-meta) pop)
712721
:style {:grid-row-start (ngu/path->grid-line-name row-path)
713722
:grid-column-start (ngu/path->grid-line-name column-path)}}
714723
props (merge props
@@ -724,12 +733,7 @@
724733
:after-props {:style style
725734
:class class}
726735
:props
727-
{:style {:height 300
728-
:width 500
729-
:overflow :auto
730-
:flex "0 0 auto"
731-
:display :grid
732-
:grid-template-rows (ngu/grid-cross-template [@column-header-height-total @row-height-total])
736+
{:style {:grid-template-rows (ngu/grid-cross-template [@column-header-height-total @row-height-total])
733737
:grid-template-columns (ngu/grid-cross-template [@row-header-width-total @column-width-total])}
734738
:attr {:ref wrapper-ref!}
735739
:children

src/re_com/nested_v_grid/parts.cljs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212

1313
(defn header-label [{:keys [path]}]
1414
(let [spec (peek path)]
15-
(or (:label spec)
16-
(some-> spec :id str)
17-
(some-> spec str))))
15+
[:div
16+
(or (:label spec)
17+
(some-> spec :id str)
18+
(some-> spec str))]))
1819

1920
(def row-header-label header-label)
2021

src/re_com/nested_v_grid/theme.cljs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
(defn style [props & ms] (apply update props :style merge ms))
1212

1313
(defmethod base ::nvg/wrapper [props]
14-
(style props {:height 300
15-
:width "100%"
16-
:overflow :auto
14+
(style props {:overflow :auto
1715
:flex "1 1 auto"
1816
:display :grid}))
1917

@@ -52,7 +50,7 @@
5250
:padding-left sm-4
5351
:background-color light-background
5452
:color "#666"
55-
:font-size "13px"
53+
:font-size 13
5654
:text-overflow :ellipsis
5755
:overflow :hidden
5856
:white-space :nowrap}))

src/re_com/nested_v_grid/util.cljc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
own-path (conj path (get-header-spec node))
8888
own-size (walk path (get-header-spec node) {:collect-anyway? true
8989
:is-leaf? is-leaf?
90+
:branch-path? (not is-leaf?)
9091
:keypath (conj keypath 0)
9192
:branch-end? branch-end?
9293
:last-child? last-child?})
@@ -124,6 +125,7 @@
124125
(or is-leaf? show-above?)
125126
(vary-meta merge {}
126127
(when is-leaf? {:leaf? true})
128+
(when-not is-leaf? {:branch? true})
127129
(when branch-end? {:branch-end? true})
128130
(when show-above? {:show-above? true})
129131
(when last-child? {:last-child? true})))]

0 commit comments

Comments
 (0)