mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 22:05:09 +01:00
Navigation stub, sortable bookmarks
This commit is contained in:
@@ -4,3 +4,45 @@
|
|||||||
|
|
||||||
/** Navigation **/
|
/** Navigation **/
|
||||||
|
|
||||||
|
nav {
|
||||||
|
/*background: #666;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul {
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
height: 125vh;
|
||||||
|
font-family: sans-serif;
|
||||||
|
margin-top: 3rem;
|
||||||
|
padding: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
background-color: white;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 3rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
box-shadow: 0 0 6px 0 #666666;
|
||||||
|
}
|
||||||
|
|
||||||
|
header * {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
header li {
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
header li a {
|
||||||
|
color: black;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ document.addEventListener('alpine:init', () => {
|
|||||||
this.cache[this.userKey]['bookmarks'] = result;
|
this.cache[this.userKey]['bookmarks'] = result;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
get filteredItems() {
|
get filteredItems() {
|
||||||
// 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)
|
||||||
@@ -58,6 +57,18 @@ document.addEventListener('alpine:init', () => {
|
|||||||
return this.bookmarks.filter(
|
return this.bookmarks.filter(
|
||||||
i => i.title.match(new RegExp(this.search, "i"))
|
i => i.title.match(new RegExp(this.search, "i"))
|
||||||
)
|
)
|
||||||
|
},
|
||||||
|
async sortAlphabetically() {
|
||||||
|
this.bookmarks.sort((a, b) => a.title.localeCompare(b.title));
|
||||||
|
},
|
||||||
|
async sortCreated(order = 'asc') {
|
||||||
|
if (order === 'desc') {
|
||||||
|
this.bookmarks.sort((a, b) => b.created_date.localeCompare(a.created_date));
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
|
||||||
|
this.bookmarks.sort((a, b) => a.created_date.localeCompare(b.created_date));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,24 +7,33 @@
|
|||||||
x-init="$store.digimarks.userKey = '{{ user_key }}'; $store.digimarks.loadCache(); $store.digimarks.getBookmarks()"
|
x-init="$store.digimarks.userKey = '{{ user_key }}'; $store.digimarks.loadCache(); $store.digimarks.getBookmarks()"
|
||||||
x-data="">
|
x-data="">
|
||||||
|
|
||||||
|
<header>
|
||||||
|
|
||||||
<nav class="menu">
|
<nav class="menu">
|
||||||
<ul>
|
<ul>
|
||||||
<li>digimarks</li>
|
<li>digimarks</li>
|
||||||
<li>tags</li>
|
<li>tags</li>
|
||||||
<li>add bookmark</li>
|
<li>add bookmark</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<input x-model="$store.digimarks.search" placeholder="Search...">
|
||||||
</nav>
|
</nav>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
|
||||||
Welcome user <span x-text="$store.digimarks.userKey"></span>! Tryout: <b x-text="$store.digimarks.tryout"></b>
|
<p>Welcome user <span x-text="$store.digimarks.userKey"></span>!</p>
|
||||||
<input x-model="$store.digimarks.search" placeholder="Search...">
|
<div x-show="$store.digimarks.loading">Loading...</div>
|
||||||
<div x-show="$store.digimarks.loading">
|
|
||||||
Loading...
|
<p>
|
||||||
</div>
|
<button @click="$store.digimarks.sortAlphabetically()">sort a-z</button>
|
||||||
|
<button @click="$store.digimarks.sortCreated()">sort date asc</button>
|
||||||
|
<button @click="$store.digimarks.sortCreated('desc')">sort date desc</button>
|
||||||
|
</p>
|
||||||
|
|
||||||
<ul x-cloak>
|
<ul x-cloak>
|
||||||
<template x-for="bookmark in $store.digimarks.filteredItems" :key="bookmark.id">
|
<template x-for="bookmark in $store.digimarks.filteredItems" :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>
|
||||||
|
</main>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user