diff --git a/package.json b/package.json index 935df6d..9c353c9 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@sveltejs/vite-plugin-svelte": "^3.0.0", "autoprefixer": "^10.4.17", "dayjs": "^1.11.10", + "image-js": "^0.35.5", "postcss": "^8.4.33", "prettier": "^3.1.1", "prettier-plugin-svelte": "^3.1.2", diff --git a/src/lib/components/DropPlaceholder.svelte b/src/lib/components/DropPlaceholder.svelte new file mode 100644 index 0000000..106e073 --- /dev/null +++ b/src/lib/components/DropPlaceholder.svelte @@ -0,0 +1,5 @@ +
+

Drop your images here

+
diff --git a/src/lib/components/gallery/ActionButton.svelte b/src/lib/components/gallery/ActionButton.svelte index 85c4694..d25a962 100644 --- a/src/lib/components/gallery/ActionButton.svelte +++ b/src/lib/components/gallery/ActionButton.svelte @@ -1,4 +1,5 @@ @@ -14,7 +17,8 @@ diff --git a/src/lib/components/gallery/BlurImagePanel.svelte b/src/lib/components/gallery/BlurImagePanel.svelte new file mode 100644 index 0000000..e8f6622 --- /dev/null +++ b/src/lib/components/gallery/BlurImagePanel.svelte @@ -0,0 +1,23 @@ + + +
+

Blur

+
+ (blurValue = e[0])} + class="w-80" + max={100} + min={0} + step={5} + /> +
+
diff --git a/src/lib/components/gallery/Header.svelte b/src/lib/components/gallery/Header.svelte index 1fd0ab9..f89ee58 100644 --- a/src/lib/components/gallery/Header.svelte +++ b/src/lib/components/gallery/Header.svelte @@ -1,17 +1,12 @@
-
- - - - - - -
- -
- - {#if image} - {image.name} + toggleRotate()} + /> + {#if rotate} + rotateRight()} + /> + rotateLeft()} /> {/if} + + blurImage()} + /> + + +
- + +
+ +
- - + + {#if image} + {image.name} + {/if} + + +
{#if showInfo} - + + {/if} + + {#if activeAction == trimString(BLUR)} + {/if} + + diff --git a/src/lib/utils/tools.ts b/src/lib/utils/tools.ts index 01e746b..59155ad 100644 --- a/src/lib/utils/tools.ts +++ b/src/lib/utils/tools.ts @@ -85,34 +85,6 @@ export function makeid(length: number) { return str } -export const proccessFiles = async (files: File[]) => { - return new Promise((resolve) => { - const __process = async () => { - let images: any[] = [] - - files.forEach((file) => { - if (file.type && !file.type.startsWith('image/')) { - console.error('File is not an image.', file.type, file) - return - } - let reader = new FileReader() - - reader.addEventListener( - 'load', - () => { - images.push(reader.result) - }, - false - ) - - if (file) { - reader.readAsDataURL(file) - } - }) - - resolve(images) - } - __process() - }) - // return images +export function trimString(str: string) { + return str.trim().replaceAll(' ', '').toLowerCase() } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 2dff047..828e29b 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -12,6 +12,7 @@ import { makeid } from '$lib/utils/tools' import { galleryStore } from '$lib/store' import type { ImageType } from '$lib/utils/types' + import DropPlaceholder from '$lib/components/DropPlaceholder.svelte' let imageDropping = false let deleteModal = false @@ -179,7 +180,7 @@ images = $galleryStore.images.filter((img) => { return selectedTags.every((tag) => img.tags.includes(tag)) }) - + break default: images = $galleryStore.images @@ -214,11 +215,7 @@
{#if imageDropping} -
-

Drop your images here

-
+ {/if}