address various UI feedback

This commit is contained in:
Martin Klepsch 2018-04-24 11:13:31 +02:00 committed by Tetiana Churikova
parent 244f9d2ea6
commit 3e25c8e04f
2 changed files with 56 additions and 39 deletions

View File

@ -0,0 +1,39 @@
(ns commiteth.ui.balances)
(defn tla-color
[tla]
{:pre [(string? tla)]}
(get {"ETH" "#57a7ed"} tla "#4360df"))
(defn balance-badge
[tla balance]
{:pre [(keyword? tla)]}
(let [tla (name tla)]
[:div.dib.ph2.pv1.relative
{:style {:color (tla-color tla)}}
[:div.absolute.top-0.left-0.right-0.bottom-0.o-10.br2
{:style {:background-color (tla-color tla)}}]
[:span.pg-med (str tla " " balance)]]))
(defn balance-label
[tla balance]
{:pre [(keyword? tla)]}
(let [tla (name tla)]
[:span.pg-med.fw5
{:style {:color (tla-color tla)}}
(str tla " " balance)]))
(defn usd-value-label [value-usd]
[:span
[:span.gray "Value "]
[:span.dark-gray (str "$" value-usd)]])
(defn token-balances [crypto-balances style]
[:span ; TODO consider non DOM el react wrapping
(for [[tla balance] crypto-balances]
^{:key tla}
[:div.dib.mr2
(case style
:label [balance-label tla balance]
:badge [balance-badge tla balance]
[balance-badge tla balance])])])

View File

