Added SVG inversion.
This commit is contained in:
parent
f3f928018f
commit
169bcfde94
5 changed files with 17 additions and 18 deletions
|
@ -4,17 +4,17 @@
|
||||||
default-theme="{{ site.Params.darkMode.default }}"></div>
|
default-theme="{{ site.Params.darkMode.default }}"></div>
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="themeSelector" role="button"
|
<a class="nav-link dropdown-toggle" href="#" id="themeSelector" role="button"
|
||||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<img src="{{ "/images/moon-svgrepo-com.svg" }}" width=20>
|
<img src="{{ "/icons/moon-svgrepo-com.svg" }}" width=20>
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="themeSelector">
|
<div class="dropdown-menu" aria-labelledby="themeSelector">
|
||||||
<a class="dropdown-item nav-link" href="#" onclick="enableLightTheme()">
|
<a class="dropdown-item nav-link" href="#" onclick="enableLightTheme()">
|
||||||
<img src="{{ "/images/sun-svgrepo-com.svg" }}" width=20>
|
<img src="{{ "/icons/sun-svgrepo-com.svg" }}" width=20>
|
||||||
</a>
|
</a>
|
||||||
<a class="dropdown-item nav-link" href="#" onclick="enableDarkTheme()">
|
<a class="dropdown-item nav-link" href="#" onclick="enableDarkTheme()">
|
||||||
<img src="{{ "/images/moon-svgrepo-com.svg" }}" width=20>
|
<img src="{{ "/icons/moon-svgrepo-com.svg" }}" width=20>
|
||||||
</a>
|
</a>
|
||||||
<a class="dropdown-item nav-link" href="#" onclick="useSystemTheme()">
|
<a class="dropdown-item nav-link" href="#" onclick="useSystemTheme()">
|
||||||
<img src="{{ "/images/computer-svgrepo-com.svg" }}" width=20>
|
<img src="{{ "/icons/computer-svgrepo-com.svg" }}" width=20>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
|
@ -1,28 +1,27 @@
|
||||||
const DARK = "dark";
|
const DARK = "dark";
|
||||||
const LIGHT = "light";
|
const LIGHT = "light";
|
||||||
const SYSTEM = "system";
|
const SYSTEM = "system";
|
||||||
|
const COLOR_THEME = "color-theme";
|
||||||
|
const DARK_OPTIONS = {
|
||||||
|
brightness: 100,
|
||||||
|
contrast: 100,
|
||||||
|
sepia: 0
|
||||||
|
};
|
||||||
|
const SVG_INVERT = {invert: ['img[src$=".svg"]']};
|
||||||
|
|
||||||
function enableDarkTheme() {
|
function enableDarkTheme() {
|
||||||
localStorage.setItem('color-theme', DARK);
|
localStorage.setItem(COLOR_THEME, DARK);
|
||||||
DarkReader.enable({
|
DarkReader.enable(DARK_OPTIONS, SVG_INVERT);
|
||||||
brightness: 100,
|
|
||||||
contrast: 100,
|
|
||||||
sepia: 0
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableLightTheme() {
|
function enableLightTheme() {
|
||||||
localStorage.setItem('color-theme', LIGHT);
|
localStorage.setItem(COLOR_THEME, LIGHT);
|
||||||
DarkReader.disable();
|
DarkReader.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
function useSystemTheme() {
|
function useSystemTheme() {
|
||||||
localStorage.setItem('color-theme', SYSTEM);
|
localStorage.setItem(COLOR_THEME, SYSTEM);
|
||||||
DarkReader.auto({
|
DarkReader.auto(DARK_OPTIONS, SVG_INVERT);
|
||||||
brightness: 100,
|
|
||||||
contrast: 100,
|
|
||||||
sepia: 0
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeColorTheme() {
|
function initializeColorTheme() {
|
||||||
|
@ -34,7 +33,7 @@ function initializeColorTheme() {
|
||||||
// If the user has already selected a preferred theme then use that instead
|
// If the user has already selected a preferred theme then use that instead
|
||||||
// of the default theme. Also, the default theme gets loaded to localStorage
|
// of the default theme. Also, the default theme gets loaded to localStorage
|
||||||
// on the first visit.
|
// on the first visit.
|
||||||
let colorTheme = localStorage.getItem('color-theme');
|
let colorTheme = localStorage.getItem(COLOR_THEME);
|
||||||
if (colorTheme == null || colorTheme.length == 0) {
|
if (colorTheme == null || colorTheme.length == 0) {
|
||||||
colorTheme = defaultColorScheme;
|
colorTheme = defaultColorScheme;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue