Change the implementation of grayscale

main
Bob Mottram 2020-07-11 10:22:06 +01:00
parent 7ec9ecfc6e
commit dabf1334fd
5 changed files with 35 additions and 78 deletions

View File

@ -1,5 +1,4 @@
:root { :root {
--grayscale: 0%;
--main-bg-color: #282c37; --main-bg-color: #282c37;
--calendar-bg-color: #eee; --calendar-bg-color: #eee;
--lines-color: black; --lines-color: black;
@ -39,7 +38,6 @@ body {
font-family: 'Montserrat'; font-family: 'Montserrat';
font-weight: 700; font-weight: 700;
min-height: 100vh; min-height: 100vh;
filter: grayscale(var(--grayscale));
} }
main { main {
@ -182,12 +180,10 @@ tr:nth-child(even) > .calendar__day__cell:nth-child(even) {
} }
.calendardayicon { .calendardayicon {
filter: grayscale(var(--grayscale));
width: 100% width: 100%
} }
.buttonprev { .buttonprev {
filter: grayscale(var(--grayscale));
float: left; float: left;
width: 10%; width: 10%;
-ms-transform: translateY(30%); -ms-transform: translateY(30%);
@ -195,7 +191,6 @@ tr:nth-child(even) > .calendar__day__cell:nth-child(even) {
} }
.buttonnext { .buttonnext {
filter: grayscale(var(--grayscale));
float: right; float: right;
width: 10%; width: 10%;
-ms-transform: translateY(30%) scaleX(-1); -ms-transform: translateY(30%) scaleX(-1);

View File

@ -1,7 +1,6 @@
@charset "UTF-8"; @charset "UTF-8";
:root { :root {
--grayscale: 0%;
--main-bg-color: #282c37; --main-bg-color: #282c37;
--link-bg-color: #282c37; --link-bg-color: #282c37;
--main-fg-color: #dddddd; --main-fg-color: #dddddd;
@ -50,7 +49,6 @@ body, html {
max-width: 100%; max-width: 100%;
min-width: 600px; min-width: 600px;
margin: 5% auto; margin: 5% auto;
filter: grayscale(var(--grayscale));
} }
a, u { a, u {
@ -91,7 +89,6 @@ a:link {
} }
.followAvatar img { .followAvatar img {
filter: grayscale(var(--grayscale));
border-radius: 10%; border-radius: 10%;
width: 20%; width: 20%;
min-width: 200px; min-width: 200px;
@ -171,7 +168,6 @@ input[type=text] {
} }
.options img { .options img {
filter: grayscale(var(--grayscale));
width: 15%; width: 15%;
} }

View File

@ -1,7 +1,6 @@
@charset "UTF-8"; @charset "UTF-8";
:root { :root {
--grayscale: 0%;
--main-bg-color: #282c37; --main-bg-color: #282c37;
--link-bg-color: #282c37; --link-bg-color: #282c37;
--main-fg-color: #dddddd; --main-fg-color: #dddddd;
@ -41,7 +40,6 @@ body, html {
min-width: 600px; min-width: 600px;
margin: 0 auto; margin: 0 auto;
font-size: var(--font-size); font-size: var(--font-size);
filter: grayscale(var(--grayscale));
} }
a, u { a, u {
@ -98,13 +96,11 @@ button:hover {
} }
.imgcontainer { .imgcontainer {
filter: grayscale(var(--grayscale));
text-align: center; text-align: center;
margin: 24px 0 12px 0; margin: 24px 0 12px 0;
} }
img.avatar { img.avatar {
filter: grayscale(var(--grayscale));
width: 40%; width: 40%;
border-radius: 50%; border-radius: 50%;
} }

View File

@ -1,7 +1,6 @@
@charset "UTF-8"; @charset "UTF-8";
:root { :root {
--grayscale: 0%;
--main-bg-color: #282c37; --main-bg-color: #282c37;
--link-bg-color: #282c37; --link-bg-color: #282c37;
--dropdown-fg-color: #dddddd; --dropdown-fg-color: #dddddd;
@ -71,7 +70,6 @@ body, html {
min-width: 950px; min-width: 950px;
margin: 0 auto; margin: 0 auto;
font-size: var(--font-size); font-size: var(--font-size);
filter: grayscale(var(--grayscale));
} }
a, u { a, u {
@ -109,7 +107,6 @@ a:link {
} }
.rssfeed img { .rssfeed img {
filter: grayscale(var(--grayscale));
width: 5%; width: 5%;
float: right; float: right;
} }
@ -147,7 +144,6 @@ a:link {
} }
.hero-image img { .hero-image img {
filter: grayscale(var(--grayscale));
width: 50%; width: 50%;
} }
@ -179,7 +175,6 @@ a:link {
} }
.hero-text img.emoji { .hero-text img.emoji {
filter: grayscale(var(--grayscale));
width: 50px; width: 50px;
padding: 0 0; padding: 0 0;
margin: 0 0; margin: 0 0;
@ -311,7 +306,6 @@ a:link {
} }
.container img.emoji { .container img.emoji {
filter: grayscale(var(--grayscale));
float: none; float: none;
width: 50px; width: 50px;
margin-left: 0px; margin-left: 0px;
@ -322,7 +316,6 @@ a:link {
} }
.hero-text img.emojiprofile { .hero-text img.emojiprofile {
filter: grayscale(var(--grayscale));
float: none; float: none;
width: 50px; width: 50px;
margin-left: 0px; margin-left: 0px;
@ -356,7 +349,6 @@ a:link {
} }
.container img.announceOrReply { .container img.announceOrReply {
filter: grayscale(var(--grayscale));
float: none; float: none;
width: 30px; width: 30px;
margin: 0 0; margin: 0 0;
@ -366,7 +358,6 @@ a:link {
} }
.container img.DMicon { .container img.DMicon {
filter: grayscale(var(--grayscale));
float: none; float: none;
width: 40px; width: 40px;
margin: 0 0; margin: 0 0;
@ -389,14 +380,12 @@ a:link {
} }
.container img.attachment { .container img.attachment {
filter: grayscale(var(--grayscale));
max-width: 120%; max-width: 120%;
margin-left: 5%; margin-left: 5%;
width: 120%; width: 120%;
padding-bottom: 3%; padding-bottom: 3%;
} }
.container img.right { .container img.right {
filter: grayscale(var(--grayscale));
float: var(--icons-side); float: var(--icons-side);
margin-left: 0px; margin-left: 0px;
margin-right:0; margin-right:0;
@ -404,7 +393,6 @@ a:link {
margin: 0 0; margin: 0 0;
} }
.containericons img.right { .containericons img.right {
filter: grayscale(var(--grayscale));
float: var(--icons-side); float: var(--icons-side);
margin-left: 20px; margin-left: 20px;
margin-right: 0; margin-right: 0;
@ -538,7 +526,6 @@ input[type=submit]:hover {
} }
.dropdown img { .dropdown img {
filter: grayscale(var(--grayscale));
opacity: 1.0; opacity: 1.0;
width: 32px; width: 32px;
height: 32px; height: 32px;
@ -563,7 +550,6 @@ input[type=submit]:hover {
} }
.search-result img { .search-result img {
filter: grayscale(var(--grayscale));
width: 7%; width: 7%;
padding: 0px 30px; padding: 0px 30px;
} }
@ -588,7 +574,6 @@ input[type=submit]:hover {
} }
.dropdown-content img { .dropdown-content img {
filter: grayscale(var(--grayscale));
width: 32px; width: 32px;
height: 32px; height: 32px;
padding: 0px 0px; padding: 0px 0px;
@ -638,7 +623,6 @@ input[type=submit]:hover {
} }
.dropbtn img { .dropbtn img {
filter: grayscale(var(--grayscale));
opacity: 1.0; opacity: 1.0;
width: 3%; width: 3%;
height: 3%; height: 3%;
@ -652,7 +636,6 @@ div.gallery:hover {
} }
div.gallery img { div.gallery img {
filter: grayscale(var(--grayscale));
width: 100%; width: 100%;
height: auto; height: auto;
} }
@ -896,7 +879,6 @@ aside .toggle-inside li {
text-align: center; text-align: center;
} }
.container img { .container img {
filter: grayscale(var(--grayscale));
float: left; float: left;
max-width: 400px; max-width: 400px;
width: 5%; width: 5%;
@ -905,12 +887,10 @@ aside .toggle-inside li {
border-radius: var(--image-corners); border-radius: var(--image-corners);
} }
.container img.emojisearch { .container img.emojisearch {
filter: grayscale(var(--grayscale));
width: 15%; width: 15%;
float: right; float: right;
} }
.container img.emojicalendar { .container img.emojicalendar {
filter: grayscale(var(--grayscale));
float: left; float: left;
max-width: 400px; max-width: 400px;
width: 8%; width: 8%;
@ -918,7 +898,6 @@ aside .toggle-inside li {
transform: translateY(-25%); transform: translateY(-25%);
} }
.container img.timelineicon { .container img.timelineicon {
filter: grayscale(var(--grayscale));
float: var(--icons-side); float: var(--icons-side);
margin-left: 0px; margin-left: 0px;
margin-right:0; margin-right:0;
@ -927,7 +906,6 @@ aside .toggle-inside li {
width: 50px; width: 50px;
} }
.container img.emojiheader { .container img.emojiheader {
filter: grayscale(var(--grayscale));
float: none; float: none;
width: 25px; width: 25px;
margin-left: 0px; margin-left: 0px;
@ -937,7 +915,6 @@ aside .toggle-inside li {
vertical-align: middle; vertical-align: middle;
} }
.containericons img { .containericons img {
filter: grayscale(var(--grayscale));
float: var(--icons-side); float: var(--icons-side);
max-width: 200px; max-width: 200px;
width: 3%; width: 3%;
@ -945,7 +922,6 @@ aside .toggle-inside li {
border-radius: 0%; border-radius: 0%;
} }
div.mediaicons img { div.mediaicons img {
filter: grayscale(var(--grayscale));
float: right; float: right;
max-width: 200px; max-width: 200px;
width: 6%; width: 6%;
@ -953,7 +929,6 @@ aside .toggle-inside li {
border-radius: 0%; border-radius: 0%;
} }
div.mediaavatar img { div.mediaavatar img {
filter: grayscale(var(--grayscale));
float: left; float: left;
max-width: 200px; max-width: 200px;
width: 5%; width: 5%;
@ -961,7 +936,6 @@ aside .toggle-inside li {
border-radius: 0%; border-radius: 0%;
} }
.timeline-avatar img { .timeline-avatar img {
filter: grayscale(var(--grayscale));
opacity: 1.0; opacity: 1.0;
width: 8%; width: 8%;
height: 8%; height: 8%;
@ -1217,24 +1191,20 @@ aside .toggle-inside li {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
} }
.hero-text img.qrcode { .hero-text img.qrcode {
filter: grayscale(var(--grayscale));
border-radius: 1%; border-radius: 1%;
width: 5%; width: 5%;
min-width: 20px; min-width: 20px;
} }
.hero-text img.title { .hero-text img.title {
filter: grayscale(var(--grayscale));
border-radius: 1%; border-radius: 1%;
width: 15%; width: 15%;
} }
#msgscope label img { #msgscope label img {
filter: grayscale(var(--grayscale));
width: 46px; width: 46px;
height: 46px; height: 46px;
padding: 0px 0px; padding: 0px 0px;
} }
.toggle-msgScope img { .toggle-msgScope img {
filter: grayscale(var(--grayscale));
width: 32px; width: 32px;
height: 32px; height: 32px;
padding: 0px 0px; padding: 0px 0px;
@ -1310,7 +1280,6 @@ aside .toggle-inside li {
text-align: center; text-align: center;
} }
.container img { .container img {
filter: grayscale(var(--grayscale));
float: left; float: left;
max-width: 400px; max-width: 400px;
width: 15%; width: 15%;
@ -1319,12 +1288,10 @@ aside .toggle-inside li {
border-radius: var(--image-corners); border-radius: var(--image-corners);
} }
.container img.emojisearch { .container img.emojisearch {
filter: grayscale(var(--grayscale));
width: 25%; width: 25%;
float: right; float: right;
} }
.container img.emojicalendar { .container img.emojicalendar {
filter: grayscale(var(--grayscale));
float: left; float: left;
max-width: 400px; max-width: 400px;
width: 12%; width: 12%;
@ -1332,7 +1299,6 @@ aside .toggle-inside li {
transform: translateY(-25%); transform: translateY(-25%);
} }
.container img.timelineicon { .container img.timelineicon {
filter: grayscale(var(--grayscale));
float: var(--icons-side); float: var(--icons-side);
margin-left: 0px; margin-left: 0px;
margin-right:0; margin-right:0;
@ -1341,7 +1307,6 @@ aside .toggle-inside li {
width: 100px; width: 100px;
} }
.container img.emojiheader { .container img.emojiheader {
filter: grayscale(var(--grayscale));
float: none; float: none;
width: 45px; width: 45px;
margin-left: 0px; margin-left: 0px;
@ -1351,7 +1316,6 @@ aside .toggle-inside li {
vertical-align: middle; vertical-align: middle;
} }
div.mediaavatar img { div.mediaavatar img {
filter: grayscale(var(--grayscale));
float: left; float: left;
max-width: 200px; max-width: 200px;
width: 8%; width: 8%;
@ -1359,7 +1323,6 @@ aside .toggle-inside li {
border-radius: 0%; border-radius: 0%;
} }
div.mediaicons img { div.mediaicons img {
filter: grayscale(var(--grayscale));
float: right; float: right;
max-width: 200px; max-width: 200px;
width: 10%; width: 10%;
@ -1367,7 +1330,6 @@ aside .toggle-inside li {
border-radius: 0%; border-radius: 0%;
} }
.containericons img { .containericons img {
filter: grayscale(var(--grayscale));
float: var(--icons-side); float: var(--icons-side);
max-width: 200px; max-width: 200px;
width: 7%; width: 7%;
@ -1375,7 +1337,6 @@ aside .toggle-inside li {
border-radius: 0%; border-radius: 0%;
} }
.timeline-avatar img { .timeline-avatar img {
filter: grayscale(var(--grayscale));
opacity: 1.0; opacity: 1.0;
width: 15%; width: 15%;
height: 15%; height: 15%;
@ -1631,24 +1592,20 @@ aside .toggle-inside li {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
} }
.hero-text img.qrcode { .hero-text img.qrcode {
filter: grayscale(var(--grayscale));
border-radius: 1%; border-radius: 1%;
width: 15%; width: 15%;
min-width: 20px; min-width: 20px;
} }
.hero-text img.title { .hero-text img.title {
filter: grayscale(var(--grayscale));
border-radius: 1%; border-radius: 1%;
width: 25%; width: 25%;
} }
#msgscope label img { #msgscope label img {
filter: grayscale(var(--grayscale));
width: 64px; width: 64px;
height: 64px; height: 64px;
padding: 0px 0px; padding: 0px 0px;
} }
.toggle-msgScope img { .toggle-msgScope img {
filter: grayscale(var(--grayscale));
width: 64px; width: 64px;
height: 64px; height: 64px;
margin: -15px 0px; margin: -15px 0px;

View File

@ -106,9 +106,8 @@ def setThemeFromDict(baseDir: str, name: str, themeParams: {}) -> None:
cssfile.write(css) cssfile.write(css)
def setSingleThemeParam(baseDir: str, def enableGrayscale(baseDir: str) -> None:
paramName: str, paramValue: str) -> None: """Enables grayscale for the current theme
"""Sets a single theme parameter across all css files
""" """
themeFiles = ('epicyon.css', 'login.css', 'follow.css', themeFiles = ('epicyon.css', 'login.css', 'follow.css',
'suspended.css', 'calendar.css', 'blog.css') 'suspended.css', 'calendar.css', 'blog.css')
@ -118,10 +117,39 @@ def setSingleThemeParam(baseDir: str,
continue continue
with open(templateFilename, 'r') as cssfile: with open(templateFilename, 'r') as cssfile:
css = cssfile.read() css = cssfile.read()
css = setCSSparam(css, paramName, paramValue) if 'grayscale' not in css:
filename = baseDir + '/' + filename css = \
with open(filename, 'w') as cssfile: css.replace('body, html {',
cssfile.write(css) 'body, html {\n filter: grayscale(100%);')
filename = baseDir + '/' + filename
with open(filename, 'w') as cssfile:
cssfile.write(css)
grayscaleFilename = baseDir + '/accounts/.grayscale'
if not os.path.isfile(grayscaleFilename):
with open(grayscaleFilename, 'w') as grayfile:
grayfile.write(' ')
def disableGrayscale(baseDir: str) -> None:
"""Disables grayscale for the current theme
"""
themeFiles = ('epicyon.css', 'login.css', 'follow.css',
'suspended.css', 'calendar.css', 'blog.css')
for filename in themeFiles:
templateFilename = baseDir + '/' + filename
if not os.path.isfile(templateFilename):
continue
with open(templateFilename, 'r') as cssfile:
css = cssfile.read()
if 'grayscale' in css:
css = \
css.replace('\n filter: grayscale(100%);', '')
filename = baseDir + '/' + filename
with open(filename, 'w') as cssfile:
cssfile.write(css)
grayscaleFilename = baseDir + '/accounts/.grayscale'
if os.path.isfile(grayscaleFilename):
os.remove(grayscaleFilename)
def setCustomFont(baseDir: str): def setCustomFont(baseDir: str):
@ -163,21 +191,6 @@ def setCustomFont(baseDir: str):
cssfile.write(css) cssfile.write(css)
def enableGrayscale(baseDir: str):
setSingleThemeParam(baseDir, 'grayscale', '100%')
grayscaleFilename = baseDir + '/accounts/.grayscale'
if not os.path.isfile(grayscaleFilename):
with open(grayscaleFilename, 'w') as grayfile:
grayfile.write(' ')
def disableGrayscale(baseDir: str):
setSingleThemeParam(baseDir, 'grayscale', '0%')
grayscaleFilename = baseDir + '/accounts/.grayscale'
if os.path.isfile(grayscaleFilename):
os.remove(grayscaleFilename)
def setThemeDefault(baseDir: str): def setThemeDefault(baseDir: str):
removeTheme(baseDir) removeTheme(baseDir)
setThemeInConfig(baseDir, 'default') setThemeInConfig(baseDir, 'default')