@ -5,6 +5,7 @@
[commiteth.util :as util] [commiteth.util :as util]
[commiteth.routes :as routes] [commiteth.routes :as routes]
[commiteth.model.bounty :as bnt] [commiteth.model.bounty :as bnt]
[commiteth.ui.balances :as ui-balances]
[commiteth.common :as common :refer [human-time]])) [commiteth.common :as common :refer [human-time]]))
(defn pr-url [{owner :repo_owner (defn pr-url [{owner :repo_owner
@ -15,35 +16,6 @@
(def primary-button-button :button.f7.ttu.tracked.outline-0.bg-sob-blue.white.pv3.ph4.pg-med.br3.bn.pointer.shadow-7) (def primary-button-button :button.f7.ttu.tracked.outline-0.bg-sob-blue.white.pv3.ph4.pg-med.br3.bn.pointer.shadow-7)
(def primary-button-link :a.dib.tc.f7.ttu.tracked.bg-sob-blue.white.pv2.ph3.pg-med.br2.pointer.hover-white.shadow-7) (def primary-button-link :a.dib.tc.f7.ttu.tracked.bg-sob-blue.white.pv2.ph3.pg-med.br2.pointer.hover-white.shadow-7)
(defn balance-badge
[tla balance]
{:pre [(keyword? tla)]}
(let [color (fn balance-badge-color [tla]
(get {"ETH" "#57a7ed"} tla "#4360df"))
tla (name tla)]
[:div.dib.ph2.pv1.relative
{:style {:color (color tla)}}
[:div.absolute.top-0.left-0.right-0.bottom-0.o-10.br2
{:style {:background-color (color tla)}}]
[:span.pg-med (str tla " " balance)]]))
(defn usd-value-label [value-usd]
[:span
[:span.usd-value-label "Value "]
[:span.usd-balance-label (str "$" value-usd)]])
(defn token-balances [crypto-balances]
[:span ; TODO consider non DOM el react wrapping
(for [[tla balance] crypto-balances]
^{:key tla}
[:div.dib.mr2
[balance-badge tla balance]])])
(defn bounty-balance [{:keys [value-usd] :as bounty}]
[:div
[token-balances (bnt/crypto-balances bounty)]
[:div.dib.mr2.pv1
[usd-value-label value-usd]]])
(defn bounty-card [{owner :repo-owner (defn bounty-card [{owner :repo-owner
repo-name :repo-name repo-name :repo-name
@ -98,7 +70,10 @@
{:style {:-webkit-filter "grayscale(1)" {:style {:-webkit-filter "grayscale(1)"
:pointer-events "none"}}) :pointer-events "none"}})
[:div.dtc.v-mid.pr3.f6 [:div.dtc.v-mid.pr3.f6
[bounty-balance bounty]] [:div
[ui-balances/token-balances (bnt/crypto-balances bounty) :badge]
[:div.dib.mr2.pv1
[ui-balances/usd-value-label (:value-usd bounty)]]]]
[:div.dtc.v-mid [:div.dtc.v-mid
[confirm-button bounty claim]]]]])) [confirm-button bounty claim]]]]]))
@ -225,14 +200,13 @@
:paid :paid}) :paid :paid})
(defn bounty-title-link [bounty {:keys [show-date? max-length]}] (defn bounty-title-link [bounty {:keys [show-date? max-length]}]
[:a {:href (common/issue-url (:repo-owner bounty) (:repo-name bounty) (:issue-number bounty))} [:a.lh-title {:href (common/issue-url (:repo-owner bounty) (:repo-name bounty) (:issue-number bounty))}
[:div.w-100.overflow-hidden [:div.w-100.overflow-hidden
[:span.db.f5.pg-med.muted-blue.hover-black [:span.db.f5.pg-med.muted-blue.hover-black
(cond-> (:issue-title bounty) (cond-> (:issue-title bounty)
max-length (gstring/truncate max-length))] max-length (gstring/truncate max-length))]
(when show-date? (when show-date?
[:span.db.mt1.f6.gray.pg-book [:span.db.mt1.f6.gray.pg-book
;;{:on-click #(do (.preventDefault %) (prn (dissoc bounty :claims)))}
(common/human-time (:updated bounty))])]]) (common/human-time (:updated bounty))])]])
(defn square-card (defn square-card
@ -244,22 +218,26 @@
[:div.flex-auto top] [:div.flex-auto top]
[:div bottom]]]) [:div bottom]]])
(defn small-card-balances [bounty]
[:div.f6
[ui-balances/token-balances (bnt/crypto-balances bounty) :label]
[:div
[ui-balances/usd-value-label (:value-usd bounty)]]])
(defn unclaimed-bounty [bounty] (defn unclaimed-bounty [bounty]
[:div.w-third-l.fl-l.pa2 [:div.w-third-l.fl-l.pa2
[square-card [square-card
[bounty-title-link bounty {:show-date? true :max-length 100}] [bounty-title-link bounty {:show-date? true :max-length 60}]
[:div.f7 [small-card-balances bounty]]])
[bounty-balance bounty]]]])
(defn paid-bounty [bounty] (defn paid-bounty [bounty]
[:div.w-third-l.fl-l.pa2 [:div.w-third-l.fl-l.pa2
[square-card [square-card
[:div [:div
[bounty-title-link bounty {:show-date? false :max-length 100}] [bounty-title-link bounty {:show-date? false :max-length 60}]
[:div.f6.mt1.gray [:div.f6.mt1.gray
"Paid out to " [:span.pg-med.muted-blue "@" (:winner_login bounty)]]] "Paid out to " [:span.pg-med.muted-blue "@" (:winner_login bounty)]]]
[:div.f7 [small-card-balances bounty]]])
[bounty-balance bounty]]]])
(defn expandable-bounty-list [bounty-component bounties] (defn expandable-bounty-list [bounty-component bounties]
(let [expanded? (r/atom false)] (let [expanded? (r/atom false)]
@ -280,7 +258,7 @@
"See all ↓")]])]))) "See all ↓")]])])))
(defn count-pill [n] (defn count-pill [n]
[:span.v-mid.ml3.ph3.pv1.bg-light-gray.br3.f7 n]) [:span.v-top.ml3.ph3.pv1.bg-black-05.gray.br3.f7 n])
(defn salute [name] (defn salute [name]
(let [msg-info (rf/subscribe [:dashboard/banner-msg])] (let [msg-info (rf/subscribe [:dashboard/banner-msg])]