web_lib

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

commit 47ce9cc3cc879452347c9833cdf17c3782f3f3a4
parent 27864823fbfd740eabf4345d6d5d28dd4a54a581
Author: triesap <137732411+triesap@users.noreply.github.com>
Date:   Wed, 13 Nov 2024 06:45:32 +0000

apps-lib: edit envelope lower add full cover basis. edit element input, select styles. edit controls app tilt. edit carousel utils. add/edit utils, locales, stores, types. edit components styles

Diffstat:
Mapps-lib/src/lib/components/controls.svelte | 3++-
Mapps-lib/src/lib/components/entry_select.svelte | 2+-
Mapps-lib/src/lib/components/envelope_lower.svelte | 20+++++++++++---------
Mapps-lib/src/lib/el/input_element.svelte | 11++++++++---
Mapps-lib/src/lib/el/select_element.svelte | 4++--
Mapps-lib/src/lib/locales/en/common.json | 7++++---
Mapps-lib/src/lib/locales/en/icu.json | 4++++
Mapps-lib/src/lib/stores/client.ts | 16++++++++++++++--
Mapps-lib/src/lib/types/client.ts | 3+++
Mapps-lib/src/lib/utils/carousel.ts | 6+++---
Mapps-lib/src/lib/utils/client.ts | 10++++++++--
Mapps-lib/src/lib/utils/numbers.ts | 3+--
12 files changed, 61 insertions(+), 28 deletions(-)

