Rename colors.py to constants.py and move all font-awesome icons to it

Essentially code cleanup
This commit is contained in:
Peder Bergebakken Sundt 2018-03-06 15:28:08 +01:00
parent 60b7da91aa
commit 03d228c3a1
2 changed files with 18 additions and 8 deletions

View File

@ -1,3 +1,4 @@
# Colors
COLOR_BLUE = "rgb(33, 150, 243)" COLOR_BLUE = "rgb(33, 150, 243)"
COLOR_BLUE_SHADOW = "rgba(33, 150, 243, 0.75)" COLOR_BLUE_SHADOW = "rgba(33, 150, 243, 0.75)"
COLOR_LIGHT_BLUE = "#e3f2fd" COLOR_LIGHT_BLUE = "#e3f2fd"
@ -22,3 +23,12 @@ COLOR_WARNING = "#ffc107"
COLOR_DANGER = "#dc3545" COLOR_DANGER = "#dc3545"
COLOR_LIGHT = "#f8f9fa" COLOR_LIGHT = "#f8f9fa"
COLOR_DARK = "#343a40" COLOR_DARK = "#343a40"
# Font Awesome
ICON_PREV = '<i class="fas fa-step-backward"></i>'
ICON_NEXT = '<i class="fas fa-step-forward"></i>'
ICON_PLAY = '<i class="fas fa-play"></i>'
ICON_PAUSE = '<i class="fas fa-pause"></i>'
ICON_TRASH = '<i class="fas fa-trash"></i>'
ICON_DOWN = '<i class="fas fa-arrow-down"></i>'
ICON_UP = '<i class="fas fa-arrow-up"></i>'

View File

@ -4,7 +4,7 @@ import remi.gui as gui
from remi import App from remi import App
from .utils import Namespace, call_as_thread, seconds_to_timestamp from .utils import Namespace, call_as_thread, seconds_to_timestamp
from . import api from . import api
from .colors import * from .constants import *
#globals: #globals:
WIDTH = 512 WIDTH = 512
@ -26,11 +26,11 @@ class RemiApp(App):
self.playback.playing = gui.Label("Now playing: None")# (TODO): update this self.playback.playing = gui.Label("Now playing: None")# (TODO): update this
self.playback.previous, self.playback.play, self.playback.next \ self.playback.previous = gui.Button(ICON_PREV, margin="3px", width="2.8em")
= map(lambda x: gui.Button(f'<i class="fas fa-{x}"></i>', margin="3px", width="2.8em"),
("step-backward", "play", "step-forward"))
self.playback.previous.set_on_click_listener(self.playback_previous) self.playback.previous.set_on_click_listener(self.playback_previous)
self.playback.play = gui.Button(ICON_PLAY, margin="3px", width="2.8em")
self.playback.play.set_on_click_listener(self.playback_play) self.playback.play.set_on_click_listener(self.playback_play)
self.playback.next = gui.Button(ICON_NEXT, margin="3px", width="2.8em")
self.playback.next.set_on_click_listener(self.playback_next) self.playback.next.set_on_click_listener(self.playback_next)
self.playback.play.style["background"] = f"linear-gradient(40deg,{COLOR_BLUE},{COLOR_PURPLE})" self.playback.play.style["background"] = f"linear-gradient(40deg,{COLOR_BLUE},{COLOR_PURPLE})"
@ -225,9 +225,9 @@ class RemiApp(App):
playlist_item["index"], playlist_item["index"],
name, name,
length, length,
'<i class="fas fa-arrow-up"></i>', ICON_UP,
'<i class="fas fa-arrow-down"></i>', ICON_DOWN,
'<i class="fas fa-trash"></i>', ICON_TRASH,
]) ])
self.playlist.table.empty(keep_title=True) self.playlist.table.empty(keep_title=True)
@ -264,6 +264,6 @@ class RemiApp(App):
#helpers #helpers
def set_playing(self, is_playing:bool): def set_playing(self, is_playing:bool):
self.playback.play.set_text('<i class="fas fa-pause"></i>' if is_playing else '<i class="fas fa-play"></i>') self.playback.play.set_text(ICON_PAUSE if is_playing else ICON_PLAY)
self.playback.seek_slider.set_enabled(is_playing) self.playback.seek_slider.set_enabled(is_playing)