commit 6864f306705b9be7b25218d0d5e82ab69f4a5090
parent cae24a3e806751aa226a97b0b9b6491f26bd55a4
Author: triesap <137732411+triesap@users.noreply.github.com>
Date: Mon, 16 Sep 2024 19:19:21 +0000
apps-lib: edit tabs component, edit types, edit utils
Diffstat:
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/apps-lib/src/lib/components/tabs.svelte b/apps-lib/src/lib/components/tabs.svelte
@@ -31,7 +31,7 @@
<button
class={`col-span-3 flex flex-col h-full justify-start items-center transition-all`}
on:click={async () => {
- app_tab_active.set(tab_i);
+ if (!tab.hide_active) app_tab_active.set(tab_i);
await tab.callback(tab_i);
}}
>
diff --git a/apps-lib/src/lib/types/components.ts b/apps-lib/src/lib/types/components.ts
@@ -5,7 +5,8 @@ export type ITabsBasisList = {
icon: GlyphKey;
classes?: string;
active_weight?: GlyphWeight;
- indicator?: string
+ indicator?: string;
+ hide_active?: boolean;
callback: CallbackPromiseGeneric<number>;
};
diff --git a/apps-lib/src/lib/utils/client.ts b/apps-lib/src/lib/utils/client.ts
@@ -1,4 +1,4 @@
-import type { AnchorRoute, LabelFieldKind, NavigationParamTuple, NavigationRouteParamKey } from "$lib/types/client";
+import type { AnchorRoute, CallbackPromiseGeneric, LabelFieldKind, NavigationParamTuple, NavigationRouteParamKey } from "$lib/types/client";
import type { ColorMode, ThemeKey, ThemeLayer } from "@radroots/theme";
export const sleep = async (ms: number): Promise<void> => {
@@ -87,3 +87,12 @@ export const int_step = (num: number, op: `+` | `-`, bounds?: number): number =>
return Math.max(int_num - 1, bounds || 0);
};
+export const clipboard_copy = async (text: string, callback: CallbackPromiseGeneric<string>): Promise<void> => {
+ try {
+ navigator.clipboard.writeText(text).then(async () => {
+ await callback(text);
+ });
+ } catch (e) {
+ console.log(`(error) clipboard_copy `, e);
+ }
+};
+\ No newline at end of file