use css vars for graph styling as well; base webview.scss off core.scss

This commit is contained in:
Damien Elmes 2020-08-27 18:34:34 +10:00
parent 21616f67bf
commit 0564d4cf86
6 changed files with 90 additions and 92 deletions

View file

@ -1,13 +1,18 @@
/* Copyright: Ankitects Pty Ltd and contributors /* Copyright: Ankitects Pty Ltd and contributors
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */ * License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
@use 'vars'; @use 'core';
@use 'buttons'; @use 'buttons';
// core.scss sets border-box, but we need to
// keep the old behaviour for now to avoid breaking
// add-ons/card templates
* {
box-sizing: content-box;
}
body { body {
margin: 2em; margin: 2em;
color: var(--text-fg);
background: var(--window-bg);
overscroll-behavior: none; overscroll-behavior: none;
} }
@ -15,10 +20,6 @@ h1 {
margin-bottom: 0.2em; margin-bottom: 0.2em;
} }
a {
color: var(--link);
}
body.nightMode { body.nightMode {
&::-webkit-scrollbar { &::-webkit-scrollbar {
background: var(--window-bg); background: var(--window-bg);

View file

@ -10,7 +10,7 @@
<script> <script>
const nightMode = window.location.hash == "#night"; const nightMode = window.location.hash == "#night";
if (nightMode) { if (nightMode) {
document.body.className = "night-mode"; document.documentElement.className = "night-mode";
} }
anki.graphs(document.getElementById("main"), nightMode); anki.graphs(document.getElementById("main"), nightMode);
</script> </script>

View file

@ -1,3 +1,6 @@
/* Copyright: Ankitects Pty Ltd and contributors
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
:root { :root {
--text-fg: black; --text-fg: black;
--window-bg: #ececec; --window-bg: #ececec;
@ -7,7 +10,7 @@
--link: #00a; --link: #00a;
--review-count: #0a0; --review-count: #0a0;
--new-count: #00a; --new-count: #00a;
--learn-count: #C35617; --learn-count: #c35617;
--zero-count: #ddd; --zero-count: #ddd;
--slightly-grey-text: #333; --slightly-grey-text: #333;
--highlight-bg: #77ccff; --highlight-bg: #77ccff;
@ -15,10 +18,11 @@
--disabled: #777; --disabled: #777;
--flag1-bg: #ffaaaa; --flag1-bg: #ffaaaa;
--flag2-bg: #ffb347; --flag2-bg: #ffb347;
--flag3-bg: #82E0AA; --flag3-bg: #82e0aa;
--flag4-bg: #85C1E9; --flag4-bg: #85c1e9;
--suspended-bg: #FFFFB2; --suspended-bg: #ffffb2;
--marked-bg: #cce; --marked-bg: #cce;
--tooltip-bg: #fcfcfc;
} }
:root[class*="night-mode"] { :root[class*="night-mode"] {
@ -26,11 +30,11 @@
--window-bg: #2f2f31; --window-bg: #2f2f31;
--frame-bg: #3a3a3a; --frame-bg: #3a3a3a;
--border: #777; --border: #777;
--faint-border: #29292B; --faint-border: #29292b;
--link: #77ccff; --link: #77ccff;
--review-count: #5CcC00; --review-count: #5ccc00;
--new-count: #77ccff; --new-count: #77ccff;
--learn-count: #FF935B; --learn-count: #ff935b;
--zero-count: #444; --zero-count: #444;
--slightly-grey-text: #ccc; --slightly-grey-text: #ccc;
--highlight-bg: #77ccff; --highlight-bg: #77ccff;
@ -42,4 +46,5 @@
--flag4-bg: #3581a9; --flag4-bg: #3581a9;
--suspended-bg: #aaaa33; --suspended-bg: #aaaa33;
--marked-bg: #77c; --marked-bg: #77c;
--tooltip-bg: #272727;
} }

18
ts/src/scss/core.scss Normal file
View file

@ -0,0 +1,18 @@
/* Copyright: Ankitects Pty Ltd and contributors
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
@use 'vars';
* {
box-sizing: border-box;
}
body {
font-family: Helvetica, Arial;
color: var(--text-fg);
background: var(--window-bg);
}
a {
color: var(--link);
}

View file

@ -135,7 +135,7 @@ export function renderCalendar(
} }
const height = bounds.height / 10; const height = bounds.height / 10;
let emptyColour = "#eee"; let emptyColour = "#ddd";
if (nightMode) { if (nightMode) {
emptyColour = "#333"; emptyColour = "#333";
} }

View file

@ -1,31 +1,28 @@
$day-fg: black; /* Copyright: Ankitects Pty Ltd and contributors
$day-bg: #f7f7f7; * License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
$day-tooltip-bg: #fcfcfc;
$night-fg: white;
$night-bg: #222;
$night-tooltip-bg: #272727;
* { @use '../scss/core';
box-sizing: border-box;
:root {
--area-fill: #00000008;
--area-stroke: #00000015;
} }
body { :root[class*="night-mode"] {
font-family: Arial; --area-fill: #ffffff15;
background: $day-bg; --area-stroke: #00000030;
color: $day-fg;
} }
.graph-tooltip { .graph-tooltip {
position: absolute; position: absolute;
background-color: white;
padding: 15px; padding: 15px;
border-radius: 5px; border-radius: 5px;
font-size: 15px; font-size: 15px;
opacity: 0; opacity: 0;
pointer-events: none; pointer-events: none;
transition: opacity 0.3s; transition: opacity 0.3s;
color: $day-fg; color: var(--text-fg);
background: $day-tooltip-bg; background: var(--tooltip-bg);
} }
.graph-tooltip table { .graph-tooltip table {
@ -84,8 +81,8 @@ body {
z-index: 1; z-index: 1;
top: 0; top: 0;
width: 100%; width: 100%;
color: $day-fg; color: var(--text-fg);
background: $day-bg; background: var(--window-bg);
padding: 0.5em; padding: 0.5em;
} }
@ -116,8 +113,8 @@ body {
.graph .area { .graph .area {
pointer-events: none; pointer-events: none;
fill: #00000008; fill: var(--area-fill);
stroke: #00000015; stroke: var(--area-stroke);
} }
.hoverzone rect { .hoverzone rect {
@ -163,36 +160,13 @@ body {
margin-bottom: 1em; margin-bottom: 1em;
} }
body.night-mode {
background: $night-bg;
color: $night-fg;
}
.no-data { .no-data {
text { text {
text-anchor: middle; text-anchor: middle;
fill: grey; fill: grey;
} }
rect { rect {
fill: $day-bg; fill: var(--window-bg);
}
}
.night-mode {
.graph-tooltip {
background: $night-tooltip-bg;
color: $night-fg;
}
.range-box {
background: $night-bg;
color: $night-fg;
}
.graph .area {
fill: #ffffff15;
stroke: #00000030;
}
.no-data rect {
fill: $night-bg;
} }
} }