-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor tag preview screens to new api (#17549)
- Loading branch information
1 parent
2192774
commit bbc7592
Showing
15 changed files
with
322 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
(ns quo.components.tags.token-tag.style | ||
(:require [quo.foundations.colors :as colors])) | ||
|
||
(defn container | ||
[size options blur? theme] | ||
(let [hold? (= options :hold)] | ||
(merge {:background-color (if blur? | ||
(colors/theme-colors colors/neutral-80-opa-5 colors/white-opa-5 theme) | ||
(colors/theme-colors colors/neutral-10 colors/neutral-90 theme)) | ||
:flex-direction :row | ||
:align-items :center | ||
:padding-left 2 | ||
:border-width (if hold? 1 0) | ||
:border-radius 20 | ||
:border-color (colors/theme-colors colors/success-50 colors/success-60 theme)} | ||
(condp = size | ||
:size-24 {:height (if hold? 26 24) | ||
:padding-right 10 | ||
:border-radius (if hold? 13 12)} | ||
:size-32 {:height (if hold? 34 32) | ||
:padding-right 12 | ||
:border-radius (if hold? 17 16)})))) | ||
|
||
(defn options-icon | ||
[size] | ||
(assoc | ||
(condp = size | ||
:size-24 {:right -8 | ||
:top -8} | ||
:size-32 {:right -6 | ||
:top -6}) | ||
:position | ||
:absolute)) | ||
|
||
(defn token-img | ||
[size] | ||
(condp = size | ||
:size-24 {:width 20 | ||
:height 20 | ||
:margin-right 6 | ||
:border-radius 10} | ||
:size-32 {:width 28 | ||
:height 28 | ||
:margin-right 8 | ||
:border-radius 14})) | ||
|
||
(defn label | ||
[theme] | ||
{:color (colors/theme-colors colors/neutral-100 colors/white theme)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
(ns quo.components.tags.token-tag.view | ||
(:require | ||
[oops.core :refer [oget]] | ||
[quo.components.icon :as icons] | ||
[quo.components.markdown.text :as text] | ||
[quo.components.tags.token-tag.style :as style] | ||
[quo.theme :as quo.theme] | ||
[react-native.core :as rn] | ||
[react-native.hole-view :as hole-view] | ||
[reagent.core :as reagent])) | ||
|
||
(defn- view-internal | ||
"Options: | ||
- :options - false / :add / :hold (default false) | ||
- :size - :size-24 / :size-32 (default :size-24) | ||
- :blur? - boolean (default false) | ||
- :theme - :light / :dark | ||
- :token-img-src - token image source | ||
- :token-value - string - token value | ||
- :token-symbol - string" | ||
[] | ||
(let [container-width (reagent/atom 0)] | ||
(fn [{:keys [options size blur? theme token-img-src token-value token-symbol] | ||
:or {size :size-24}}] | ||
[rn/view | ||
{:on-layout #(reset! container-width | ||
(oget % :nativeEvent :layout :width))} | ||
[hole-view/hole-view | ||
{:holes (if options | ||
[{:x (- @container-width | ||
(condp = size | ||
:size-24 10 | ||
:size-32 12)) | ||
:y (condp = size | ||
:size-24 -6 | ||
:size-32 -4) | ||
:width 16 | ||
:height 16 | ||
:borderRadius 8}] | ||
[])} | ||
[rn/view | ||
{:style (style/container size options blur? theme)} | ||
[rn/image | ||
{:style (style/token-img size) | ||
:source token-img-src}] | ||
[text/text | ||
{:size :paragraph-2 | ||
:weight :medium | ||
:style (style/label theme)} | ||
(str token-value " " token-symbol)]]] | ||
(when options | ||
[rn/view {:style (style/options-icon size)} | ||
[icons/icon (if (= options :hold) :i/hold :i/add-token) | ||
{:size 20 | ||
:no-color true}]])]))) | ||
|
||
(def view (quo.theme/with-theme view-internal)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.