diff --git a/apps-lib/src/lib/components/controls.svelte b/apps-lib/src/lib/components/controls.svelte @@ -4,6 +4,7 @@ app_tilt, app_toast, app_win, + envelope_tilt, envelope_visible, Toast, wind, @@ -25,7 +26,7 @@ }); envelope_visible.subscribe(async (_envelope_visible) => { - if (_envelope_visible) app_tilt.set(true); + if (_envelope_visible && $envelope_tilt) app_tilt.set(true); else app_tilt.set(false); }); </script> diff --git a/apps-lib/src/lib/components/entry_select.svelte b/apps-lib/src/lib/components/entry_select.svelte @@ -42,7 +42,7 @@ key: `caret-up-down`, dim: `xs`, weight: `bold`, - classes: `text-layer-${layer}-glyph`, + classes: `text-layer-${layer}-glyph_d`, }} /> </div> diff --git a/apps-lib/src/lib/components/envelope_lower.svelte b/apps-lib/src/lib/components/envelope_lower.svelte @@ -35,16 +35,18 @@ out:fly={{ y: `100%`, easing: quintInOut }} class={`z-20 absolute bottom-0 left-0 flex flex-col h-[100vh] w-full justify-start items-start`} > - <button - class={`flex flex-row h-[12%] w-full justify-center items-center text-white`} - on:click={async () => { - await handle_close(); - }} - > - <Fill /> - </button> + {#if !basis.full_cover} + <button + class={`flex flex-row h-[12%] w-full justify-center items-center text-white`} + on:click={async () => { + await handle_close(); + }} + > + <Fill /> + </button> + {/if} <div - class={`relative flex flex-col h-[calc(100vh-12%)] w-full justify-start justify-start items-start bg-layer-1-surface rounded-t-3xl overflow-hidden`} + class={`relative flex flex-col ${basis.full_cover ? `h-[100vh]` : `h-[calc(100vh-12%)]`} w-full justify-start justify-start items-start bg-layer-1-surface rounded-t-3xl overflow-hidden`} > <div class={`absolute z-10 top-0 left-0 grid grid-cols-12 flex flex-row h-12 w-full px-4 pb-2 justify-center items-center ${el_c_scrolled ? `bg-layer-1-surface/30 backdrop-blur-lg` : ``} el-re`} diff --git a/apps-lib/src/lib/el/input_element.svelte b/apps-lib/src/lib/el/input_element.svelte @@ -24,8 +24,13 @@ $: basis = basis; $: id = basis?.id ? basis?.id : null; $: layer = - typeof basis?.layer === `boolean` ? 0 : parse_layer(basis?.layer, 1); //@todo - + typeof basis?.layer === `boolean` + ? parse_layer(0) + : parse_layer(basis?.layer); + $: classes_layer = + typeof basis?.layer === `boolean` + ? `` + : `text-layer-${layer}-glyph placeholder:text-layer-${layer}-glyph_pl caret-layer-${layer}-glyph`; $: if (basis?.id && basis?.sync && value) { (async () => { try { @@ -89,6 +94,6 @@ }} {id} type="text" - class={`${fmt_cl(basis?.classes)} el-input text-layer-${layer}-glyph placeholder:text-layer-${layer}-glyph_pl caret-layer-${layer}-glyph el-re`} + class={`${fmt_cl(basis?.classes)} el-input ${classes_layer} el-re`} placeholder={basis?.placeholder || ""} /> diff --git a/apps-lib/src/lib/el/select_element.svelte b/apps-lib/src/lib/el/select_element.svelte @@ -17,7 +17,7 @@ typeof basis?.layer === `boolean` ? `` : !value - ? `text-layer-${layer}-glyph_pl opacity-40` + ? `text-layer-${layer}-glyph_pl` : `text-layer-${layer}-glyph_d`; onMount(async () => { @@ -104,7 +104,7 @@ key: `caret-up-down`, dim: `xs`, weight: `bold`, - classes: `text-layer-${layer}-glyph translate-y-[1px]`, + classes: `text-layer-${layer}-glyph`, }} /> </div> diff --git a/apps-lib/src/lib/locales/en/common.json b/apps-lib/src/lib/locales/en/common.json @@ -1,7 +1,4 @@ { - "current_location": "Current location", - "close": "Close", - "make_primary": "Make primary", "accept": "Accept", "activation": "Activation", "active": "Active", @@ -18,11 +15,13 @@ "bank_account": "Bank account", "business_name": "Business name", "cancel": "Cancel", + "close": "Close", "configure": "Configure", "connect": "Connect", "connected": "Connected", "connection": "Connection", "continue": "Continue", + "current_location": "Current location", "date_created": "Date created", "date_modified": "Date modified", "delete": "Delete", @@ -56,6 +55,7 @@ "lot": "Lot", "lot_name": "Lot name", "lowest_price": "Lowest price", + "make_primary": "Make primary", "map": "Map", "market": "Market", "message": "Message", @@ -71,6 +71,7 @@ "optional": "Optional", "options": "Options", "options_list": "Options list", + "order": "Order", "origin": "Origin", "other": "Other", "outflows": "Outflows", diff --git a/apps-lib/src/lib/locales/en/icu.json b/apps-lib/src/lib/locales/en/icu.json @@ -9,9 +9,11 @@ "*_month": "{value} month", "*_name": "{value} name", "*_price": "{value} price", + "*_quantity": "{value} quantity", "*_summary": "{value} summary", "*_the": "{value} the", "*_title": "{value} title", + "*_total": "{value} total", "*_your_device": "{value} your device", "a_*_is_required": "A {value} is required", "add_*": "Add {value}", @@ -20,6 +22,7 @@ "as_*": "As {value}", "choose_*": "Choose {value}", "choose_a_*": "Choose a {}", + "choose_on_*": "Choose on {value}", "click_to_add_a_*": "Click to add a {value}", "configure_*": "Configure {value}", "connect_*": "Connect {value}", @@ -57,6 +60,7 @@ "the_*": "The {value}", "the_*_is_available": "The {value} is available", "the_*_is_missing": "The {value} is missing", + "the_*_is_incomplete": "The {value} is incomplete", "the_*_is_registered": "The {value} is registered", "the_current_entry_*_will_be_deleted": "The current entry \"{value}\" will be deleted", "this_*": "This {value}", diff --git a/apps-lib/src/lib/stores/client.ts b/apps-lib/src/lib/stores/client.ts @@ -50,9 +50,21 @@ export const tabs_active = writable<number>(0); export const carousel_active = writable<boolean>(false); export const carousel_index = writable<number>(0); export const carousel_index_max = writable<number>(0); -export const carousel_num = writable<number>(1); - +const fn_carousel_num = (num_i: number, num_min: number) => { + const store = writable<number>(num_i); + return { + subscribe: store.subscribe, + set: (num: number) => { + store.set(Math.max(num, num_min)); + }, + update: (updater: (num: number) => number) => { + store.update((num) => Math.max(updater(num), num_min)); + } + }; +} +export const carousel_num = fn_carousel_num(1, 1); export const envelope_visible = writable<boolean>(false); +export const envelope_tilt = writable<boolean>(true); export const nostr_ndk_configured = writable<boolean>(false); export const nostr_relays_poll_documents = writable<boolean>(false); diff --git a/apps-lib/src/lib/types/client.ts b/apps-lib/src/lib/types/client.ts @@ -192,3 +192,5 @@ export type IToast = IClOpt & export type AppConfigType = `farmer` | `personal` export type GeolocationLatitudeFmtOption = 'dms' | 'd' | 'dm'; + +export type UploadFilePresignedUrl = { url: string; storage_key: string; file_name: string } +\ No newline at end of file diff --git a/apps-lib/src/lib/utils/carousel.ts b/apps-lib/src/lib/utils/carousel.ts @@ -7,7 +7,7 @@ import { } from "$lib"; import { get as get_store } from 'svelte/store'; -const CAROUSEL_DELAY_MS = 250; +const CAROUSEL_DELAY_MS = 150; const get_slide_container = <T extends string>( view: T, @@ -59,7 +59,7 @@ export const carousel_inc = async <T extends string>( view: T, duration: number = CAROUSEL_DELAY_MS ): Promise<void> => { - const num = get_store(carousel_num) || 1; + const num = get_store(carousel_num); carousel_num.set(1); await exe_iter(async () => carousel_inc_handler(view), num, duration); }; @@ -69,7 +69,7 @@ export const carousel_dec = async <T extends string>( view: T, duration: number = CAROUSEL_DELAY_MS ): Promise<void> => { - const num = get_store(carousel_num) || 1; + const num = get_store(carousel_num); carousel_num.set(1); await exe_iter(async () => carousel_dec_handler(view), num, duration); }; diff --git a/apps-lib/src/lib/utils/client.ts b/apps-lib/src/lib/utils/client.ts @@ -1,7 +1,6 @@ import { goto } from "$app/navigation"; -import { app_toast, locale, nav_prev, TOAST_MS, type AnchorRoute, type AppConfigType, type AppLayoutKey, type CallbackPromise, type CallbackPromiseGeneric, type GeolocationLatitudeFmtOption, type GlyphKey, type IToast, type LabelFieldKind, type NavigationParamTuple, type NavigationRoute, type NavigationRouteParamKey } from "$lib"; +import { app_toast, locale, nav_prev, t, TOAST_MS, type AnchorRoute, type AppConfigType, type AppLayoutKey, type CallbackPromise, type CallbackPromiseGeneric, type GeolocationLatitudeFmtOption, type GlyphKey, type IToast, type LabelFieldKind, type NavigationParamTuple, type NavigationRoute, type NavigationRouteParamKey } from "$lib"; import type { ColorMode, ThemeKey, ThemeLayer } from "@radroots/theme"; - import { get as get_store } from "svelte/store"; @@ -281,3 +280,9 @@ export const exe_iter = async (callback: CallbackPromise, num: number = 1, delay console.log(`(error) exe_iter `, e); } }; + +export const fmt_list_oxford = (list: string[], loc_key?: string): string => { + if (list.length > 1 && loc_key) return `${list.slice(0, -1).map(i => `${loc_key}${i}`).join(', ')} ${`${get_store(t)(`common.and`)}`} ${`${loc_key}${list[list.length - 1]}`}`; + else if (list.length > 1) return `${list.slice(0, -1).join(', ')} ${`${get_store(t)(`common.and`)}`} ${list[list.length - 1]}`; + return list[0]; +}; +\ No newline at end of file diff --git a/apps-lib/src/lib/utils/numbers.ts b/apps-lib/src/lib/utils/numbers.ts @@ -10,4 +10,4 @@ export const fmt_price = (currency: string, value: string): string => { maximumFractionDigits: 2 }).format(value_num); return res; -}; -\ No newline at end of file +};