commit 621bbc1dc432104d93d83d4000e71a4603ed87d7
parent db5db651dee0619449d7f2f5450fb0d0e9c2a435
Author: triesap <137732411+triesap@users.noreply.github.com>
Date: Fri, 8 Nov 2024 05:47:52 +0000
apps-lib: edit components styles, elements styles. add/edit locales, utils
Diffstat:
9 files changed, 78 insertions(+), 60 deletions(-)
diff --git a/apps-lib/src/lib/components/entry_line.svelte b/apps-lib/src/lib/components/entry_line.svelte
@@ -14,8 +14,12 @@
$: layer =
typeof basis.wrap?.layer === `boolean`
- ? false
- : parse_layer(basis.wrap?.layer, 1);
+ ? parse_layer(0)
+ : parse_layer(basis.wrap?.layer);
+ $: classes_layer =
+ typeof basis.wrap?.layer === `boolean`
+ ? ``
+ : `text-layer-${layer}-glyph`;
let loading_dim: ILoadingDimension = `sm`;
$: loading_dim = basis.wrap?.style === `guide` ? `md` : `sm`;
</script>
@@ -43,7 +47,7 @@
key: basis.notify_inline.glyph,
dim: `xs+`,
weight: `bold`,
- classes: `text-layer-${layer}-glyph`,
+ classes: `${classes_layer}`,
}
: basis.notify_inline.glyph}
/>
diff --git a/apps-lib/src/lib/components/entry_wrap.svelte b/apps-lib/src/lib/components/entry_wrap.svelte
@@ -5,12 +5,12 @@
$: layer =
typeof basis?.layer === `boolean`
- ? false
- : parse_layer(basis?.layer, 1);
+ ? parse_layer(0)
+ : parse_layer(basis?.layer);
$: classes_layer =
- layer === false
+ typeof basis?.layer === `boolean`
? `bg-transparent`
- : `bg-layer-${layer}-surface text-layer-${layer}-glyph_d ${basis?.style_a ? `active:bg-layer-${layer}-surface_a` : ``}`;
+ : `bg-layer-${layer}-surface ${basis?.style_a ? `active:bg-layer-${layer}-surface_a` : ``}`; //text-layer-${layer}-glyph_d
</script>
<button
diff --git a/apps-lib/src/lib/el/input_element.svelte b/apps-lib/src/lib/el/input_element.svelte
@@ -15,10 +15,7 @@
onMount(async () => {
try {
- if (basis.id && basis.sync_init) {
- const sync_val = await kv.get(basis.id);
- await kv.set(basis.id, sync_val || ``);
- }
+ await kv_init();
} catch (e) {
} finally {
}
@@ -29,7 +26,7 @@
$: layer =
typeof basis?.layer === `boolean` ? 0 : parse_layer(basis?.layer, 1); //@todo
- $: if (basis?.id && basis?.sync) {
+ $: if (basis?.id && basis?.sync && value) {
(async () => {
try {
await kv.set(basis?.id, value);
@@ -37,6 +34,20 @@
})();
}
+ const kv_init = async (): Promise<void> => {
+ try {
+ if (!basis?.id) return;
+ if (basis?.sync) {
+ const kv_val = await kv.get(basis?.id);
+ console.log(`kv_val `, kv_val);
+ if (kv_val && el) el.value = kv_val;
+ else await kv.set(basis?.id, ``);
+ }
+ } catch (e) {
+ console.log(`(error) kv_init `, e);
+ }
+ };
+
const handle_on_input = async (el: HTMLInputElement): Promise<void> => {
try {
let pass = true;
diff --git a/apps-lib/src/lib/el/select_element.svelte b/apps-lib/src/lib/el/select_element.svelte
@@ -12,7 +12,7 @@
$: layer =
typeof basis?.layer === `boolean`
? parse_layer(0)
- : parse_layer(basis.layer, 0);
+ : parse_layer(basis.layer);
$: classes_layer =
typeof basis?.layer === `boolean` ? `` : `text-layer-${layer}-glyph_d`;
diff --git a/apps-lib/src/lib/el/select_menu.svelte b/apps-lib/src/lib/el/select_menu.svelte
@@ -10,7 +10,7 @@
$: layer =
typeof basis?.layer === `boolean`
? parse_layer(0)
- : parse_layer(basis.layer, 0);
+ : parse_layer(basis.layer);
$: classes_layer =
typeof basis?.layer === `boolean` ? `` : `text-layer-${layer}-glyph`;
</script>
diff --git a/apps-lib/src/lib/el/textarea_element.svelte b/apps-lib/src/lib/el/textarea_element.svelte
@@ -11,6 +11,7 @@
let el: HTMLTextAreaElement | null = null;
+ export let value: string = ``;
export let basis: ITextAreaElement;
$: basis = basis;
@@ -24,21 +25,21 @@
} catch (e) {}
});
+ $: if (basis?.id && basis?.sync && value) {
+ (async () => {
+ try {
+ await kv.set(basis?.id, value);
+ } catch (e) {}
+ })();
+ }
+
const kv_init = async (): Promise<void> => {
try {
- if (basis?.id) {
- if (basis?.sync_init)
- await kv.set(
- basis?.id,
- typeof basis?.sync_init === `string`
- ? basis?.sync_init
- : ``,
- );
- if (basis?.sync) {
- const kv_val = await kv.get(basis?.id);
- if (kv_val && el) el.value = fmt_textarea_value(kv_val);
- else await kv.set(basis?.id, ``);
- }
+ if (!basis?.id) return;
+ if (basis?.sync) {
+ const kv_val = await kv.get(basis?.id);
+ if (kv_val && el) el.value = fmt_textarea_value(kv_val);
+ else await kv.set(basis?.id, ``);
}
if (basis?.on_mount) await basis?.on_mount(el);
} catch (e) {
@@ -71,6 +72,7 @@
<textarea
bind:this={el}
+ bind:value
{id}
contenteditable="true"
class={`${fmt_cl(basis.classes)} el-textarea w-full bg-layer-${layer}-surface text-layer-${layer}-glyph placeholder:text-layer-${layer}-glyph_pl caret-layer-${layer}-glyph`}
diff --git a/apps-lib/src/lib/locales/en/common.json b/apps-lib/src/lib/locales/en/common.json
@@ -1,4 +1,5 @@
{
+ "make_primary": "Make primary",
"accept": "Accept",
"activation": "Activation",
"active": "Active",
diff --git a/apps-lib/src/lib/types/el.ts b/apps-lib/src/lib/types/el.ts
@@ -156,7 +156,7 @@ export type IInputElement = IId & IClOpt & ILyOptTs & {
hidden?: boolean;
validate?: RegExp;
sync?: boolean;
- sync_init?: boolean;
+ // sync_init?: string;
field?: IFormField;
/*notify_inline?: {
glyph: GlyphKey | IGlyph;
@@ -173,7 +173,7 @@ export type ITextAreaElement = IId & IClOpt & ILyOptTs & {
hidden?: boolean;
validate?: RegExp;
sync?: true;
- sync_init?: true | string;
+ //sync_init?: true | string;
field?: IFormField;
/*notify_inline?: {
glyph: GlyphKey | IGlyph;
diff --git a/apps-lib/src/lib/utils/routes.ts b/apps-lib/src/lib/utils/routes.ts
@@ -1,35 +1,35 @@
export type NavigationRoute =
- | "/"
- | "/models/location-gcs"
- | "/models/nostr-profile"
- | "/models/nostr-profile/edit/field"
- | "/models/nostr-profile/view"
- | "/models/nostr-relay"
- | "/models/nostr-relay/view"
- | "/models/trade-product"
- | "/models/trade-product/add"
- | "/settings"
- | "/test"
- | "/cfg/error"
- | "/cfg/init";
+ | "/"
+ | "/models/location-gcs"
+ | "/models/nostr-profile"
+ | "/models/nostr-profile/edit/field"
+ | "/models/nostr-profile/view"
+ | "/models/nostr-relay"
+ | "/models/nostr-relay/view"
+ | "/models/trade-product"
+ | "/models/trade-product/add"
+ | "/settings"
+ | "/test"
+ | "/cfg/error"
+ | "/cfg/init";
export function parse_route(route: string): NavigationRoute {
- switch (route) {
- case "/":
- case "/models/location-gcs":
- case "/models/nostr-profile":
- case "/models/nostr-profile/edit/field":
- case "/models/nostr-profile/view":
- case "/models/nostr-relay":
- case "/models/nostr-relay/view":
- case "/models/trade-product":
- case "/models/trade-product/add":
- case "/settings":
- case "/test":
- case "/cfg/error":
- case "/cfg/init":
- return route;
- default:
- return "/";
- };
+ switch (route) {
+ case "/":
+ case "/models/location-gcs":
+ case "/models/nostr-profile":
+ case "/models/nostr-profile/edit/field":
+ case "/models/nostr-profile/view":
+ case "/models/nostr-relay":
+ case "/models/nostr-relay/view":
+ case "/models/trade-product":
+ case "/models/trade-product/add":
+ case "/settings":
+ case "/test":
+ case "/cfg/error":
+ case "/cfg/init":
+ return route;
+ default:
+ return "/";
+ };
};
\ No newline at end of file