Skip to content

Commit

Permalink
chore(schema): for user-avatar component
Browse files Browse the repository at this point in the history
  • Loading branch information
yqrashawn committed Feb 20, 2024
1 parent 5a7bfc6 commit 3dedf85
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
26 changes: 26 additions & 0 deletions src/quo/components/avatars/user_avatar/schema.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(ns quo.components.avatars.user-avatar.schema
(:require
[quo.components.avatars.user-avatar.style :as style]))


(def ?schema
[:=>
[:catn
[:props
[:map
[:full-name {:optional true} [:maybe string?]]
[:size {:optional true} [:maybe (into [:enum] (keys style/sizes))]]
[:customization-color [:maybe :schema.common/customization-color]]
[:static? {:optional true} [:maybe :any]]
[:status-indicator? {:optional true} [:maybe :any]]
[:online? {:optional true} [:maybe :any]]
[:ring? {:optional true} [:maybe :any]]
[:theme :schema.common/theme]
[:profile-picture
[:maybe
[:or
string?
number?
[:map [:uri string?]]
[:map [:fn fn?]]]]]]]]
:any])
12 changes: 8 additions & 4 deletions src/quo/components/avatars/user_avatar/view.cljs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
(ns quo.components.avatars.user-avatar.view
(:require
[quo.components.avatars.user-avatar.schema :as component-schema]
[quo.components.avatars.user-avatar.style :as style]
[quo.components.common.no-flicker-image :as no-flicker-image]
[quo.components.markdown.text :as text]
[quo.theme]
[react-native.core :as rn]
[react-native.fast-image :as fast-image]
[schema.core :as schema]
utils.string))

(defn initials-avatar
Expand Down Expand Up @@ -55,10 +57,10 @@
status-indicator? true
online? true
ring? true
customization-color :blue}
customization-color :blue
full-name "Your Name"}
:as props}]
(let [full-name (or full-name "Your Name")
;; image generated with profile-picture-fn is round cropped
(let [;; image generated with `profile-picture-fn` is round cropped
;; no need to add border-radius for them
outer-styles (style/outer size (not (:fn profile-picture)))
;; Once image is loaded, fast image re-renders view with the help of reagent atom,
Expand Down Expand Up @@ -108,4 +110,6 @@

:else {:uri profile-picture})}])]))

(def user-avatar (quo.theme/with-theme user-avatar-internal))
(def user-avatar
(quo.theme/with-theme
(schema/instrument #'user-avatar-internal component-schema/?schema)))

0 comments on commit 3dedf85

Please sign in to comment.