mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 22:05:09 +01:00
Initial theme toggler
This commit is contained in:
@@ -2,6 +2,31 @@
|
|||||||
* digimarks styling
|
* digimarks styling
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
html[data-theme='light'] {
|
||||||
|
--background-color: #fff;
|
||||||
|
--text-color: #121416d8;
|
||||||
|
--link-color: #543fd7;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-theme='dark'] {
|
||||||
|
--background-color: #212a2e;
|
||||||
|
--text-color: #F7F8F8;
|
||||||
|
--link-color: #828fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: var(--background-color);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: var(--link-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
filter: brightness(80%);
|
||||||
|
}
|
||||||
|
|
||||||
/* Active element, e.g. a button */
|
/* Active element, e.g. a button */
|
||||||
.active {
|
.active {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ document.addEventListener('alpine:init', () => {
|
|||||||
bookmarks: [],
|
bookmarks: [],
|
||||||
tags: [],
|
tags: [],
|
||||||
|
|
||||||
|
theme: Alpine.$persist('light').as('theme'),
|
||||||
|
|
||||||
show_bookmarks: Alpine.$persist(true).as('show_bookmarks'),
|
show_bookmarks: Alpine.$persist(true).as('show_bookmarks'),
|
||||||
show_bookmarks_list: Alpine.$persist(true).as('show_bookmarks_list'),
|
show_bookmarks_list: Alpine.$persist(true).as('show_bookmarks_list'),
|
||||||
show_bookmarks_cards: Alpine.$persist(false).as('show_bookmarks_cards'),
|
show_bookmarks_cards: Alpine.$persist(false).as('show_bookmarks_cards'),
|
||||||
@@ -39,6 +41,16 @@ document.addEventListener('alpine:init', () => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async toggleTheme() {
|
||||||
|
/* TBD: loop through themes instead of dark/light modes */
|
||||||
|
if (this.theme === 'dark') {
|
||||||
|
this.theme = 'light';
|
||||||
|
} else {
|
||||||
|
this.theme = 'dark';
|
||||||
|
}
|
||||||
|
document.documentElement.setAttribute('data-theme', this.theme);
|
||||||
|
},
|
||||||
|
|
||||||
async loadCache() {
|
async loadCache() {
|
||||||
if (this.userKey in this.cache) {
|
if (this.userKey in this.cache) {
|
||||||
console.log('Loading bookmarks from cache for user "' + this.userKey + '"');
|
console.log('Loading bookmarks from cache for user "' + this.userKey + '"');
|
||||||
@@ -75,8 +87,7 @@ document.addEventListener('alpine:init', () => {
|
|||||||
this.cache[this.userKey]['bookmarks'] = result;
|
this.cache[this.userKey]['bookmarks'] = result;
|
||||||
|
|
||||||
let tags_response = await fetch('/api/v1/' + this.userKey + '/tags/');
|
let tags_response = await fetch('/api/v1/' + this.userKey + '/tags/');
|
||||||
let tags_result = await tags_response.json();
|
this.cache[this.userKey]['tags'] = await tags_response.json();
|
||||||
this.cache[this.userKey]['tags'] = tags_result;
|
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<button x-data>add bookmark</button>
|
<button x-data>add bookmark</button>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<button @click="$store.digimarks.toggleTheme()">theme</button>
|
||||||
|
</li>
|
||||||
<li><input x-model="$store.digimarks.search" placeholder="Search..."></li>
|
<li><input x-model="$store.digimarks.search" placeholder="Search..."></li>
|
||||||
<li x-show="$store.digimarks.loading">↻</li>
|
<li x-show="$store.digimarks.loading">↻</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -56,7 +59,7 @@
|
|||||||
<template x-for="bookmark in $store.digimarks.filteredBookmarks" :key="bookmark.id">
|
<template x-for="bookmark in $store.digimarks.filteredBookmarks" :key="bookmark.id">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div x-show="bookmark.starred">*</div>
|
<div x-show="bookmark.starred">*</div>
|
||||||
{# <img x-show="bookmark.favicon" x-bind:src="'/static/favicons/' + bookmark.favicon">#}
|
{# <img x-show="bookmark.favicon" x-bind:src="'/static/favicons/' + bookmark.favicon">#}
|
||||||
<a x-text="bookmark.title" x-bind:href="bookmark.url" target="_blank"></a>
|
<a x-text="bookmark.title" x-bind:href="bookmark.url" target="_blank"></a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user