mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-07 02:33:39 +02:00
Add open-iconic and use icons for playback control buttons
This commit is contained in:
parent
9858cece51
commit
115f5cd3e6
6 changed files with 43 additions and 14 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
|
@ -4608,6 +4608,11 @@
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"open-iconic": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/open-iconic/-/open-iconic-1.1.1.tgz",
|
||||||
|
"integrity": "sha1-nc/Ix808Yc20ojaxo0eJTJetwMY="
|
||||||
|
},
|
||||||
"optimist": {
|
"optimist": {
|
||||||
"version": "0.6.1",
|
"version": "0.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,14 @@
|
||||||
"build:cljs": "shadow-cljs release app",
|
"build:cljs": "shadow-cljs release app",
|
||||||
"build:html": "sed 's/\"\\/app\\//\".\\/app\\//g' src/html/index.html > public/index.html",
|
"build:html": "sed 's/\"\\/app\\//\".\\/app\\//g' src/html/index.html > public/index.html",
|
||||||
"build:sass": "node-sass --output-style compressed src/sass/app.sass public/app/style.css",
|
"build:sass": "node-sass --output-style compressed src/sass/app.sass public/app/style.css",
|
||||||
"build": "rm -r public/*; run-p build:*; ",
|
"build": "rm -r public/*; run-p copy:* build:*",
|
||||||
|
"copy:icons": "cp -R node_modules/open-iconic/font/fonts public",
|
||||||
"deploy": "npm run build && gh-pages -d public -m \"Deploying $(git rev-parse --short HEAD)\"",
|
"deploy": "npm run build && gh-pages -d public -m \"Deploying $(git rev-parse --short HEAD)\"",
|
||||||
"dev:cljs": "shadow-cljs watch app test",
|
"dev:cljs": "shadow-cljs watch app test",
|
||||||
"dev:html": "sed 's/\"\\.\\/app\\//\"\\/app\\//g' src/html/index.html > public/index.html",
|
"dev:html": "sed 's/\"\\.\\/app\\//\"\\/app\\//g' src/html/index.html > public/index.html",
|
||||||
"dev:sass": "npm run build:sass; node-sass -w src/sass/app.sass public/app/style.css",
|
"dev:sass": "npm run build:sass; node-sass -w src/sass/app.sass public/app/style.css",
|
||||||
"dev:test": "karma start --reporters growl,progress --auto-watch",
|
"dev:test": "karma start --reporters growl,progress --auto-watch",
|
||||||
"dev": "npm-run-all test:compile -p dev:*",
|
"dev": "npm-run-all copy:* test:compile -p dev:*",
|
||||||
"test": "run-s test:compile test:run",
|
"test": "run-s test:compile test:run",
|
||||||
"test:compile": "shadow-cljs compile test",
|
"test:compile": "shadow-cljs compile test",
|
||||||
"test:run": "karma start --single-run"
|
"test:run": "karma start --single-run"
|
||||||
|
|
@ -28,6 +29,7 @@
|
||||||
"@hugojosefson/color-hash": "^2.0.3",
|
"@hugojosefson/color-hash": "^2.0.3",
|
||||||
"bulma": "^0.7.1",
|
"bulma": "^0.7.1",
|
||||||
"create-react-class": "^15.6.3",
|
"create-react-class": "^15.6.3",
|
||||||
|
"open-iconic": "^1.1.1",
|
||||||
"react": "^16.3.2",
|
"react": "^16.3.2",
|
||||||
"react-dom": "^16.3.2",
|
"react-dom": "^16.3.2",
|
||||||
"shadow-cljs": "^2.3.19"
|
"shadow-cljs": "^2.3.19"
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,19 @@
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::current-content
|
::current-content
|
||||||
(fn [db]
|
(fn [db]
|
||||||
(-> db :response)))
|
(db :response)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
; returns info on the current song as is (basically the metadata you can read from the file system)
|
; returns info on the current song as is (basically the metadata you can read from the file system)
|
||||||
::currently-playing
|
::currently-playing
|
||||||
(fn [db]
|
(fn [db]
|
||||||
(-> db :currently-playing)))
|
(db :currently-playing)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::is-playing?
|
||||||
|
(fn [query-v _]
|
||||||
|
[(re-frame/subscribe [::currently-playing])])
|
||||||
|
(fn [[currently-playing]]
|
||||||
|
(let [status (:status currently-playing)]
|
||||||
|
(and (not (:paused? status))
|
||||||
|
(not (:ended? status))))))
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
(:require [re-frame.core :refer [dispatch subscribe]]
|
(:require [re-frame.core :refer [dispatch subscribe]]
|
||||||
[airsonic-ui.events :as events]
|
[airsonic-ui.events :as events]
|
||||||
[airsonic-ui.subs :as subs]
|
[airsonic-ui.subs :as subs]
|
||||||
[airsonic-ui.views.cover :refer [cover]]))
|
[airsonic-ui.views.cover :refer [cover]]
|
||||||
|
[airsonic-ui.views.icon :refer [icon]]))
|
||||||
|
|
||||||
;; currently playing / coming next / audio controls...
|
;; currently playing / coming next / audio controls...
|
||||||
|
|
||||||
|
|
@ -12,19 +13,23 @@
|
||||||
[:progress.progress.is-tiny {:value (:current-time status)
|
[:progress.progress.is-tiny {:value (:current-time status)
|
||||||
:max (:duration item)}]])
|
:max (:duration item)}]])
|
||||||
|
|
||||||
(defn playback-controls []
|
(defn playback-controls [is-playing?]
|
||||||
|
;; TODO: Toggle play pause icon based on playback status
|
||||||
[:div.field.has-addons
|
[:div.field.has-addons
|
||||||
(let [buttons [["previous" ::events/previous-song]
|
(let [buttons [[:media-step-backward ::events/previous-song]
|
||||||
["play / pause" ::events/toggle-play-pause]
|
[(if is-playing? :media-pause :media-play) ::events/toggle-play-pause]
|
||||||
["next" ::events/next-song]]]
|
[:media-step-forward ::events/next-song]]]
|
||||||
(map (fn [[label event]]
|
(map (fn [[icon-glyph event]]
|
||||||
[:p.control>button.button.is-light {:on-click #(dispatch [event])} label])
|
[:p.control>button.button.is-light {:on-click #(dispatch [event])}
|
||||||
|
[icon icon-glyph]])
|
||||||
buttons))])
|
buttons))])
|
||||||
|
|
||||||
(def logo-url "https://airsonic.github.io/airsonic-ui/assets/images/logo/airsonic-light-350x100.png")
|
(def logo-url "https://airsonic.github.io/airsonic-ui/assets/images/logo/airsonic-light-350x100.png")
|
||||||
|
|
||||||
(defn bottom-bar []
|
(defn bottom-bar []
|
||||||
(let [currently-playing @(subscribe [::subs/currently-playing])]
|
(let [currently-playing @(subscribe [::subs/currently-playing])
|
||||||
|
is-playing? @(subscribe [::subs/is-playing?])]
|
||||||
|
(println "is-playing?" is-playing?)
|
||||||
[:nav.navbar.is-fixed-bottom.playback-area
|
[:nav.navbar.is-fixed-bottom.playback-area
|
||||||
[:div.navbar-brand
|
[:div.navbar-brand
|
||||||
[:div.navbar-item
|
[:div.navbar-item
|
||||||
|
|
@ -36,6 +41,6 @@
|
||||||
[:div.level-left>article.media
|
[:div.level-left>article.media
|
||||||
[:div.media-left [cover (:item currently-playing) 48]]
|
[:div.media-left [cover (:item currently-playing) 48]]
|
||||||
[:div.media-content [current-song-info currently-playing]]]
|
[:div.media-content [current-song-info currently-playing]]]
|
||||||
[:div.level-right [playback-controls]]]
|
[:div.level-right [playback-controls is-playing?]]]
|
||||||
;; not playing anything
|
;; not playing anything
|
||||||
[:p.idle-notification "Currently no song selected"])]]))
|
[:p.idle-notification "Currently no song selected"])]]))
|
||||||
|
|
|
||||||
4
src/cljs/airsonic_ui/views/icon.cljs
Normal file
4
src/cljs/airsonic_ui/views/icon.cljs
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
(ns airsonic-ui.views.icon)
|
||||||
|
|
||||||
|
(defn icon [glyph]
|
||||||
|
[:span.icon [:span.oi {:data-glyph (name glyph)}]])
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
@import "../../node_modules/bulma/bulma"
|
@import "../../node_modules/bulma/bulma"
|
||||||
|
@import "../../node_modules/open-iconic/font/css/open-iconic.scss"
|
||||||
|
|
||||||
// area holding content & side navi
|
// area holding content & side navi
|
||||||
#app main
|
#app main
|
||||||
|
|
@ -27,9 +28,12 @@
|
||||||
.level-right
|
.level-right
|
||||||
flex-grow: 0
|
flex-grow: 0
|
||||||
flex-shrink: 1
|
flex-shrink: 1
|
||||||
|
padding-left: .5rem
|
||||||
|
padding-left: .5rem
|
||||||
|
padding-right: .5rem
|
||||||
|
|
||||||
.progress.is-tiny
|
.progress.is-tiny
|
||||||
height: 0.25rem
|
height: .25rem
|
||||||
|
|
||||||
// cover images
|
// cover images
|
||||||
.image.is-256x256
|
.image.is-256x256
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue