Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSS themes #125

Merged
merged 3 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions backend/static/js/auto_darktheme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*!
* Color mode toggler for Bootstrap's docs (https://getbootstrap.com/)
* Copyright 2011-2024 The Bootstrap Authors
* Licensed under the Creative Commons Attribution 3.0 Unported License.
*/

(() => {
'use strict'

const getStoredTheme = () => localStorage.getItem('theme')
const setStoredTheme = theme => localStorage.setItem('theme', theme)

const getPreferredTheme = () => {
const storedTheme = getStoredTheme()
if (storedTheme) {
return storedTheme
}

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

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

setTheme(getPreferredTheme())

const showActiveTheme = (theme) => {

const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`)

document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
element.classList.remove('active')
element.setAttribute('aria-pressed', 'false')
})

btnToActive.classList.add('active')
btnToActive.setAttribute('aria-pressed', 'true')
}


window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
const storedTheme = getStoredTheme()
if (storedTheme !== 'light' && storedTheme !== 'dark') {
setTheme(getPreferredTheme())
}
})

window.addEventListener('DOMContentLoaded', () => {
showActiveTheme(getPreferredTheme())

document.querySelectorAll('[data-bs-theme-value]')
.forEach(toggle => {
toggle.addEventListener('click', () => {
const theme = toggle.getAttribute('data-bs-theme-value')
setStoredTheme(theme)
setTheme(theme)
showActiveTheme(theme)
})
})
})

})()
9 changes: 9 additions & 0 deletions frontend/static/icons/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Font license info


## Entypo

Copyright (C) 2012 by Daniel Bruce

Author: Daniel Bruce
License: SIL (http://scripts.sil.org/OFL)
Homepage: http://www.entypo.com


## Font Awesome

Copyright (C) 2016 by Dave Gandy
Expand Down
18 changes: 18 additions & 0 deletions frontend/static/icons/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@
"css": "menu",
"code": 61762,
"src": "fontawesome"
},
{
"uid": "f8e120c48c070f8afd2d072651b4fb9f",
"css": "light-up",
"code": 59392,
"src": "entypo"
},
{
"uid": "0d03db7afd4857accf1821efdc8ea72b",
"css": "moon",
"code": 59393,
"src": "entypo"
},
{
"uid": "f6fa10cb3ffec7becb60834f50bb0182",
"css": "adjust",
"code": 59395,
"src": "entypo"
}
]
}
3 changes: 3 additions & 0 deletions frontend/static/icons/css/songs-codes.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

.icon-light-up:before { content: '\e800'; } /* '' */
.icon-moon:before { content: '\e801'; } /* '' */
.icon-trash-empty:before { content: '\e802'; } /* '' */
.icon-adjust:before { content: '\e803'; } /* '' */
.icon-plus:before { content: '\e804'; } /* '' */
.icon-minus:before { content: '\e805'; } /* '' */
.icon-up-open:before { content: '\e806'; } /* '' */
Expand Down
15 changes: 9 additions & 6 deletions frontend/static/icons/css/songs-embedded.css

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions frontend/static/icons/css/songs-ie7-codes.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

.icon-light-up { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-moon { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-trash-empty { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-adjust { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-plus { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-minus { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-up-open { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
Expand Down
3 changes: 3 additions & 0 deletions frontend/static/icons/css/songs-ie7.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
/* font-size: 120%; */
}

.icon-light-up { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-moon { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-trash-empty { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-adjust { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-plus { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-minus { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
.icon-up-open { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
Expand Down
17 changes: 10 additions & 7 deletions frontend/static/icons/css/songs.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@font-face {
font-family: 'songs';
src: url('../font/songs.eot?84746066');
src: url('../font/songs.eot?84746066#iefix') format('embedded-opentype'),
url('../font/songs.woff2?84746066') format('woff2'),
url('../font/songs.woff?84746066') format('woff'),
url('../font/songs.ttf?84746066') format('truetype'),
url('../font/songs.svg?84746066#songs') format('svg');
src: url('../font/songs.eot?15005186');
src: url('../font/songs.eot?15005186#iefix') format('embedded-opentype'),
url('../font/songs.woff2?15005186') format('woff2'),
url('../font/songs.woff?15005186') format('woff'),
url('../font/songs.ttf?15005186') format('truetype'),
url('../font/songs.svg?15005186#songs') format('svg');
font-weight: normal;
font-style: normal;
}
Expand All @@ -15,7 +15,7 @@
@media screen and (-webkit-min-device-pixel-ratio:0) {
@font-face {
font-family: 'songs';
src: url('../font/songs.svg?84746066#songs') format('svg');
src: url('../font/songs.svg?15005186#songs') format('svg');
}
}
*/
Expand Down Expand Up @@ -54,7 +54,10 @@
/* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
}

.icon-light-up:before { content: '\e800'; } /* '' */
.icon-moon:before { content: '\e801'; } /* '' */
.icon-trash-empty:before { content: '\e802'; } /* '' */
.icon-adjust:before { content: '\e803'; } /* '' */
.icon-plus:before { content: '\e804'; } /* '' */
.icon-minus:before { content: '\e805'; } /* '' */
.icon-up-open:before { content: '\e806'; } /* '' */
Expand Down
Binary file modified frontend/static/icons/font/songs.eot
Binary file not shown.
8 changes: 7 additions & 1 deletion frontend/static/icons/font/songs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/static/icons/font/songs.ttf
Binary file not shown.
Binary file modified frontend/static/icons/font/songs.woff
Binary file not shown.
Binary file modified frontend/static/icons/font/songs.woff2
Binary file not shown.
22 changes: 12 additions & 10 deletions frontend/static/styles.sass
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ $bgDefault : #f9f9f9
$bgHighlight : #c4c2bd
$colDefault : #7793f3
$colHighlight : #e81c1c
$absoluteBlack : #000000
$originalDark : #212529
$border-color: $bgHighlight

[data-bs-theme="dark"]
--bs-body-bg: #{$absoluteBlack}

[data-bs-theme="dark"] .navbar
background: #{$originalDark}

.navbar
--bs-navbar-color: #{$colDefault}
--bs-navbar-hover-color: #{$colHighlight}
Expand All @@ -14,12 +22,6 @@ $border-color: $bgHighlight
.dropdown-menu
--bs-dropdown-link-color: #{$colDefault}
--bs-dropdown-link-hover-color: #{$colHighlight}
--bs-dropdown-link-active-bg: #{$colDefault}

//.chord
// position: absolute
// line-height: 0
// font-weight: bold

.chord
font-weight: bold
Expand All @@ -38,7 +40,7 @@ $border-color: $bgHighlight
margin: auto
width: 90%
text-align: center
border: 3px solid $border-color
border: 3px solid var(--bs-border-color)

html, body
height: 100%
Expand All @@ -63,7 +65,7 @@ html, body
z-index: 10

hr
background-color: $border-color
background-color: var(--bs-border-color)
height: 2px

.languages
Expand Down Expand Up @@ -94,8 +96,8 @@ hr
height: 1px

.accordion-button:not(.collapsed)
background-color: white
color: black
background-color: var(--bs-accordion-btn-bg)
color: var(--bs-accordion-btn-color)
&:focus
box-shadow: var(--bs-accordion-btn-focus-box-shadow)

Expand Down
8 changes: 8 additions & 0 deletions frontend/templates/base/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<script src="{% static "js/jquery-3.7.1.min.js" %}"
type="text/javascript"
defer></script>
<script src="{% static "js/auto_darktheme.js" %}"
type="text/javascript"
defer></script>
<link rel="stylesheet" type="text/css" href="{% static 'icons/css/songs.css' %}">
<link rel="stylesheet" type="text/css" href="{% sass_src 'styles.sass' %}">
{% block extra_head %} {% endblock %}
Expand Down Expand Up @@ -74,6 +77,11 @@
{% trans "Language" %}
</label>
</div>
<div class="mb-1 d-flex ms-2 me-2 justify-content-center">
<button class="btn btn-outline-secondary me-2" type="button" data-bs-theme-value="light"><i class="icon-light-up"></i></button>
<button class="btn btn-outline-secondary me-2" type="button" data-bs-theme-value="dark"><i class="icon-moon"></i></button>
<button class="btn btn-outline-secondary" type="button" data-bs-theme-value="auto"><i class="icon-adjust"></i></button>
</div>
{% for locale in languages %}
<form id="{{ locale.code }}" action="{% url 'set_language' %}" method="post">
{% csrf_token %}
Expand Down
Loading