Add sorting to Quick Links

This commit is contained in:
Fred Boniface
2023-07-24 11:35:27 +01:00
parent 69949fb8f4
commit 2ffa3510ee
5 changed files with 16 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
<script>
<script lang="ts">
import Island from '$lib/islands/island.svelte';
import { ql } from '$lib/stores/quick-links.js';
import { ql } from '$lib/stores/quick-links';
export let variables = {
title: 'Quick Links'
};

View File

@@ -1,11 +1,11 @@
<script>
<script lang="ts">
import Island from '$lib/islands/island.svelte';
import { ql } from '$lib/stores/quick-links.js';
import { ql } from '$lib/stores/quick-links';
export let variables = {
title: 'Quick Links'
};
let qlData = [];
let qlData: string[] = [];
$: {
qlData = $ql;
console.log(qlData);
@@ -13,16 +13,16 @@
let saveButton = 'Save';
async function timeout(ms) {
async function timeout(ms: number): Promise<any> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function saveQl() {
// Fetch the content of all text entries within the island then run ql.set([ARRAY OF INPUT CONTENT])
const inputs = document.getElementsByClassName('qlInput');
let inputLinks = [];
let inputLinks: string[] = [];
for (let item of inputs) {
let text = item?.value;
let text = (<HTMLInputElement>item)?.value;
if (text !== '') {
inputLinks.push(text);
}
@@ -46,7 +46,7 @@
ql.set(updatedQl);
}
function handleClick(event) {
function handleClick(event: any) {
// Handle the click event here
console.log('Island Clicked');
// You can access the `variables` passed to the Island component here if needed