Skip to content

Commit f06016f

Browse files
committed
[dropdown] Adjust width/height props
1 parent 1386786 commit f06016f

File tree

4 files changed

+32
-26
lines changed

4 files changed

+32
-26
lines changed

src/re_com/dropdown.cljs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,12 @@
360360
:exit (js/setTimeout (fn [] (reset! transitionable :out)) 50)))
361361
theme (theme/defaults
362362
args
363-
{:user [(theme/<-props (merge args
364-
(when anchor-height {:height anchor-height})
365-
(when width {:width width})
366-
(when anchor-width {:width anchor-width}))
363+
{:user [(theme/<-props (-> args
364+
(dissoc :height)
365+
(merge
366+
(when anchor-height {:height anchor-height})
367+
(when width {:width width})
368+
(when anchor-width {:width anchor-width})))
367369
{:part ::anchor-wrapper
368370
:exclude [:max-height :min-height]})
369371
(theme/<-props (merge args

src/re_com/theme/default.cljs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@
158158
(->> {}
159159
(case part
160160

161-
::dropdown/wrapper
162-
{:style {:max-width "250px"}}
163-
164161
::dropdown/body-wrapper
165162
{:style {:background-color "white"
166163
:border-radius "4px"

src/re_demo/dropdown.cljs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@
1212

1313
(defn panel*
1414
[]
15-
(let [width (r/atom 200)
16-
height (r/atom 200)
17-
min-width (r/atom 200)
18-
max-width (r/atom 200)
19-
max-height (r/atom 200)
20-
min-height (r/atom 200)
21-
body-width (r/atom 200)
22-
anchor-width (r/atom 200)]
15+
(let [width (r/atom 200)
16+
height (r/atom 200)
17+
min-width (r/atom 200)
18+
max-width (r/atom 200)
19+
max-height (r/atom 200)
20+
min-height (r/atom 200)
21+
anchor-height (r/atom 200)
22+
body-width (r/atom 200)
23+
body-height (r/atom 200)
24+
anchor-width (r/atom 200)]
2325
(fn []
2426
[v-box :src (at) :size "auto" :gap "10px"
2527
:children
@@ -52,6 +54,8 @@
5254
:model model
5355
:width (some-> @width px)}
5456
(when @height {:height (px @height)})
57+
(when @anchor-height {:anchor-height (px @anchor-height)})
58+
(when @body-height {:body-height (px @body-height)})
5559
{:min-width (some-> @min-width px)
5660
:max-width (some-> @max-width px)
5761
:max-height (some-> @max-height px)
@@ -68,14 +72,17 @@
6872
:children [[title3 "Interactive Parameters" {:margin-top "0"}]
6973
[v-box :src (at)
7074
:gap "20px"
71-
:children [[prop-slider {:prop width :id :width :default 212 :default-on? false}]
72-
[prop-slider {:prop height :id :height :default 212 :default-on? false}]
73-
[prop-slider {:prop min-width :id :min-width :default 212 :default-on? false}]
74-
[prop-slider {:prop max-width :id :max-width :default 212 :default-on? false}]
75-
[prop-slider {:prop min-height :id :min-height :default 212 :default-on? false}]
76-
[prop-slider {:prop max-height :id :max-height :default 212 :default-on? false}]
77-
[prop-slider {:prop body-width :id :body-width :default 212 :default-on? false}]
78-
[prop-slider {:prop anchor-width :id :anchor-width :default 212 :default-on? false}]]]]]]]]]
75+
:children
76+
[[prop-slider {:prop width :id :width :default 212 :default-on? false}]
77+
[prop-slider {:prop height :id :height :default 212 :default-on? false}]
78+
[prop-slider {:prop min-width :id :min-width :default 212 :default-on? false}]
79+
[prop-slider {:prop max-width :id :max-width :default 212 :default-on? false}]
80+
[prop-slider {:prop min-height :id :min-height :default 212 :default-on? false}]
81+
[prop-slider {:prop max-height :id :max-height :default 212 :default-on? false}]
82+
[prop-slider {:prop body-width :id :body-width :default 212 :default-on? false}]
83+
[prop-slider {:prop body-height :id :body-height :default 212 :default-on? false}]
84+
[prop-slider {:prop anchor-height :id :anchor-height :default 35 :default-on? false :min 10 :max 50}]
85+
[prop-slider {:prop anchor-width :id :anchor-width :default 212 :default-on? false}]]]]]]]]]
7986
[parts-table "dropdown" dropdown-parts-desc]]])))
8087

8188
;; core holds a reference to panel, so need one level of indirection to get figwheel updates

src/re_demo/utils.cljs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216
[element]
217217
(set! (.-scrollTop element) 0))
218218

219-
(defn prop-slider [{:keys [prop default default-on? id] :or {default-on? true}}]
219+
(defn prop-slider [{:keys [prop default default-on? id min max] :or {default-on? true min 40 max 500}}]
220220
(let [default (or @prop default)]
221221
(when (and default-on? default)
222222
(reset! prop default))
@@ -239,8 +239,8 @@
239239
[rc/slider
240240
:model prop
241241
:on-change #(reset! prop %)
242-
:min 50
243-
:max 400
242+
:min min
243+
:max max
244244
:step 1
245245
:width "300px"]
246246
[gap :src (at) :size "5px"]

0 commit comments

Comments
 (0)