Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating hiccup to pure react component usage (First step) #18574

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/legacy/status_im/bottom_sheet/sheets.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
(rn/hw-back-add-listener dismiss-bottom-sheet-callback)
(fn []
(rn/hw-back-remove-listener dismiss-bottom-sheet-callback))))
[theme/provider {:theme (or page-theme (theme/get-theme))}
[theme/provider (or page-theme (theme/get-theme))
[bottom-sheet/bottom-sheet opts
(when content
[content (when options options)])]])]))
4 changes: 2 additions & 2 deletions src/quo/components/avatars/account_avatar/component_spec.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{:height (:size opts)
:width (:size opts)
:borderRadius (style/get-border-radius (:size opts))
:backgroundColor (colors/resolve-color (:customization-color opts) :dark)})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @flexsurfer, why these values reversed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk , probably there was a bug before?

:backgroundColor (colors/resolve-color (:customization-color opts) :light)})
(h/is-truthy (h/query-by-label-text :account-emoji))
(h/has-style (h/query-by-label-text :account-emoji)
{:fontSize (style/get-emoji-size (:size opts))})
Expand Down Expand Up @@ -65,7 +65,7 @@
{:height (:size opts)
:width (:size opts)
:borderRadius (style/get-border-radius (:size opts))
:backgroundColor (colors/resolve-color (:customization-color opts) :dark)})
:backgroundColor (colors/resolve-color (:customization-color opts) :light)})
(h/is-truthy (h/query-by-label-text :account-emoji))
(h/has-style (h/query-by-label-text :account-emoji)
{:fontSize (style/get-emoji-size (:size opts))})
Expand Down
5 changes: 3 additions & 2 deletions src/quo/components/avatars/account_avatar/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@


(defn root-container
[{:keys [type size theme customization-color]
[{:keys [type size customization-color]
:or {size default-size
customization-color :blue}}]
customization-color :blue}}
theme]
(let [watch-only? (= type :watch-only)
width (cond-> size
(keyword? size) (container-size size))]
Expand Down
17 changes: 9 additions & 8 deletions src/quo/components/avatars/account_avatar/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[clojure.string :as string]
[quo.components.avatars.account-avatar.style :as style]
[quo.theme :as quo.theme]
[react-native.core :as rn]))
[react-native.pure :as rn.pure]))

(defn- view-internal
(defn- view-pure
"Opts:

:type - keyword -> :default/:watch-only
Expand All @@ -21,15 +21,16 @@
:or {size style/default-size
emoji "🍑"}
:as opts}]
(let [emoji-size (style/get-emoji-size size)]
[rn/view
(let [theme (quo.theme/use-theme)
emoji-size (style/get-emoji-size size)]
(rn.pure/view
{:accessible true
:accessibility-label :account-avatar
:style (style/root-container opts)}
[rn/text
:style (style/root-container opts theme)}
(rn.pure/text
{:accessibility-label :account-emoji
:adjusts-font-size-to-fit true
:style {:font-size emoji-size}}
(when emoji (string/trim emoji))]]))
(when emoji (string/trim emoji))))))

(def view (quo.theme/with-theme view-internal))
(defn view [params] (rn.pure/func view-pure params))
50 changes: 25 additions & 25 deletions src/quo/components/avatars/group_avatar/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[quo.components.icon :as icon]
[quo.foundations.colors :as colors]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[react-native.fast-image :as fast-image]))
[react-native.fast-image :as fast-image]
[react-native.pure :as rn.pure]))

(def sizes
{:size-20 {:icon 12
Expand All @@ -19,27 +19,27 @@
:size-80 {:icon 32
:container 80}})

(defn- view-internal
[_]
(fn [{:keys [size theme customization-color picture icon-name]
:or {size :size-20
customization-color :blue
picture nil
icon-name :i/group}}]
(let [container-size (get-in sizes [size :container])
icon-size (get-in sizes [size :icon])]
[rn/view
{:accessibility-label :group-avatar
:style (style/container {:container-size container-size
:customization-color customization-color
:theme theme})}
(if picture
[fast-image/fast-image
{:source picture
:style {:width container-size
:height container-size}}]
[icon/icon icon-name
{:size icon-size
:color colors/white-opa-70}])])))
(defn- view-pure
[{:keys [size customization-color picture icon-name]
:or {size :size-20
customization-color :blue
picture nil
icon-name :i/group}}]
(let [theme (quo.theme/use-theme)
container-size (get-in sizes [size :container])
icon-size (get-in sizes [size :icon])]
(rn.pure/view
{:accessibility-label :group-avatar
:style (style/container {:container-size container-size
:customization-color customization-color
:theme theme})}
(if picture
(fast-image/fast-image
{:source picture
:style {:width container-size
:height container-size}})
(icon/icon icon-name
{:size icon-size
:color colors/white-opa-70})))))

(def view (quo.theme/with-theme view-internal))
(defn view [props] (rn.pure/func view-pure props))
3 changes: 2 additions & 1 deletion src/quo/components/avatars/user_avatar/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
{:length amount-initials
:full-name full-name
:font-size (:font-size (text/text-style {:size
font-size}))
font-size}
nil))
:indicator-size (when status-indicator?
(:status-indicator sizes))
:indicator-border (when status-indicator?
Expand Down
17 changes: 9 additions & 8 deletions src/quo/components/avatars/wallet_user_avatar/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[quo.components.avatars.wallet-user-avatar.style :as style]
[quo.components.markdown.text :as text]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[react-native.pure :as rn.pure]
utils.string))

(def properties
Expand Down Expand Up @@ -34,7 +34,7 @@
(= size second-smallest-possible)))
(def biggest-possible (last (keys properties)))

(defn- view-internal
(defn- view-pure
"Options:

:full-name - string (default: nil) - used to generate initials
Expand All @@ -44,18 +44,19 @@
:monospace? - boolean (default: false) - use monospace font
:lowercase? - boolean (default: false) - lowercase text
:neutral? - boolean (default: false) - use neutral colors variant"
[{:keys [full-name customization-color size theme monospace? lowercase? neutral?]
[{:keys [full-name customization-color size monospace? lowercase? neutral?]
:or {size biggest-possible}}]
(let [circle-size (:size (size properties))
(let [theme (quo.theme/use-theme)
circle-size (:size (size properties))
small? (check-if-size-small size)
initials (utils.string/get-initials full-name (if small? 1 2))]
[rn/view
(rn.pure/view
{:style (style/container circle-size customization-color neutral? theme)}
[text/text
(text/text
{:accessibility-label :wallet-user-avatar
:size (:font-size (size properties))
:weight (if monospace? :monospace (:font-weight (size properties)))
:style (style/text customization-color neutral? theme)}
(if (and initials lowercase?) (string/lower-case initials) initials)]]))
(if (and initials lowercase?) (string/lower-case initials) initials)))))

(def wallet-user-avatar (quo.theme/with-theme view-internal))
(defn wallet-user-avatar [params] (rn.pure/func view-pure params))
6 changes: 4 additions & 2 deletions src/quo/components/browser/browser_input/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
(defn input
[disabled?]
(assoc (text/text-style {:size :paragraph-1
:weight :regular})
:weight :regular}
nil)
:flex 1
:min-height 36
:min-width 120
Expand Down Expand Up @@ -47,7 +48,8 @@
(defn text
[]
(assoc (text/text-style {:size :paragraph-1
:weight :medium})
:weight :medium}
nil)
:color
(colors/theme-colors colors/neutral-100 colors/white)))

Expand Down
Loading