mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-07 02:33:39 +02:00
Improvements to currently playing queue (#48)
* First sloppy import of code from heyarne/reagent-movable * Consistently use "current queue" to avoid confusion * Update shadow-cljs, re-frame and debux * Solve styling problem when sorting table rows * Make sortable component more reusable * Refactor playlist to use a sorted-map * Make sure current queue is displayed again * Fix sorting when converting a shuffled into a linear playlist * Implement set-current-track * Implement song-move in playlist * Add autoprefixer * Implement drag and drop reordering in current queue * Fix broken dev sass build * Bump some dependencies * Move airsonic-ui.views.icon to bulma.icon * Implement reusable dropdown in bulma.dropdown * Immediately render reordered tracks, reimplement actions in album view * Use new song-table on search result page * Make song-table more reusable * Remove current song * Implement go to source in current queue * Remove unused song view
This commit is contained in:
parent
f0324a236d
commit
8bf222a6e8
29 changed files with 1773 additions and 869 deletions
20
src/cljs/bulma/dropdown/events.cljs
Normal file
20
src/cljs/bulma/dropdown/events.cljs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
(ns bulma.dropdown.events
|
||||
(:require [re-frame.core :as rf]))
|
||||
|
||||
(defn show-dropdown [db [_ dropdown-id]]
|
||||
(assoc-in db [:bulma :visible-dropdown] dropdown-id))
|
||||
|
||||
(rf/reg-event-db ::show show-dropdown)
|
||||
|
||||
(defn hide-dropdown [db _]
|
||||
(update db :bulma dissoc :visible-dropdown))
|
||||
|
||||
(rf/reg-event-db ::hide hide-dropdown)
|
||||
|
||||
(defn toggle-dropdown [db [_ dropdown-id]]
|
||||
(let [visible-dropdown (get-in db [:bulma :visible-dropdown])]
|
||||
(if (= visible-dropdown dropdown-id)
|
||||
(hide-dropdown db [::hide])
|
||||
(show-dropdown db [::show dropdown-id]))))
|
||||
|
||||
(rf/reg-event-db ::toggle toggle-dropdown)
|
||||
22
src/cljs/bulma/dropdown/subs.cljs
Normal file
22
src/cljs/bulma/dropdown/subs.cljs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(ns bulma.dropdown.subs
|
||||
(:require [re-frame.core :as rf]))
|
||||
|
||||
;; NOTE: This is almost the same as bulma.modal.subs
|
||||
;; Maybe we can provide some abstraction that covers both, but maybe we shouldn't
|
||||
|
||||
(defn visible-dropdown
|
||||
"Gives us the ID of the currently visible dropdown"
|
||||
[db _]
|
||||
(get-in db [:bulma :visible-dropdown]))
|
||||
|
||||
(rf/reg-sub ::visible-dropdown visible-dropdown)
|
||||
|
||||
(defn visible?
|
||||
"Predicate to check the visibility of a single modal"
|
||||
[visible-dropdown [_ dropdown-id]]
|
||||
(= visible-dropdown dropdown-id))
|
||||
|
||||
(rf/reg-sub
|
||||
::visible?
|
||||
:<- [::visible-dropdown]
|
||||
visible?)
|
||||
43
src/cljs/bulma/dropdown/views.cljs
Normal file
43
src/cljs/bulma/dropdown/views.cljs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
(ns bulma.dropdown.views
|
||||
(:require [re-frame.core :refer [dispatch subscribe]]
|
||||
[reagent.core :as r]
|
||||
[bulma.icon :refer [icon]]
|
||||
[bulma.dropdown.events :as ev]
|
||||
[bulma.dropdown.subs :as sub]))
|
||||
|
||||
(defn choose-action [event-vector]
|
||||
(fn [e]
|
||||
(.preventDefault e)
|
||||
(dispatch [::ev/hide])
|
||||
(dispatch event-vector)))
|
||||
|
||||
(defn generate-id []
|
||||
(str "bulma-dropdown-" (random-uuid)))
|
||||
|
||||
(defn click-overlay
|
||||
[]
|
||||
[:div {:style {:position "fixed"
|
||||
:z-index 19 ;; <- 20 is the z-index of .dropdown-menu
|
||||
:top 0
|
||||
:left 0
|
||||
:bottom 0
|
||||
:right 0}
|
||||
:on-click #(dispatch [::ev/hide])}])
|
||||
|
||||
(defn dropdown [{:keys [items]}]
|
||||
(let [dropdown-id (generate-id)]
|
||||
(fn []
|
||||
(let [visible? @(subscribe [::sub/visible? dropdown-id])]
|
||||
[(if visible? :div.dropdown.is-right.is-active :div.dropdown.is-right)
|
||||
(when visible? [click-overlay])
|
||||
[:div.dropdown-trigger
|
||||
[:span.is-small.button {:aria-haspopup "true"
|
||||
:aria-controls dropdown-id
|
||||
:on-click #(dispatch [::ev/toggle dropdown-id])}
|
||||
[icon :ellipses]]]
|
||||
[:div.dropdown-menu {:id dropdown-id, :role "menu"}
|
||||
[:div.dropdown-content
|
||||
(for [[idx {:keys [label event]}] (map-indexed vector items)]
|
||||
^{:key (str dropdown-id "-" idx)}
|
||||
[:a.dropdown-item {:href "#"
|
||||
:on-click (choose-action event)} label])]]]))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue