Skip to content

Commit

Permalink
UI Redesign (#121)
Browse files Browse the repository at this point in the history
 - Added color theme support
 - Added `neon-dark` and `custom-dark` color themes
 - Added `/settings` endpoint to change color themes client-side
  • Loading branch information
dssecret authored Feb 23, 2023
1 parent 7384cb9 commit 7a5ad1f
Show file tree
Hide file tree
Showing 72 changed files with 2,110 additions and 1,631 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version
- Migrated config to use `utils.config.Config` from `settings.py` (#117)
- Added `user.fetch_attacks_runner` and `user.stat_db_attacks_user`
- Added auto-cancellation of vault withdrawals
- Added color theme support
- Added account settings endpoint

=== Fixed
- Fixed Tox CI runs (due to broken dependency installation)
Expand Down
7 changes: 6 additions & 1 deletion controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ def index():
return render_template("index.html", extensions=extensions)


@mod.route("/settings")
def settings():
return render_template("settings.html")


@mod.route("/static/toast.js")
@mod.route("/static/favicon.svg")
@mod.route("/static/login.css")
@mod.route("/static/utils.js")
@mod.route("/static/bot/oc.js")
@mod.route("/static/bot/stakeouts.js")
Expand All @@ -43,6 +47,7 @@ def index():
@mod.route("/static/faction/bankingaa.js")
@mod.route("/static/faction/chain.js")
@mod.route("/static/faction/members.js")
@mod.route("/static/fonts/JetBrainsMono-Light.woff2")
@mod.route("/static/stats/db.js")
@mod.route("/static/stats/list.js")
@mod.route("/static/torn/factions.js")
Expand Down
11 changes: 0 additions & 11 deletions controllers/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ def error404(e):
)


@mod.app_errorhandler(422)
def error422(e):
"""
Returns the 422 error page
:param e: HTTP error
"""

return render_template("/errors/422.html"), 422


@mod.app_errorhandler(500)
def error500(e):
"""
Expand Down
1 change: 1 addition & 0 deletions models/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, sid):
self.name = server.name
self.admins = server.admins
self.config = server.config
self.icon = server.icon

self.factions = server.factions

Expand Down
1 change: 1 addition & 0 deletions models/servermodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ServerModel(DynamicDocument):
name = StringField(default="")
admins = ListField(default=[]) # List of admin ids
config = DictField(default={"stakeouts": 0, "verify": 0}) # Dictionary of server configurations
icon = StringField(default="") # icon hash

factions = ListField(default=[]) # List of factions in server

Expand Down
2 changes: 1 addition & 1 deletion skynet/commands/bot/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def verify(interaction, *args, **kwargs):
{
"title": "Verification Failed",
"description": "No Discord ID found. Please verify that you are officially verified by Torn. "
"Otherwise, try forcing the verification.",
"Otherwise, try forcing the verification.",
"color": SKYNET_ERROR,
}
],
Expand Down
13 changes: 11 additions & 2 deletions static/base.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
a:link {
text-decoration: none;
@font-face {
font-family: "JetBrains Mono";
src: url("/static/fonts/JetBrainsMono-Light.woff2") format("woff");
}

body {
font-family: "JetBrains Mono", serif;
}

.vertical-navbar {
min-height: 100vh;
}
Binary file added static/fonts/JetBrainsMono-Light.woff2
Binary file not shown.
35 changes: 35 additions & 0 deletions static/global/modeSelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*!
* Color mode toggler for Bootstrap's docs (https://getbootstrap.com/)
* Copyright 2011-2022 The Bootstrap Authors
* Licensed under the Creative Commons Attribution 3.0 Unported License.
*/

(() => {
'use strict';

const storedTheme = localStorage.getItem('theme');

const getPreferredTheme = function () {
if (storedTheme) {
return storedTheme;
}

return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'custom-dark' : 'light';
}

const setTheme = function (theme) {
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-bs-theme', 'custom-dark');
} else {
document.documentElement.setAttribute('data-bs-theme', theme);
}
}

setTheme(getPreferredTheme());

window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if (storedTheme !== 'light' || storedTheme !== 'custom-dark') {
setTheme(getPreferredTheme());
}
});
})()
29 changes: 0 additions & 29 deletions static/login.css

This file was deleted.

114 changes: 114 additions & 0 deletions static/themes/dark.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions static/themes/dark.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7a5ad1f

Please sign in to comment.