Skip to content

Commit 6c19290

Browse files
authored
Add blur variants for context-tag (#15621)
- Split context-tags into context-tag.view & context-tag.style namespaces - Fix context-tags preview screen & add blur option
1 parent d902fb1 commit 6c19290

File tree

5 files changed

+248
-192
lines changed

5 files changed

+248
-192
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
(ns quo2.components.tags.context-tag.style
2+
(:require [quo2.foundations.colors :as colors]))
3+
4+
(defn base-tag
5+
[override-theme blur?]
6+
{:border-radius 100
7+
:padding-vertical 3
8+
:flex-direction :row
9+
:padding-right 8
10+
:padding-left 8
11+
:background-color (if blur?
12+
(colors/theme-colors colors/neutral-80-opa-5 colors/white-opa-5 override-theme)
13+
(colors/theme-colors colors/neutral-10 colors/neutral-90 override-theme))})
14+
15+
(def context-tag-image
16+
{:width 20
17+
:border-radius 10
18+
:background-color :white
19+
:height 20})
20+
21+
(defn context-tag-icon-color
22+
[blur?]
23+
(if blur?
24+
(colors/theme-colors colors/neutral-80-opa-40 colors/white-opa-40)
25+
(colors/theme-colors colors/neutral-50 colors/neutral-40)))
26+
27+
(def context-tag-text-container
28+
{:align-items :center
29+
:flex-direction :row})
30+
31+
(def audio-tag-container
32+
{:padding-left 2
33+
:padding-vertical 2})
34+
35+
(def audio-tag-icon-container
36+
{:width 20
37+
:height 20
38+
:border-radius 10
39+
:align-items :center
40+
:justify-content :center
41+
:background-color colors/primary-50})
42+
43+
(def audio-tag-icon-color colors/white)
44+
45+
(defn audio-tag-text-color
46+
[override-theme]
47+
(colors/theme-colors colors/neutral-100 colors/white override-theme))
48+
49+
(def community-tag
50+
{:padding-vertical 2})
51+
52+
(defn community-tag-text
53+
[override-theme]
54+
{:margin-left 2
55+
:color (colors/theme-colors colors/neutral-100 colors/white override-theme)})
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
(ns quo2.components.tags.context-tag.view
2+
(:require [quo2.components.avatars.group-avatar :as group-avatar]
3+
[quo2.components.icon :as icons]
4+
[quo2.components.markdown.text :as text]
5+
[quo2.components.tags.context-tag.style :as style]
6+
[react-native.core :as rn]))
7+
8+
(defn trim-public-key
9+
[pk]
10+
(str (subs pk 0 6) "..." (subs pk (- (count pk) 3))))
11+
12+
(defn base-tag
13+
[{:keys [override-theme style blur?]} & children]
14+
(into
15+
[rn/view {:style (merge (style/base-tag override-theme blur?) style)}]
16+
children))
17+
18+
(defn group-avatar-tag
19+
[label opts]
20+
[base-tag
21+
(-> opts
22+
(select-keys [:override-theme :style :blur?])
23+
(assoc-in [:style :padding-left] 3)
24+
(assoc-in [:style :padding-vertical] 2))
25+
[group-avatar/group-avatar opts]
26+
[text/text
27+
{:weight :medium
28+
:size :paragraph-2
29+
:style (:text-style opts)}
30+
(str " " label)]])
31+
32+
(defn public-key-tag
33+
[params public-key]
34+
[base-tag params
35+
[text/text
36+
{:weight :monospace
37+
:size :paragraph-2}
38+
(trim-public-key public-key)]])
39+
40+
(defn context-tag
41+
[{:keys [text-style blur?] :as params} photo name channel-name]
42+
(let [text-params {:weight :medium
43+
:size :paragraph-2
44+
:style (assoc text-style :justify-content :center)}]
45+
[base-tag (assoc-in params [:style :padding-left] 3)
46+
[rn/image
47+
{:style style/context-tag-image
48+
:source photo}]
49+
[rn/view {:style style/context-tag-text-container}
50+
[text/text text-params (str " " name)]
51+
(when channel-name
52+
[:<>
53+
[icons/icon
54+
:i/chevron-right
55+
{:color (style/context-tag-icon-color blur?)
56+
:size 16}]
57+
[text/text text-params (str "# " channel-name)]])]]))
58+
59+
(defn user-avatar-tag
60+
[params username photo]
61+
[context-tag params {:uri photo} username])
62+
63+
(defn audio-tag
64+
[duration params]
65+
[base-tag (merge {:style style/audio-tag-container} params)
66+
[rn/view {:style style/audio-tag-icon-container}
67+
[icons/icon
68+
:i/play
69+
{:color style/audio-tag-icon-color
70+
:size 12}]]
71+
[text/text
72+
{:weight :medium
73+
:size :paragraph-2
74+
:style {:margin-left 4
75+
:color (style/audio-tag-text-color (:override-theme params))}}
76+
duration]])
77+
78+
(defn community-tag
79+
[avatar community-name {:keys [override-theme] :as params}]
80+
[context-tag
81+
(merge {:style style/community-tag
82+
:text-style (style/community-tag-text override-theme)}
83+
params)
84+
avatar
85+
community-name])

src/quo2/components/tags/context_tags.cljs

Lines changed: 0 additions & 126 deletions
This file was deleted.

src/quo2/core.cljs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
quo2.components.tabs.segmented-tab
6868
quo2.components.tabs.account-selector
6969
quo2.components.tabs.tabs
70-
quo2.components.tags.context-tags
70+
quo2.components.tags.context-tag.view
7171
quo2.components.tags.status-tags
7272
quo2.components.tags.permission-tag
7373
quo2.components.tags.tag
@@ -91,12 +91,11 @@
9191
(def system-message quo2.components.messages.system-message/system-message)
9292
(def reaction quo2.components.reactions.reaction/reaction)
9393
(def add-reaction quo2.components.reactions.reaction/add-reaction)
94-
(def user-avatar-tag quo2.components.tags.context-tags/user-avatar-tag)
95-
(def context-tag quo2.components.tags.context-tags/context-tag)
96-
(def group-avatar-tag quo2.components.tags.context-tags/group-avatar-tag)
97-
(def audio-tag quo2.components.tags.context-tags/audio-tag)
98-
(def community-tag quo2.components.tags.context-tags/community-tag)
99-
94+
(def user-avatar-tag quo2.components.tags.context-tag.view/user-avatar-tag)
95+
(def context-tag quo2.components.tags.context-tag.view/context-tag)
96+
(def group-avatar-tag quo2.components.tags.context-tag.view/group-avatar-tag)
97+
(def audio-tag quo2.components.tags.context-tag.view/audio-tag)
98+
(def community-tag quo2.components.tags.context-tag.view/community-tag)
10099
(def floating-shell-button quo2.components.navigation.floating-shell-button/floating-shell-button)
101100
(def page-nav quo2.components.navigation.page-nav/page-nav)
102101
(def disclaimer quo2.components.selectors.disclaimer.view/view)

0 commit comments

Comments
 (0)