Skip to content

Commit

Permalink
chore(schema): for user-avatar component
Browse files Browse the repository at this point in the history
Signed-off-by: yqrashawn <namy.19@gmail.com>
  • Loading branch information
yqrashawn committed Feb 20, 2024
1 parent 424bbc3 commit f6e554b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/quo/components/avatars/user_avatar/schema.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(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 {:optional true} [:maybe :schema.common/customization-color]]
[:static? {:optional true} [:maybe boolean?]]
[:status-indicator? {:optional true} [:maybe boolean?]]
[:online? {:optional true} [:maybe boolean?]]
[:ring? {:optional true} [:maybe boolean?]]
[:theme :schema.common/theme]
[:profile-picture
[:maybe
[:or
:schema.common/image-source
[:map [:fn fn?]]]]]]]]
:any])
8 changes: 6 additions & 2 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 @@ -58,7 +60,7 @@
customization-color :blue}
:as props}]
(let [full-name (or full-name "Your Name")
;; image generated with profile-picture-fn is round cropped
;; 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 f6e554b

Please sign in to comment.