mirror of
https://github.com/status-im/status-react.git
synced 2025-01-25 18:29:37 +00:00
parent
50af7fb502
commit
cd1bd1c211
@ -1,7 +1,6 @@
|
|||||||
(ns status-im2.contexts.chat.messages.content.text.style
|
(ns status-im2.contexts.chat.messages.content.text.style
|
||||||
(:require [quo2.foundations.colors :as colors]))
|
(:require [quo2.foundations.colors :as colors]
|
||||||
|
[quo.platform :as platform]))
|
||||||
(def spacing-between-blocks 0)
|
|
||||||
|
|
||||||
(def block
|
(def block
|
||||||
{:border-radius 6
|
{:border-radius 6
|
||||||
@ -13,17 +12,14 @@
|
|||||||
:border-left-color colors/neutral-40})
|
:border-left-color colors/neutral-40})
|
||||||
|
|
||||||
(defn mention-tag-wrapper
|
(defn mention-tag-wrapper
|
||||||
[]
|
[first-child-mention]
|
||||||
{:flex-direction :row
|
{:flex-direction :row
|
||||||
:align-items :center
|
:align-items :center
|
||||||
:height 22})
|
:height (if platform/ios? 22 21)
|
||||||
|
:background-color colors/primary-50-opa-10
|
||||||
(def mention-tag
|
|
||||||
{:background-color colors/primary-50-opa-10
|
|
||||||
:padding-horizontal 3
|
:padding-horizontal 3
|
||||||
:border-radius 6
|
:border-radius 6
|
||||||
:margin-bottom -3
|
:transform [{:translateY (if platform/ios? (if first-child-mention 4.5 3) 4.5)}]})
|
||||||
:height 22})
|
|
||||||
|
|
||||||
(def mention-tag-text
|
(def mention-tag-text
|
||||||
{:color (colors/theme-colors colors/primary-50
|
{:color (colors/theme-colors colors/primary-50
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn render-inline
|
(defn render-inline
|
||||||
[units {:keys [type literal destination]} chat-id style-override]
|
[units {:keys [type literal destination]} chat-id style-override first-child-mention]
|
||||||
(let [show-as-plain-text? (seq style-override)]
|
(let [show-as-plain-text? (seq style-override)]
|
||||||
(case (keyword type)
|
(case (keyword type)
|
||||||
:code
|
:code
|
||||||
@ -55,21 +55,17 @@
|
|||||||
:mention
|
:mention
|
||||||
(conj
|
(conj
|
||||||
units
|
units
|
||||||
[rn/view
|
[rn/pressable
|
||||||
{:style style/mention-tag-wrapper}
|
{:on-press #(rf/dispatch [:chat.ui/show-profile literal])
|
||||||
[rn/touchable-opacity
|
:style (style/mention-tag-wrapper first-child-mention)}
|
||||||
{:active-opacity 1
|
[quo/text
|
||||||
:on-press #(rf/dispatch [:chat.ui/show-profile literal])
|
{:weight :medium
|
||||||
:style style/mention-tag}
|
:style style/mention-tag-text
|
||||||
[quo/text
|
:size :paragraph-1}
|
||||||
{:weight :medium
|
(rf/sub [:messages/resolve-mention literal])]])
|
||||||
:style style/mention-tag-text
|
|
||||||
:size :paragraph-1}
|
|
||||||
(rf/sub [:messages/resolve-mention literal])]]])
|
|
||||||
|
|
||||||
:edited
|
:edited
|
||||||
(conj units
|
(conj units
|
||||||
|
|
||||||
[quo/text
|
[quo/text
|
||||||
{:weight :medium
|
{:weight :medium
|
||||||
:style {:font-size 11 ; Font-size must be used instead of props or the
|
:style {:font-size 11 ; Font-size must be used instead of props or the
|
||||||
@ -90,39 +86,47 @@
|
|||||||
|
|
||||||
(conj units literal))))
|
(conj units literal))))
|
||||||
|
|
||||||
|
(defn first-child-mention
|
||||||
|
[children]
|
||||||
|
(and (> (count children) 0)
|
||||||
|
(= (keyword (:type (second children))) :mention)
|
||||||
|
(empty? (get-in children [0 :literal]))))
|
||||||
|
|
||||||
(defn render-block
|
(defn render-block
|
||||||
[blocks {:keys [type literal children]} chat-id style-override]
|
[blocks {:keys [type literal children]} chat-id style-override]
|
||||||
(case (keyword type)
|
(let [mention-first (first-child-mention children)]
|
||||||
:paragraph
|
(case (keyword type)
|
||||||
(conj blocks
|
:paragraph
|
||||||
[rn/view
|
(conj blocks
|
||||||
(reduce
|
[rn/view
|
||||||
(fn [acc e]
|
(reduce
|
||||||
(render-inline acc e chat-id style-override))
|
(fn [acc e]
|
||||||
[quo/text
|
(render-inline acc e chat-id style-override mention-first))
|
||||||
{:style {:size :paragraph-1
|
[quo/text
|
||||||
:color (when (seq style-override) colors/white)}}]
|
{:style {:size :paragraph-1
|
||||||
children)])
|
:margin-bottom (if mention-first (if quo.platform/ios? 4 0) 2)
|
||||||
|
:margin-top (if mention-first (if quo.platform/ios? -4 0) 2)
|
||||||
|
:color (when (seq style-override) colors/white)}}]
|
||||||
|
children)])
|
||||||
|
|
||||||
:edited-block
|
:edited-block
|
||||||
(conj blocks
|
(conj blocks
|
||||||
(reduce
|
(reduce
|
||||||
(fn [acc e]
|
(fn [acc e]
|
||||||
(render-inline acc e chat-id style-override))
|
(render-inline acc e chat-id style-override first-child-mention))
|
||||||
[quo/text {:size :paragraph-1}]
|
[quo/text {:size :paragraph-1}]
|
||||||
children))
|
children))
|
||||||
|
|
||||||
:blockquote
|
:blockquote
|
||||||
(conj blocks
|
(conj blocks
|
||||||
[rn/view {:style style/quote}
|
[rn/view {:style style/quote}
|
||||||
[quo/text literal]])
|
[quo/text literal]])
|
||||||
|
|
||||||
:codeblock
|
:codeblock
|
||||||
(conj blocks
|
(conj blocks
|
||||||
[rn/view {:style (merge style/block (style/code))}
|
[rn/view {:style (merge style/block (style/code))}
|
||||||
[quo/text (subs literal 0 (dec (count literal)))]])
|
[quo/text (subs literal 0 (dec (count literal)))]])
|
||||||
blocks))
|
blocks)))
|
||||||
|
|
||||||
(def edited-tag
|
(def edited-tag
|
||||||
{:literal (str "(" (i18n/label :t/edited) ")")
|
{:literal (str "(" (i18n/label :t/edited) ")")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user