mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Improve spacing when browsing the library
This commit is contained in:
parent
f0324a236d
commit
9ccaabfe29
3 changed files with 38 additions and 26 deletions
|
|
@ -1,16 +1,9 @@
|
|||
(ns airsonic-ui.components.library.views
|
||||
(:require [re-frame.core :refer [subscribe]]
|
||||
[bulma.tabs :refer [tabs]]
|
||||
[airsonic-ui.routes :as routes :refer [url-for]]
|
||||
[airsonic-ui.components.collection.views :as collection]))
|
||||
|
||||
(defn tabs [{:keys [items active-item]}]
|
||||
[:div.tabs
|
||||
[:ul (for [[idx [route label]] (map-indexed vector items)]
|
||||
(let [[_ params _] route]
|
||||
^{:key idx} [:li (when (= params active-item)
|
||||
{:class "is-active"})
|
||||
[:a {:href (apply url-for route)} label]]))]])
|
||||
|
||||
;; this variable determines how many pages before the first known page we should list
|
||||
(def page-padding 2)
|
||||
|
||||
|
|
@ -58,22 +51,29 @@
|
|||
(when (< current-page (- num-pages page-padding))
|
||||
[:li [pagination-link current-page num-pages (url-fn num-pages)]])]]))
|
||||
|
||||
(def tab-items [[[::routes/library {:kind "recent"} nil] "Recently played"]
|
||||
[[::routes/library {:kind "newest"} nil] "Newest additions"]
|
||||
[[::routes/library {:kind "starred"} nil] "Starred"]])
|
||||
(defn tab-items [[current-id current-params :as current-route]]
|
||||
(->>
|
||||
[[[::routes/library {:kind "recent"}] "Recently played"]
|
||||
[[::routes/library {:kind "newest"}] "Newest additions"]
|
||||
[[::routes/library {:kind "starred"}] "Starred"]]
|
||||
(map (fn [[[id params :as route] label]]
|
||||
(cond-> {:href (apply routes/url-for route)
|
||||
:label label}
|
||||
(and (= id current-id)
|
||||
(= (:kind params) (:kind current-params)))
|
||||
(assoc :active? true))))))
|
||||
|
||||
(defn main
|
||||
"Renders the pagination and shows a list of all albums with their cover art.
|
||||
The first parameter is the route that's passed in, the second one is the
|
||||
content that has been fetched for that route."
|
||||
[[_ {:keys [kind]} {:keys [page]
|
||||
:or {page 1}}]
|
||||
[[_ {:keys [kind]} {:keys [page] :or {page 1}} :as current-route]
|
||||
{:keys [scan-status]}]
|
||||
(let [page (int page)
|
||||
library @(subscribe [:library/paginated kind])
|
||||
(let [library @(subscribe [:library/paginated kind])
|
||||
page (int page)
|
||||
current-items (get library page)
|
||||
url-fn #(url-for ::routes/library {:kind kind} {:page %})
|
||||
pagination [pagination {:current-page page
|
||||
pagination-links [pagination {:current-page page
|
||||
:items library
|
||||
:url-fn url-fn}]]
|
||||
[:div
|
||||
|
|
@ -83,8 +83,8 @@
|
|||
[:p.subtitle.is-5.has-text-grey [:strong (:count scan-status)] " items"]
|
||||
(when (:scanning scan-status)
|
||||
[:p.subtitle.is-5.has-text-grey "Scanning…"]))]
|
||||
[:section.section>div.container
|
||||
[tabs {:items tab-items :active-item {:kind kind}}]
|
||||
pagination
|
||||
[:section.section [collection/listing current-items]]
|
||||
pagination]]))
|
||||
[:section.section.is-small>div.container
|
||||
[tabs {:items (tab-items current-route)}]]
|
||||
[:section.section.is-tiny>div.container pagination-links]
|
||||
[:section.section.is-tiny>div.container [collection/listing current-items]]
|
||||
[:section.section.is-tiny>div.container pagination-links]]))
|
||||
|
|
|
|||
8
src/cljs/bulma/tabs.cljs
Normal file
8
src/cljs/bulma/tabs.cljs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(ns bulma.tabs)
|
||||
|
||||
(defn tabs [{:keys [items]}]
|
||||
[:div.tabs
|
||||
[:ul
|
||||
(for [[idx {:keys [href label active?]}] (map-indexed vector items)]
|
||||
^{:key idx} [:li (when active? {:class "is-active"})
|
||||
[:a {:href href} label]])]])
|
||||
|
|
@ -232,9 +232,13 @@
|
|||
|
||||
// useful in general to pull elements closer together; bulma es very generous
|
||||
// with whitespace
|
||||
.section.is-small
|
||||
padding-top: 24px
|
||||
padding-bottom: 24px
|
||||
.section
|
||||
// $section-padding: 3rem 1.5rem
|
||||
&.is-small
|
||||
padding: 1.5rem 1.5rem
|
||||
|
||||
&.is-tiny
|
||||
padding: 0.75rem 1.5rem
|
||||
|
||||
// occurs on many pages at the top to show details
|
||||
.hero
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue