Skip to content

Commit 45b0960

Browse files
authored
Add reagent support to transform prop keys inside vectors (#21937)
- Remove now unnecessary wrapper for reanimated/view - Use kebab-case keywords for the hole-view component - Use rn/StyleSheet.absoluteFill along with ClojureScript styles - Fix keys inside view's `:transform` property - Remove some uses of `merge` to pass styles to components - Add tests for `convert-prop-value`
1 parent 857cb47 commit 45b0960

File tree

23 files changed

+181
-142
lines changed

23 files changed

+181
-142
lines changed

src/quo/components/blur/view.cljs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
([{:keys [style]} child]
1111
(let [theme (quo.theme/use-theme)]
1212
[rn/view
13-
{:style (assoc style
14-
:pointer-events :box-none
15-
:background-color
16-
(or (:background-color style)
17-
(colors/theme-colors colors/white colors/neutral-80 theme)))}
13+
{:style [style
14+
{:pointer-events :box-none
15+
:background-color (or (:background-color style)
16+
(colors/theme-colors colors/white colors/neutral-80 theme))}]}
1817
child])))
1918

2019
(def view (if platform/ios? blur/view view-android))

src/quo/components/buttons/button/style.cljs

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -56,62 +56,63 @@
5656
24 8
5757
12))})
5858

59-
(defn style-container
59+
(defn container-styles
6060
[{:keys [size disabled? border-radius background-color border-color icon-only? icon-top
61-
icon-left icon-right]}]
62-
(merge {:height size
63-
:align-items :center
64-
:justify-content :center
65-
:flex-direction (if icon-top :column :row)
66-
:padding-horizontal (when-not (or icon-only? icon-left icon-right)
67-
(case size
68-
56 (if border-color 10 11)
69-
40 16
70-
32 12
71-
24 7
72-
16))
73-
:padding-left (when-not (or icon-only? icon-left)
74-
(case size
75-
56 nil
76-
40 16
77-
32 12
78-
24 8
79-
16))
80-
:padding-right (when-not (or icon-only? icon-right)
81-
(case size
82-
56 nil
83-
40 16
84-
32 12
85-
24 8
86-
16))
87-
:padding-top (when-not (or icon-only? icon-left icon-right)
88-
(case size
89-
56 0
90-
40 (if border-color 8 9)
91-
32 (if border-color 4 5)
92-
24 0
93-
(if border-color 8 9)))
94-
:padding-bottom (when-not (or icon-only? icon-left icon-right)
95-
(case size
96-
56 0
97-
40 9
98-
32 5
99-
24 0
100-
9))
101-
:overflow :hidden
102-
:background-color (if disabled? (colors/alpha background-color 0.3) background-color)
103-
:border-radius (if border-radius
104-
border-radius
105-
(case size
106-
56 12
107-
40 12
108-
32 10
109-
24 8
110-
12))
111-
:border-color border-color
112-
:border-width (when border-color 1)}
113-
(when icon-only?
114-
{:width size})
115-
(when border-color
116-
{:border-color border-color
117-
:border-width 1})))
61+
icon-left icon-right inner-style]}]
62+
[{:height size
63+
:align-items :center
64+
:justify-content :center
65+
:flex-direction (if icon-top :column :row)
66+
:padding-horizontal (when-not (or icon-only? icon-left icon-right)
67+
(case size
68+
56 (if border-color 10 11)
69+
40 16
70+
32 12
71+
24 7
72+
16))
73+
:padding-left (when-not (or icon-only? icon-left)
74+
(case size
75+
56 nil
76+
40 16
77+
32 12
78+
24 8
79+
16))
80+
:padding-right (when-not (or icon-only? icon-right)
81+
(case size
82+
56 nil
83+
40 16
84+
32 12
85+
24 8
86+
16))
87+
:padding-top (when-not (or icon-only? icon-left icon-right)
88+
(case size
89+
56 0
90+
40 (if border-color 8 9)
91+
32 (if border-color 4 5)
92+
24 0
93+
(if border-color 8 9)))
94+
:padding-bottom (when-not (or icon-only? icon-left icon-right)
95+
(case size
96+
56 0
97+
40 9
98+
32 5
99+
24 0
100+
9))
101+
:overflow :hidden
102+
:background-color (if disabled? (colors/alpha background-color 0.3) background-color)
103+
:border-radius (if border-radius
104+
border-radius
105+
(case size
106+
56 12
107+
40 12
108+
32 10
109+
24 8
110+
12))
111+
:border-color border-color
112+
:border-width (when border-color 1)}
113+
(when icon-only?
114+
{:width size})
115+
(when border-color
116+
{:border-color border-color
117+
:border-width 1})
118+
inner-style])

src/quo/components/buttons/button/view.cljs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,18 @@
6262
:on-press on-press
6363
:allow-multiple-presses? allow-multiple-presses?
6464
:on-long-press on-long-press
65-
:style (merge
66-
(style/shape-style-container size border-radius)
67-
container-style)}
65+
:style [(style/shape-style-container size border-radius) container-style]}
6866
[rn/view
69-
{:style (merge
70-
(style/style-container {:size size
67+
{:style (style/container-styles {:size size
7168
:disabled? disabled?
7269
:border-radius border-radius
7370
:background-color background-color
7471
:border-color border-color
7572
:icon-only? icon-only?
7673
:icon-top icon-top
7774
:icon-left icon-left
78-
:icon-right icon-right})
79-
inner-style)}
75+
:icon-right icon-right
76+
:inner-style inner-style})}
8077
(when overlay-customization-color
8178
[customization-colors/overlay
8279
{:customization-color overlay-customization-color

src/quo/components/drawers/drawer_top/view.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
button-disabled? account-avatar-emoji account-avatar-type customization-color icon-avatar
202202
context icon]}]
203203
(let [theme (quo.theme/use-theme)]
204-
[rn/view {:style (merge style/container container-style)}
204+
[rn/view {:style [style/container container-style]}
205205
(when (left-image-supported-types type)
206206
[rn/view {:style style/left-container}
207207
[left-image

src/quo/components/gradient/gradient_cover/view.cljs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
:colors [color-top color-bottom]
1919
:start {:x 0 :y 0}
2020
:end {:x 0 :y 1}
21-
:style (merge (style/root-container opacity height)
22-
container-style)}])))
21+
:style [(style/root-container opacity height)
22+
container-style]}])))

src/quo/components/inputs/input/view.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
:char-limit char-limit
132132
:theme theme}])
133133
[rn/view
134-
{:style (merge (style/input-container colors-by-status small? disabled?) input-container-style)}
134+
{:style [(style/input-container colors-by-status small? disabled?) input-container-style]}
135135
(when-let [{:keys [icon-name]} left-icon]
136136
[left-accessory
137137
{:variant-colors variant-colors

src/quo/components/keycard/style.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
(colors/theme-colors colors/neutral-100 colors/white theme))
3737
:align-self :center
3838
:height 280.48
39-
:transform [{:rotate "-30deg"} {:translateY -30}]
39+
:transform [{:rotate "-30deg"} {:translate-y -30}]
4040
:opacity (when-not locked? 0.02)
4141
:z-index 1})
4242

src/quo/components/messages/gap.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
:margin-left -4}
4949
(if (= type :top)
5050
{:top 0}
51-
{:transform [{:rotateZ "180deg"}]
51+
{:transform [{:rotate-z "180deg"}]
5252
:bottom 0})
5353
style)}]))
5454

src/quo/components/settings/category/data_item/view.cljs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[{:keys [label data container-style blur?]}]
1111
(let [theme (quo.theme/use-theme)
1212
last-item (rn/use-memo #(last data) [data])]
13-
[rn/view {:style (merge (style/container label) container-style)}
13+
[rn/view {:style [(style/container label) container-style]}
1414
(when label
1515
[text/text
1616
{:weight :medium
@@ -29,4 +29,3 @@
2929
[data-item/view data-item-props]
3030
(when-not (= item last-item)
3131
[rn/view {:style (style/settings-separator blur? theme)}])])]]))
32-

src/quo/components/settings/category/reorder/view.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
separator (rn/use-memo (fn [] [rn/view
2525
{:style (style/reorder-separator blur? theme)}])
2626
[blur? theme])]
27-
[rn/view {:style (merge (style/container label) container-style)}
27+
[rn/view {:style [(style/container label) container-style]}
2828
[text/text
2929
{:weight :medium
3030
:size :paragraph-2

0 commit comments

Comments
 (0)