From 2e68fb22f51690a2d150599a6ab176d369a71246 Mon Sep 17 00:00:00 2001 From: yqrashawn Date: Fri, 2 Dec 2022 14:42:16 +0800 Subject: [PATCH] feat: add display-name in author component (#14473) --- src/quo2/components/messages/author/view.cljs | 24 ++++++++++++++++++- .../contexts/quo_preview/messages/author.cljs | 18 +++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/quo2/components/messages/author/view.cljs b/src/quo2/components/messages/author/view.cljs index bf276bb195..12eb339c65 100644 --- a/src/quo2/components/messages/author/view.cljs +++ b/src/quo2/components/messages/author/view.cljs @@ -9,6 +9,28 @@ (def middle-dot "ยท") +(defn display-name [{:keys [profile-name nickname ens-name text-style]}] + (let [ens? (-> ens-name string/blank? not) + nickname? (-> nickname string/blank? not)] + (if ens? + [text/text (merge {:weight :semi-bold + :size :paragraph-2 + :style (style/ens-text)} + text-style) + ens-name] + [:<> + (if nickname? + [text/text (merge {:weight :semi-bold + :size :paragraph-2 + :style (style/nickname-text)} + text-style) + nickname] + [text/text (merge {:weight :semi-bold + :size :paragraph-2 + :style (style/profile-name-text nickname?)} + text-style) + profile-name])]))) + (defn author [{:keys [profile-name nickname chat-key ens-name time-str contact? verified? untrustworthy?]}] [:f> (fn [] @@ -63,4 +85,4 @@ [text/text {:monospace true :size :paragraph-2 :style (style/time-text ens?)} - time-str]]))]) \ No newline at end of file + time-str]]))]) diff --git a/src/status_im2/contexts/quo_preview/messages/author.cljs b/src/status_im2/contexts/quo_preview/messages/author.cljs index e2d6a5bac0..7e63e5ae9d 100644 --- a/src/status_im2/contexts/quo_preview/messages/author.cljs +++ b/src/status_im2/contexts/quo_preview/messages/author.cljs @@ -1,9 +1,10 @@ (ns status-im2.contexts.quo-preview.messages.author - (:require [react-native.core :as rn] - [quo2.foundations.colors :as colors] - [status-im2.contexts.quo-preview.preview :as preview] + (:require [quo2.components.markdown.text :as text] [quo2.components.messages.author.view :as quo2] - [reagent.core :as reagent])) + [quo2.foundations.colors :as colors] + [react-native.core :as rn] + [reagent.core :as reagent] + [status-im2.contexts.quo-preview.preview :as preview])) (def descriptor [{:label "Profile name" :key :profile-name @@ -49,9 +50,14 @@ [preview/customizer state descriptor]] [rn/view {:padding-vertical 60 :padding--horizontal 15 - :flex-direction :row :justify-content :center} - [quo2/author @state]]]]))) + [rn/view + [text/text "Author:"] + [quo2/author @state]] + [rn/view {:height 50}] + [rn/view + [text/text "Display Name:"] + [quo2/display-name @state]]]]]))) (defn preview-author [] [rn/view {:background-color (colors/theme-colors colors/white colors/neutral-90)