From 66bac03e3078e4e781d2d3903c05ad66a883a354 Mon Sep 17 00:00:00 2001 From: wukko Date: Mon, 22 Jul 2024 14:33:43 +0600 Subject: [PATCH] web/dialogs: add picker dialog & clean up small dialog --- web/i18n/en/a11y/dialog.json | 3 + web/i18n/en/dialog.json | 9 +- .../dialog/DialogBackdropClose.svelte | 18 ++ .../components/dialog/DialogButtons.svelte | 61 +++++ web/src/components/dialog/DialogHolder.svelte | 107 +++++++- web/src/components/dialog/PickerDialog.svelte | 231 ++++++++++++++++++ web/src/components/dialog/PickerItem.svelte | 65 +++++ web/src/components/dialog/SmallDialog.svelte | 176 ++----------- .../save/buttons/DownloadButton.svelte | 93 ++++--- web/src/lib/download.ts | 9 + web/src/lib/types/dialog.ts | 11 +- 11 files changed, 584 insertions(+), 199 deletions(-) create mode 100644 web/i18n/en/a11y/dialog.json create mode 100644 web/src/components/dialog/DialogBackdropClose.svelte create mode 100644 web/src/components/dialog/DialogButtons.svelte create mode 100644 web/src/components/dialog/PickerDialog.svelte create mode 100644 web/src/components/dialog/PickerItem.svelte create mode 100644 web/src/lib/download.ts diff --git a/web/i18n/en/a11y/dialog.json b/web/i18n/en/a11y/dialog.json new file mode 100644 index 00000000..451d74cf --- /dev/null +++ b/web/i18n/en/a11y/dialog.json @@ -0,0 +1,3 @@ +{ + "picker.item.generic": "media thumbnail" +} diff --git a/web/i18n/en/dialog.json b/web/i18n/en/dialog.json index b57fae5b..bfe30bec 100644 --- a/web/i18n/en/dialog.json +++ b/web/i18n/en/dialog.json @@ -2,7 +2,14 @@ "button.gotit": "got it", "button.cancel": "cancel", "button.reset": "reset", + "button.done": "done", + "button.downloadAudio": "download audio", "reset.title": "reset all settings?", - "reset.body": "are you sure you want to reset all settings? this action is immediate and irreversible." + "reset.body": "are you sure you want to reset all settings? this action is immediate and irreversible.", + + "picker.title": "select what to save", + "picker.description.desktop": "click an item to save it. images can also be saved via the right click menu.", + "picker.description.phone": "press an item to save it. images can also be saved with a long press.", + "picker.description.ios": "press an item to save it with a shortcut. images can also be saved with a long press." } diff --git a/web/src/components/dialog/DialogBackdropClose.svelte b/web/src/components/dialog/DialogBackdropClose.svelte new file mode 100644 index 00000000..7c290533 --- /dev/null +++ b/web/src/components/dialog/DialogBackdropClose.svelte @@ -0,0 +1,18 @@ + + + + + diff --git a/web/src/components/dialog/DialogButtons.svelte b/web/src/components/dialog/DialogButtons.svelte new file mode 100644 index 00000000..5f086a78 --- /dev/null +++ b/web/src/components/dialog/DialogButtons.svelte @@ -0,0 +1,61 @@ + + + + + diff --git a/web/src/components/dialog/DialogHolder.svelte b/web/src/components/dialog/DialogHolder.svelte index 7a9550fe..61503fcd 100644 --- a/web/src/components/dialog/DialogHolder.svelte +++ b/web/src/components/dialog/DialogHolder.svelte @@ -1,7 +1,9 @@ @@ -18,11 +20,56 @@ buttons={dialog.buttons} /> {/if} + + {#if dialog.type === "picker"} + + {/if} {/each}
diff --git a/web/src/components/dialog/PickerDialog.svelte b/web/src/components/dialog/PickerDialog.svelte new file mode 100644 index 00000000..5c5c0d61 --- /dev/null +++ b/web/src/components/dialog/PickerDialog.svelte @@ -0,0 +1,231 @@ + + + +
+ +
+ {#if items} + {#each items as item} + + {/each} + {/if} +
+ {#if buttons} + + {/if} +
+ + +
+ + diff --git a/web/src/components/dialog/PickerItem.svelte b/web/src/components/dialog/PickerItem.svelte new file mode 100644 index 00000000..b56abcc9 --- /dev/null +++ b/web/src/components/dialog/PickerItem.svelte @@ -0,0 +1,65 @@ + + + + + diff --git a/web/src/components/dialog/SmallDialog.svelte b/web/src/components/dialog/SmallDialog.svelte index 3a4cdddf..b2951d62 100644 --- a/web/src/components/dialog/SmallDialog.svelte +++ b/web/src/components/dialog/SmallDialog.svelte @@ -1,12 +1,14 @@ diff --git a/web/src/lib/download.ts b/web/src/lib/download.ts new file mode 100644 index 00000000..e08320ef --- /dev/null +++ b/web/src/lib/download.ts @@ -0,0 +1,9 @@ +import { device } from "$lib/device"; + +export const downloadFile = (url: string) => { + if (device.is.iOS) { + return navigator?.share({ url }).catch(() => {}); + } else { + return window.open(url, "_blank"); + } +}; diff --git a/web/src/lib/types/dialog.ts b/web/src/lib/types/dialog.ts index 6630fd6f..f6d2439d 100644 --- a/web/src/lib/types/dialog.ts +++ b/web/src/lib/types/dialog.ts @@ -9,13 +9,20 @@ export type DialogButton = { export type SmallDialogIcons = "warn-red"; +export type DialogPickerItem = { + type?: 'photo' | 'video', + url: string, + thumb?: string, +} + export type DialogInfo = { id: string, - type: "small", + type: "small" | "picker", meowbalt?: MeowbaltEmotions, icon?: SmallDialogIcons, title?: string, bodyText?: string, bodySubText?: string, - buttons: DialogButton[], + buttons?: DialogButton[], + items?: DialogPickerItem[], }