From a3d3d97b3b73bc1650264bc61dd9f7a796e5df75 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Mon, 6 Jul 2020 20:53:14 +0100 Subject: [PATCH] Added theme toggle to Admin page The admin can switch between the two default themes without a page reload, with a nice animation (on small screens). Preference is stored as a cookie, so the default theme setting will still apply to others. --- config-default.ini | 6 +- jellyfin_accounts/__init__.py | 4 +- jellyfin_accounts/data/config-base.json | 4 +- jellyfin_accounts/data/templates/admin.html | 61 +++++++++++- jellyfin_accounts/data/templates/admin.js | 100 ++++++++++++++++++-- jellyfin_accounts/web.py | 14 ++- pyproject.toml | 2 +- 7 files changed, 165 insertions(+), 26 deletions(-) diff --git a/config-default.ini b/config-default.ini index 33271ef..4daf69f 100644 --- a/config-default.ini +++ b/config-default.ini @@ -9,13 +9,13 @@ server = http://jellyfin.local:8096 public_server = https://jellyf.in:443 ; this and below settings will show on the jellyfin dashboard when the program connects. you may as well leave them alone. client = jf-accounts -version = 0.3.0 +version = 0.3.2 device = jf-accounts -device_id = jf-accounts-0.3.0 +device_id = jf-accounts-0.3.2 [ui] ; settings related to the ui and program functionality. -; choose the look of jellyfin-accounts. +; default appearance for all users. theme = Jellyfin (Dark) ; set 0.0.0.0 to run on localhost host = 0.0.0.0 diff --git a/jellyfin_accounts/__init__.py b/jellyfin_accounts/__init__.py index 4ae7053..4c23d6d 100755 --- a/jellyfin_accounts/__init__.py +++ b/jellyfin_accounts/__init__.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -__version__ = "0.3.2" +__version__ = "0.3.3" import secrets import configparser @@ -218,7 +218,7 @@ elif "Custom" in current_theme and "custom_css" in config["files"]: try: css_path = Path(config["files"]["custom_css"]) shutil.copy(css_path, (local_dir / "static" / css_path.name)) - log.debug('Loaded custom CSS "{css_path.name}"') + log.debug(f'Loaded custom CSS "{css_path.name}"') css_file = css_path.name except FileNotFoundError: log.error( diff --git a/jellyfin_accounts/data/config-base.json b/jellyfin_accounts/data/config-base.json index 3b26383..af11e87 100644 --- a/jellyfin_accounts/data/config-base.json +++ b/jellyfin_accounts/data/config-base.json @@ -71,7 +71,7 @@ "description": "Settings related to the UI and program functionality." }, "theme": { - "name": "Look", + "name": "Default Look", "required": false, "requires_restart": true, "type": "select", @@ -81,7 +81,7 @@ "Custom CSS" ], "value": "Jellyfin (Dark)", - "description": "Choose the look of jellyfin-accounts." + "description": "Default appearance for all users." }, "host": { "name": "Address", diff --git a/jellyfin_accounts/data/templates/admin.html b/jellyfin_accounts/data/templates/admin.html index e94f7c5..c0f1aa1 100644 --- a/jellyfin_accounts/data/templates/admin.html +++ b/jellyfin_accounts/data/templates/admin.html @@ -14,7 +14,39 @@ - + {% if not bs5 %} {% endif %} @@ -53,10 +85,27 @@ margin-top: 5%; color: grey; } + .circle { + /*margin-left: 1rem; + width: 1rem; + height: 1rem; + border-radius: 50%; + z-index: 5000;*/ + -webkit-transition: all 300ms cubic-bezier(0.550, 0.055, 0.675, 0.190); + -moz-transition: all 300ms cubic-bezier(0.550, 0.055, 0.675, 0.190); + -o-transition: all 300ms cubic-bezier(0.550, 0.055, 0.675, 0.190); + transition: all 300ms cubic-bezier(0.550, 0.055, 0.675, 0.190); /* easeInCubic */ + } + .smooth-transition { + -webkit-transition: all 300ms cubic-bezier(0.550, 0.055, 0.675, 0.190); + -moz-transition: all 300ms cubic-bezier(0.550, 0.055, 0.675, 0.190); + -o-transition: all 300ms cubic-bezier(0.550, 0.055, 0.675, 0.190); + transition: all 300ms cubic-bezier(0.550, 0.055, 0.675, 0.190); /* easeInCubic */ + } Admin - +