mirror of
https://github.com/status-im/open-bounty.git
synced 2025-03-01 01:20:41 +00:00
add some bounty sorting
This commit is contained in:
parent
26c740517b
commit
bdbdc2e2d2
@ -2,7 +2,9 @@
|
||||
(:require [reagent.core :as r]
|
||||
[re-frame.core :as rf]
|
||||
[commiteth.common :refer [moment-timestamp
|
||||
issue-url]]))
|
||||
issue-url]]
|
||||
[commiteth.handlers :as handlers]
|
||||
[commiteth.db :as db]))
|
||||
|
||||
|
||||
(defn bounty-item [bounty]
|
||||
@ -60,40 +62,44 @@
|
||||
(defn bounties-filters []
|
||||
[:div.open-bounties-filter
|
||||
[bounties-filter "Value"]
|
||||
[bounties-filter "Type"]
|
||||
[bounties-filter "Language"]
|
||||
[bounties-filter "Currency"]
|
||||
[bounties-filter "Date"]
|
||||
[bounties-filter "More"]])
|
||||
[bounties-filter "Owner"]])
|
||||
|
||||
(defn bounties-sort []
|
||||
(let [open? (r/atom false)]
|
||||
(fn []
|
||||
[:div.open-bounties-sort
|
||||
{:tab-index 0
|
||||
:on-blur #(reset! open? false)}
|
||||
[:div.open-bounties-sort-element
|
||||
{:on-click #(swap! open? not)}
|
||||
"Most Recent"
|
||||
[:div.icon-forward-white-box
|
||||
[:img
|
||||
{:src "icon-forward-white.svg"}]]]
|
||||
(when @open?
|
||||
[:div.open-bounties-sort-element-tooltip
|
||||
"TOOLTIP"])])))
|
||||
(let [current-sorting (rf/subscribe [::db/bounty-sorting-type])]
|
||||
[:div.open-bounties-sort
|
||||
{:tab-index 0
|
||||
:on-blur #(reset! open? false)}
|
||||
[:div.open-bounties-sort-element
|
||||
{:on-click #(swap! open? not)}
|
||||
(db/bounty-sorting-types @current-sorting)
|
||||
[:div.icon-forward-white-box
|
||||
[:img
|
||||
{:src "icon-forward-white.svg"}]]]
|
||||
(when @open?
|
||||
[:div.open-bounties-sort-element-tooltip
|
||||
(for [[sorting-type sorting-name] db/bounty-sorting-types]
|
||||
[:div.open-bounties-sort-type
|
||||
{:on-click #(do
|
||||
(reset! open? false)
|
||||
(rf/dispatch [::handlers/set-bounty-sorting-type sorting-type]))}
|
||||
sorting-name])])]))))
|
||||
|
||||
(defn bounties-list [open-bounties]
|
||||
(let [order (rf/subscribe [:bounties-order])]
|
||||
[:div.ui.container.open-bounties-container
|
||||
[:div.open-bounties-header "Bounties"]
|
||||
[:div.open-bounties-filter-and-sort
|
||||
[bounties-filters]
|
||||
[bounties-sort]]
|
||||
(if (empty? open-bounties)
|
||||
[:div.view-no-data-container
|
||||
[:p "No recent activity yet"]]
|
||||
(into [:div.ui.items]
|
||||
(for [bounty open-bounties]
|
||||
[bounty-item bounty])))]))
|
||||
[:div.ui.container.open-bounties-container
|
||||
[:div.open-bounties-header "Bounties"]
|
||||
[:div.open-bounties-filter-and-sort
|
||||
[bounties-filters]
|
||||
[bounties-sort]]
|
||||
(if (empty? open-bounties)
|
||||
[:div.view-no-data-container
|
||||
[:p "No recent activity yet"]]
|
||||
(into [:div.ui.items]
|
||||
(for [bounty open-bounties]
|
||||
[bounty-item bounty])))])
|
||||
|
||||
|
||||
(defn bounties-page []
|
||||
|
@ -1,14 +1,19 @@
|
||||
(ns commiteth.db)
|
||||
|
||||
(def bounty-sorting-types {::bounty-sorting-type|most-recent "Most recent"
|
||||
::bounty-sorting-type|lowest-value "Lowest value"
|
||||
::bounty-sorting-type|highest-value "Highest value"
|
||||
::bounty-sorting-type|owner "Owner"})
|
||||
|
||||
(def default-db
|
||||
{:page :bounties
|
||||
:user nil
|
||||
:repos-loading? false
|
||||
:repos {}
|
||||
{:page :bounties
|
||||
:user nil
|
||||
:repos-loading? false
|
||||
:repos {}
|
||||
:activity-feed-loading? false
|
||||
:open-bounties-loading? false
|
||||
:open-bounties []
|
||||
:owner-bounties {}
|
||||
:top-hunters []
|
||||
:activity-feed []
|
||||
:bounties-order ::bounties-order|most-recent})
|
||||
:open-bounties []
|
||||
:owner-bounties {}
|
||||
:top-hunters []
|
||||
:activity-feed []
|
||||
::bounty-sorting-type ::bounty-sorting-type|most-recent})
|
||||
|
@ -453,3 +453,8 @@
|
||||
(fn [db [_]]
|
||||
(.removeEventListener js/window "click" close-dropdown)
|
||||
(assoc db :user-dropdown-open? false)))
|
||||
|
||||
(reg-event-db
|
||||
::set-bounty-sorting-type
|
||||
(fn [db [_ sorting-type]]
|
||||
(assoc db ::db/bounty-sorting-type sorting-type)))
|
||||
|
@ -1,5 +1,6 @@
|
||||
(ns commiteth.subscriptions
|
||||
(:require [re-frame.core :refer [reg-sub]]))
|
||||
(:require [re-frame.core :refer [reg-sub]]
|
||||
[commiteth.db :as db]))
|
||||
|
||||
(reg-sub
|
||||
:db
|
||||
@ -82,6 +83,6 @@
|
||||
(:user-dropdown-open? db)))
|
||||
|
||||
(reg-sub
|
||||
:bounties-order
|
||||
::db/bounty-sorting-type
|
||||
(fn [db _]
|
||||
(:bounties-order db)))
|
||||
(::db/bounty-sorting-type db)))
|
||||
|
@ -484,8 +484,7 @@
|
||||
.open-bounties-sort-element-tooltip {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
//margin-top: 12px;
|
||||
padding: 16px 24px;
|
||||
//padding: 16px 0;
|
||||
min-width: 200px;
|
||||
border-radius: 8px;
|
||||
background-color: #1e3751;
|
||||
@ -496,6 +495,15 @@
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.open-bounties-sort-type {
|
||||
padding: 19px 24px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.open-bounties-sort-type:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.icon-forward-white-box {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
|
Loading…
x
Reference in New Issue
Block a user