Skip to content

Commit dd7795a

Browse files
authored
Truncate secondary names in username and author components (#19468)
* fix: allow name-container inside message content to shrink so secondary-name can be truncated * fix: responsively truncate contact profile secondary-name * fix: ensure home chat-list-items use full available width in layout * fix: adjust layout of home chat-list-item shrinking with notification counter * fix: adjust layout of home chat-list-item when displaying notification counter * tidy: simplify alignment * tweak: adjust alignment of quo/author component for different text sizes * tidy: extract styles and reformat notification-layout
1 parent feb8753 commit dd7795a

File tree

6 files changed

+63
-37
lines changed

6 files changed

+63
-37
lines changed

src/quo/components/messages/author/style.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
(def name-container
1111
{:margin-right 8
12+
:flex-shrink 1
1213
:flex-direction :row
1314
:align-items :flex-end
1415
})
@@ -31,14 +32,13 @@
3132

3233
(defn secondary-name
3334
[theme]
34-
{:padding-top 1
35-
:flex-shrink 999999
35+
{:flex-shrink 999999
3636
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)})
3737

3838
(defn icon-container
3939
[is-first?]
4040
{:margin-left (if is-first? 4 2)
41-
:margin-bottom 4})
41+
:margin-bottom 2})
4242

4343
(defn time-text
4444
[theme]

src/quo/components/messages/author/view.cljs

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
[{:keys [primary-name secondary-name style short-chat-key time-str contact? verified? untrustworthy?
1414
muted? size theme]
1515
:or {size 13}}]
16-
[rn/view {:style (merge style/container style {:height (if (= size 15) 21.75 18.2)})}
16+
[rn/view
17+
{:style (merge style/container
18+
style
19+
{:height (if (= size 15) 21.75 18.2)
20+
:padding-bottom (if (= size 15) 2 0.5)})}
1721
[rn/view {:style style/name-container}
1822
[text/text
1923
{:weight :semi-bold

src/quo/components/text_combinations/username/style.cljs

+12-7
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@
22
(:require [quo.foundations.colors :as colors]))
33

44
(def container
5-
{:flex-direction :row
6-
:height 32})
5+
{:flex-direction :row
6+
:justify-content :flex-start
7+
:height 32})
78

89
(def username-text-container
910
{:flex-direction :row
10-
:align-items :flex-end})
11+
:align-items :flex-end
12+
:flex-shrink 1})
1113

1214
(defn real-name-text
1315
[theme blur?]
14-
{:color (if blur?
15-
(colors/theme-colors colors/neutral-80-opa-40 colors/white-opa-40 theme)
16-
(colors/theme-colors colors/neutral-60 colors/neutral-40 theme))})
16+
{:color (if blur?
17+
(colors/theme-colors colors/neutral-80-opa-40 colors/white-opa-40 theme)
18+
(colors/theme-colors colors/neutral-60 colors/neutral-40 theme))
19+
:flex-shrink 1})
1720

1821
(defn real-name-dot
1922
[theme blur?]
20-
(assoc (real-name-text theme blur?) :margin-horizontal 6))
23+
(merge (real-name-text theme blur?)
24+
{:margin-horizontal 6
25+
:flex-shrink 0}))
2126

2227
(defn status-icon-container
2328
[name-type status]

src/quo/components/text_combinations/username/view.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
{:style (style/real-name-text theme blur?)
2727
:size :paragraph-1
2828
:accessibility-label :real-name
29-
:weight :medium}
29+
:weight :medium
30+
:number-of-lines 1}
3031
real-name]])])
3132

3233
(defn- icon-20

src/status_im/contexts/chat/home/chat_list_item/style.cljs

+7-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
:align-items :center})
1212

1313
(def chat-data-container
14-
{:flex 1
15-
:margin-left 8
16-
:margin-right 16})
14+
{:flex 1
15+
:margin-left 8})
1716

1817
(def notification-container
1918
{:margin-left :auto
@@ -22,6 +21,11 @@
2221
:justify-content :center
2322
:align-items :center})
2423

