1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-07 00:15:10 +01:00

Show bookmarks in a grid

This commit is contained in:
2025-05-06 23:15:09 +02:00
parent d28228fc03
commit 0f7e280bb3
4 changed files with 51 additions and 10 deletions

View File

@@ -15,3 +15,18 @@ button:hover {
button:focus { button:focus {
border-color: #d57803; border-color: #d57803;
} }
.cards {
grid-column-gap: 1rem;
grid-row-gap: 1rem;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}
.card {
background-color: #fff;
border: 1px solid #d5d9d9;
border-radius: 8px;
box-shadow: rgba(213, 217, 217, .5) 0 2px 5px 0;
/*margin: 1em;*/
padding: 1em;
}

View File

@@ -3,6 +3,8 @@
* v0.0.1 * v0.0.1
*/ */
/* Main structure */
body { body {
height: 125vh; height: 125vh;
font-family: sans-serif; font-family: sans-serif;
@@ -45,6 +47,7 @@ header li a {
background-color: #cccccc; background-color: #cccccc;
} }
/* Buttons */
button { button {
background-color: #fff; background-color: #fff;
border: 1px solid #d5d9d9; border: 1px solid #d5d9d9;
@@ -76,3 +79,12 @@ button:focus {
box-shadow: rgba(213, 217, 217, .5) 0 2px 5px 0; box-shadow: rgba(213, 217, 217, .5) 0 2px 5px 0;
outline: 0; outline: 0;
} }
/* Cards */
.cards {
display: grid;
}
.card {
display: inline-grid;
}

View File

@@ -10,6 +10,8 @@ document.addEventListener('alpine:init', () => {
tags: [], tags: [],
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_cards: Alpine.$persist(false).as('show_bookmarks_cards'),
show_tags: Alpine.$persist(false).as('show_tags'), show_tags: Alpine.$persist(false).as('show_tags'),
/* Loading indicator */ /* Loading indicator */
@@ -36,6 +38,7 @@ document.addEventListener('alpine:init', () => {
// this.countDownTimer(); // this.countDownTimer();
}, 1000); }, 1000);
}, },
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 + '"');
@@ -77,6 +80,7 @@ document.addEventListener('alpine:init', () => {
this.loading = false; this.loading = false;
}, },
get filteredBookmarks() { get filteredBookmarks() {
// return this.cache[this.userKey]['bookmarks'].filter( // return this.cache[this.userKey]['bookmarks'].filter(
// i => i.title.includes(this.search) // i => i.title.includes(this.search)
@@ -91,6 +95,7 @@ document.addEventListener('alpine:init', () => {
i => i.match(new RegExp(this.search, "i")) i => i.match(new RegExp(this.search, "i"))
) )
}, },
async sortAlphabetically(order = 'asc') { async sortAlphabetically(order = 'asc') {
this.sort_created_asc = false; this.sort_created_asc = false;
this.sort_created_desc = false; this.sort_created_desc = false;
@@ -117,19 +122,15 @@ document.addEventListener('alpine:init', () => {
this.bookmarks.sort((a, b) => a.created_date.localeCompare(b.created_date)); this.bookmarks.sort((a, b) => a.created_date.localeCompare(b.created_date));
} }
}, },
async toggleTagPage() { async toggleTagPage() {
console.log('Toggle tag page'); console.log('Toggle tag page');
this.show_bookmarks = !this.show_bookmarks; this.show_bookmarks = !this.show_bookmarks;
this.show_tags = !this.show_bookmarks; this.show_tags = !this.show_bookmarks;
/* },
if (this.show_bookmarks) { async toggleListOrGrid() {
this.show_tags = true; this.show_bookmarks_list = !this.show_bookmarks_list;
this.show_bookmarks = false; this.show_bookmarks_cards = !this.show_bookmarks_list;
} else {
this.show_bookmarks = true;
this.show_tags = false;
}
*/
} }
}) })
}); });

View File

@@ -41,13 +41,26 @@
<button @click="$store.digimarks.sortCreated('desc')" <button @click="$store.digimarks.sortCreated('desc')"
:class="$store.digimarks.sort_created_desc && 'active'">date &uarr; :class="$store.digimarks.sort_created_desc && 'active'">date &uarr;
</button> </button>
<button @click="$store.digimarks.toggleListOrGrid()"
:class="$store.digimarks.show_bookmarks_cards && 'active'">list or grid
</button>
</p> </p>
<ul x-cloak> <ul x-cloak x-show="$store.digimarks.show_bookmarks_list">
<template x-for="bookmark in $store.digimarks.filteredBookmarks" :key="bookmark.id"> <template x-for="bookmark in $store.digimarks.filteredBookmarks" :key="bookmark.id">
<li><a x-text="bookmark.title" x-bind:href="bookmark.url" target="_blank"></a></li> <li><a x-text="bookmark.title" x-bind:href="bookmark.url" target="_blank"></a></li>
</template> </template>
</ul> </ul>
<section x-cloak x-show="$store.digimarks.show_bookmarks_cards" class="cards">
<template x-for="bookmark in $store.digimarks.filteredBookmarks" :key="bookmark.id">
<div class="card">
<div x-show="bookmark.starred">*</div>
{# <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>
</div>
</template>
</section>
</section> </section>
<section x-cloak x-show="$store.digimarks.show_tags" x-transition.opacity> <section x-cloak x-show="$store.digimarks.show_tags" x-transition.opacity>