web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

commit 2035c142a50aa1ccff68348f4ab2791d8b14e2f2
parent 6586a3190fec4740dd56c04c5532cf9ebcf63b6c
Author: triesap <137732411+triesap@users.noreply.github.com>
Date:   Mon,  9 Dec 2024 07:04:59 +0000

apps-lib: edit components, elements. add/edit locales, utils

Diffstat:
Mapps-lib/src/lib/components/nav_toolbar.svelte | 2+-
Mapps-lib/src/lib/components/tabs_float.svelte | 11+++++++----
Mapps-lib/src/lib/el/input_element.svelte | 2+-
Mapps-lib/src/lib/locales/en/common.json | 2++
Mapps-lib/src/lib/locales/en/error.json | 1+
Mapps-lib/src/lib/utils/client.ts | 8++++++++
Mapps-lib/src/lib/utils/routes.ts | 6++++++
7 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/apps-lib/src/lib/components/nav_toolbar.svelte b/apps-lib/src/lib/components/nav_toolbar.svelte @@ -2,7 +2,7 @@ import { Glyph, LogoCircleSm, ls, route } from "$lib"; </script> -<div class={`flex flex-row h-12 w-full px-6 pb-4 justify-between items-center`}> +<div class={`flex flex-row h-12 w-full px-6 pb-6 justify-between items-center`}> <button class={`flex flex-row gap-2 justify-start items-center`} on:click={async () => { diff --git a/apps-lib/src/lib/components/tabs_float.svelte b/apps-lib/src/lib/components/tabs_float.svelte @@ -27,14 +27,15 @@ <button class={`relative col-span-1 flex flex-row justify-center items-center`} on:click={async () => { - await route(`/`); + await route(`/search`); }} > <Glyph basis={{ classes: `text-[24px] text-layer-0-glyph/80`, - weight: - $page.url.pathname === `/search` ? `fill` : `bold`, + weight: $page.url.pathname.startsWith(`/search`) + ? `fill` + : `bold`, key: `magnifying-glass`, }} /> @@ -63,7 +64,9 @@ </button> <button class={`relative col-span-1 flex flex-row h-full justify-center items-center`} - on:click={async () => {}} + on:click={async () => { + await route(`/notifications`); + }} > <Glyph basis={{ diff --git a/apps-lib/src/lib/el/input_element.svelte b/apps-lib/src/lib/el/input_element.svelte @@ -28,7 +28,7 @@ ? parse_layer(0) : parse_layer(basis?.layer); $: classes_layer = - typeof basis?.layer === `boolean` + typeof basis?.layer === `boolean` || typeof basis?.layer === `undefined` ? `` : `bg-layer-${layer}-surface text-layer-${layer}-glyph placeholder:text-layer-${layer}-glyph_pl caret-layer-${layer}-glyph`; $: if (basis?.id && basis?.sync && value) { diff --git a/apps-lib/src/lib/locales/en/common.json b/apps-lib/src/lib/locales/en/common.json @@ -1,4 +1,5 @@ { + "notifications": "Notifications", "accept": "Accept", "activation": "Activation", "active": "Active", @@ -132,6 +133,7 @@ "reset": "Reset", "return": "Return", "review": "Review", + "search": "Search", "secret_key": "Secret key", "settings": "Settings", "setup": "Setup", diff --git a/apps-lib/src/lib/locales/en/error.json b/apps-lib/src/lib/locales/en/error.json @@ -5,6 +5,7 @@ "keystore_nostr_secretkey": "The nostr key is not configured", "network_failure": "The requested resource is not available", "nostr_sync_disabled": "Sync to nostr network is disabled. Do you want to activate it?", + "operation_failure": "There was an error processing the request", "page": { "load": "There was an error loading the page", "status": { diff --git a/apps-lib/src/lib/utils/client.ts b/apps-lib/src/lib/utils/client.ts @@ -308,3 +308,11 @@ export const catch_err = async (e: unknown, fn_name: string): Promise<void> => { console.log(`(catch_err) `, e) } }; + +export const debounce_input = (func: Function, delay: number) => { + let timer: ReturnType<typeof setTimeout>; + return function (this: any, ...args: any) { + clearTimeout(timer); + timer = setTimeout(() => func.apply(this, args), delay); + }; +}; diff --git a/apps-lib/src/lib/utils/routes.ts b/apps-lib/src/lib/utils/routes.ts @@ -2,6 +2,7 @@ export type NavigationRoute = | "/" | "/farm/land" | "/farm/land/add" + | "/farm/land/view" | "/models/location-gcs" | "/models/nostr-profile" | "/models/nostr-profile/edit/field" @@ -11,6 +12,8 @@ export type NavigationRoute = | "/models/trade-product" | "/models/trade-product/add" | "/models/trade-product/view" + | "/notifications" + | "/search" | "/settings" | "/settings/nostr" | "/settings/profile" @@ -24,6 +27,7 @@ export function parse_route(route: string): NavigationRoute { case "/": case "/farm/land": case "/farm/land/add": + case "/farm/land/view": case "/models/location-gcs": case "/models/nostr-profile": case "/models/nostr-profile/edit/field": @@ -33,6 +37,8 @@ export function parse_route(route: string): NavigationRoute { case "/models/trade-product": case "/models/trade-product/add": case "/models/trade-product/view": + case "/notifications": + case "/search": case "/settings": case "/settings/nostr": case "/settings/profile":