24+
(def notification-container-layout
25+
{:flex-grow 1
26+
:justify-content :center
27+
:margin-left 8})
28+
2529
;; TODO: duplicate of `quo.components.common.unread-grey-dot.style`
2630
;; Replace it when this component is defined as part of `quo.components`
2731
(defn grey-dot

src/status_im/contexts/chat/home/chat_list_item/view.cljs

+34-22
Original file line numberDiff line numberDiff line change
@@ -184,35 +184,45 @@
184184
{:customization-color color
185185
:size :size-32}]))
186186

187+
(defn- notification-layout
188+
[child]
189+
[rn/view
190+
{:style style/notification-container-layout}
191+
[rn/view {:style style/notification-container}
192+
child]])
193+
187194
(defn notification
188195
[{:keys [muted group-chat unviewed-messages-count unviewed-mentions-count]}]
189196
(let [customization-color (rf/sub [:profile/customization-color])
190197
unread-messages? (pos? unviewed-messages-count)
191198
unread-mentions? (pos? unviewed-mentions-count)]
192-
[rn/view {:style style/notification-container}
193-
(cond
194-
muted
195-
[quo/icon :i/muted {:color colors/neutral-40}]
199+
(cond
200+
muted
201+
[notification-layout
202+
[quo/icon :i/muted {:color colors/neutral-40}]]
196203

197-
(and group-chat unread-mentions?)
204+
(and group-chat unread-mentions?)
205+
[notification-layout
198206
[quo/counter
199207
{:container-style {:position :relative :right 0}
200208
:customization-color customization-color
201209
:accessibility-label :new-message-counter}
202-
unviewed-mentions-count]
210+
unviewed-mentions-count]]
203211

204-
;; TODO: use the grey-dot component when chat-list-item is moved to quo.components
205-
(and group-chat unread-messages?)
212+
;; TODO: use the grey-dot component when chat-list-item is moved to quo.components
213+
(and group-chat unread-messages?)
214+
[notification-layout
206215
[rn/view
207216
{:style (style/grey-dot)
208-
:accessibility-label :unviewed-messages-public}]
217+
:accessibility-label :unviewed-messages-public}]]
209218

210-
unread-messages?
219+
unread-messages?
220+
[notification-layout
211221
[quo/counter
212222
{:container-style {:position :relative :right 0}
213223
:customization-color customization-color
214224
:accessibility-label :new-message-counter}
215-
unviewed-messages-count])]))
225+
unviewed-messages-count]])))
216226

217227
(defn chat-item
218228
[{:keys [chat-id group-chat color name last-message timestamp muted]
@@ -223,23 +233,25 @@
223233
(rf/sub [:contacts/contact-two-names-by-identity chat-id]))
224234
{:keys [ens-verified added?] :as contact} (when-not group-chat
225235
(rf/sub [:contacts/contact-by-address chat-id]))]
226-
[:<>
236+
[rn/view {:style {:flex-direction :row}}
227237
[avatar-view
228238
{:contact contact
229239
:chat-id chat-id
230240
:full-name primary-name
231241
:color color
232242
:muted? muted}]
233-
[rn/view {:style style/chat-data-container}
234-
[quo/author
235-
{:primary-name primary-name
236-
:secondary-name secondary-name
237-
:size 15
238-
:verified? ens-verified
239-
:contact? added?
240-
:muted? muted
241-
:time-str (datetime/to-short-str timestamp)}]
242-
[last-message-preview group-chat last-message muted]]
243+
[rn/view {:style {:flex-shrink 1}}
244+
[rn/view {:style style/chat-data-container}
245+
[quo/author
246+
{:primary-name primary-name
247+
:secondary-name secondary-name
248+
:size 15
249+
:verified? ens-verified
250+
:contact? added?
251+
:muted? muted
252+
:time-str (datetime/to-short-str timestamp)
253+
:style {:flex-shrink 1}}]
254+
[last-message-preview group-chat last-message muted]]]
243255
[notification item]]))
244256

245257
(defn chat-user

0 commit comments

Comments
 (0)