chore: create profile-picture schema with profile-picture-fn field fix: update context-tag schema to allow for profile-picture-fn tidy: move profile-picture schema into the common schema namespaces tidy: revise docs for user-avatar-internal component to mainly warn about `profile-picture-fn` usage tidy: rename `profile-picture` schema to `profile-picture-source` tidy: use profile-picture-source schema in user-avatar schema
This commit is contained in:
parent
13f87020eb
commit
265b712fe3
|
@ -17,8 +17,5 @@
|
|||
[:theme :schema.common/theme]
|
||||
[:profile-picture
|
||||
{:optional true}
|
||||
[:maybe
|
||||
[:or
|
||||
:schema.common/image-source
|
||||
[:map [:fn fn?]]]]]]]]
|
||||
[:maybe :schema.quo/profile-picture-source]]]]]
|
||||
:any])
|
||||
|
|
|
@ -25,32 +25,11 @@
|
|||
|
||||
(defn user-avatar-internal
|
||||
"Render user avatar with `profile-picture`
|
||||
`profile-picture` should be one of {:uri profile-picture-uri} or {:fn profile-picture-fn}
|
||||
|
||||
`profile-picture-fn` should return an image URI, there's helper fn to generate
|
||||
it in `utils.image-server`
|
||||
|
||||
params for `profile-picture-fn`
|
||||
{:length initials' length
|
||||
:full-name used to generate initials
|
||||
:font-size initials font size
|
||||
:indicator-size status indicator outer radius, set to nil or 0 when no indicator
|
||||
:indicator-border `indicator-size`-`indicator-border` is the inner radius
|
||||
:indicator-color color for status indicator
|
||||
:theme :light or :dark
|
||||
:background-color intials avatar background color
|
||||
:color intials avatar text color
|
||||
:size intials avatar radius
|
||||
:ring? render ident ring around avatar? NOTE: this option may not work if override-ring? is not nil}
|
||||
|
||||
supported color formats:
|
||||
#RRGGBB
|
||||
#RRGGBBAA
|
||||
rgb(255,255,255)
|
||||
rgba(255,255,255,0.1) note alpha is 0-1
|
||||
|
||||
the reason we use the `profile-picture-fn` here is to separate
|
||||
logic (pubkey, key-uid... in subs) and style (color, size... in this component)"
|
||||
WARNING:
|
||||
When calling the `profile-picture-fn` and passing the `:ring?` key, be aware that the `profile-picture-fn`
|
||||
may have an `:override-ring?` value. If it does then the `:ring?` value will not be used.
|
||||
For reference, refer to the `utils.image-server` namespace for these `profile-picture-fn` are generated."
|
||||
[{:keys [full-name size profile-picture customization-color static?
|
||||
status-indicator? online? ring? theme]
|
||||
:or {size :big
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
(def ^:private ?default
|
||||
[:map
|
||||
[:profile-picture {:optional true} [:maybe :schema.common/image-source]]
|
||||
[:profile-picture {:optional true} [:maybe :schema.quo/profile-picture-source]]
|
||||
[:full-name {:optional true} [:maybe :string]]])
|
||||
|
||||
(def ^:private ?multiuser
|
||||
|
@ -26,7 +26,8 @@
|
|||
[:users {:optional true}
|
||||
[:maybe
|
||||
[:sequential
|
||||
[:map [:profile-picture {:optional true} [:maybe :schema.common/image-source]]
|
||||
[:map
|
||||
[:profile-picture {:optional true} [:maybe :schema.quo/profile-picture-source]]
|
||||
[:full-name {:optional true} [:maybe :string]]
|
||||
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]]]]]])
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
(ns schema.quo
|
||||
(:require
|
||||
[schema.registry :as registry]))
|
||||
|
||||
(def ^:private ?profile-picture-fn-params
|
||||
[:map
|
||||
[:length :int]
|
||||
[:full-name :string]
|
||||
[:font-size :int]
|
||||
[:indicator-size {:optional true} [:maybe :int]]
|
||||
[:indicator-color {:optional true} [:maybe :string]]
|
||||
[:indicator-center-to-edge {:optional true} [:maybe :int]]
|
||||
[:override-theme :schema.common/theme]
|
||||
[:background-color :string]
|
||||
[:color :string]
|
||||
[:size :int]
|
||||
[:ring? :boolean]
|
||||
[:ring-width :int]])
|
||||
|
||||
(def ^:private ?profile-picture-source
|
||||
[:or
|
||||
:schema.common/image-source
|
||||
[:map
|
||||
[:fn [:=> [:cat ?profile-picture-fn-params] :string]]]])
|
||||
|
||||
(defn register-schemas
|
||||
[]
|
||||
(registry/register ::profile-picture-source ?profile-picture-source))
|
|
@ -9,6 +9,7 @@
|
|||
malli.util
|
||||
schema.common
|
||||
[schema.core :as schema]
|
||||
schema.quo
|
||||
schema.re-frame
|
||||
schema.registry
|
||||
[taoensso.timbre :as log]))
|
||||
|
@ -78,7 +79,8 @@
|
|||
[]
|
||||
(schema.registry/merge (malli.util/schemas))
|
||||
(schema.common/register-schemas)
|
||||
(schema.re-frame/register-schemas))
|
||||
(schema.re-frame/register-schemas)
|
||||
(schema.quo/register-schemas))
|
||||
|
||||
(defn setup!
|
||||
"Configure Malli and initializes instrumentation.
|
||||
|
|
Loading…
Reference in New Issue