diff --git a/docs/routes/classes/Card.md b/docs/routes/classes/Card.md index 3f8d553db..252ca62fb 100644 --- a/docs/routes/classes/Card.md +++ b/docs/routes/classes/Card.md @@ -23,7 +23,7 @@
- +
diff --git a/docs/routes/classes/File.md b/docs/routes/classes/File.md new file mode 100644 index 000000000..b8dcc8f17 --- /dev/null +++ b/docs/routes/classes/File.md @@ -0,0 +1,14 @@ +```svelte example raised + + +
+
+ +
cool-mod.jar
+ +
+
+``` diff --git a/docs/routes/components/Button.md b/docs/routes/components/Button.md index f56e73c27..9fa6e5e95 100644 --- a/docs/routes/components/Button.md +++ b/docs/routes/components/Button.md @@ -6,7 +6,7 @@ import IconDownload from 'virtual:icons/heroicons-outline/download' - + ``` ### Color variants example @@ -19,7 +19,6 @@
- @@ -33,7 +32,7 @@ ### With icons example -```svelte example raised +```svelte example
- - + +
``` diff --git a/docs/routes/components/CheckboxVirtualList.md b/docs/routes/components/CheckboxVirtualList.md index 6d4c98a57..55bde2400 100644 --- a/docs/routes/components/CheckboxVirtualList.md +++ b/docs/routes/components/CheckboxVirtualList.md @@ -2,17 +2,16 @@ diff --git a/package.json b/package.json index f1f726571..fe08306a2 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "dev": "svelte-kit dev", "build": "svelte-kit build", "package": "svelte-kit package && merge-dirs package/src package", + "watch:package": "svelte-kit package --watch", "preview": "svelte-kit preview", "prepare": "svelte-kit sync", "check": "svelte-check --tsconfig ./tsconfig.json", @@ -82,7 +83,7 @@ "postcss-preset-env": "^7.7.1", "postcss-pxtorem": "^6.0.0", "sanitize.css": "^13.0.0", - "svelte-tiny-virtual-list": "^2.0.1", + "svelte-tiny-virtual-list": "^2.0.5", "svelte-use-click-outside": "^1.0.0", "throttle-debounce": "^3.0.1", "undici": "^5.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5562a2c65..93eeb3690 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,7 +47,7 @@ specifiers: svelte-check: ^2.7.2 svelte-intl-precompile: ^0.11.1 svelte-preprocess: ^4.10.7 - svelte-tiny-virtual-list: ^2.0.1 + svelte-tiny-virtual-list: ^2.0.5 svelte-use-click-outside: ^1.0.0 svelte2tsx: ^0.5.5 throttle-debounce: ^3.0.1 @@ -82,7 +82,7 @@ dependencies: postcss-preset-env: 7.7.1_postcss@8.4.8 postcss-pxtorem: 6.0.0_postcss@8.4.8 sanitize.css: 13.0.0 - svelte-tiny-virtual-list: 2.0.1 + svelte-tiny-virtual-list: 2.0.5 svelte-use-click-outside: 1.0.0 throttle-debounce: 3.0.1 undici: 5.2.0 @@ -5141,8 +5141,8 @@ packages: typescript: 4.6.2 dev: true - /svelte-tiny-virtual-list/2.0.1: - resolution: {integrity: sha512-0X6k5cZxF9yRLfVJ1bfwQmfEMbd3OSNNM/tI9y44jYbsB/FkI2GEIKpeV5J8AQy87qFU9xnPLxxo3erQFfdC2A==} + /svelte-tiny-virtual-list/2.0.5: + resolution: {integrity: sha512-xg9ckb8UeeIme4/5qlwCrl2QNmUZ8SCQYZn3Ji83cUsoASqRNy3KWjpmNmzYvPDqCHSZjruBBsoB7t5hwuzw5g==} dev: false /svelte-use-click-outside/1.0.0: diff --git a/src/components/Button.svelte b/src/components/Button.svelte index 936dbe454..4c704e480 100644 --- a/src/components/Button.svelte +++ b/src/components/Button.svelte @@ -5,7 +5,7 @@ import { classCombine } from '../utils/classCombine' /** The element to be styled as a button */ - export let as: 'button' | 'a' | 'summary' | 'input' = 'button' + export let as: 'button' | 'a' | 'summary' | 'input' | 'file' = 'button' export let href = '' if (href) as = 'a' @@ -15,7 +15,6 @@ export let size: 'sm' | 'md' | 'lg' = 'md' export let color: | '' - | 'raised' | 'primary' | 'primary-light' | 'secondary' @@ -24,6 +23,9 @@ | 'danger-light' | 'transparent' = '' + /** Applies a stronger shadow to the element. To be used when the button isn't on a card */ + export let raised = false + /** Show notification badge in the upper right of button */ export let badge = false @@ -40,6 +42,7 @@ 'button', `button--size-${size}`, `button--color-${color}`, + raised && 'button--raised', badge && 'has-badge', ]) @@ -48,6 +51,10 @@ function dispatchClick() { if (!disabled) dispatch('click') } + + function dispatchFiles(event: Event) { + if (!disabled) dispatch('files', (event.target as HTMLInputElement).files || new FileList()) + } {#if as === 'a'} @@ -56,6 +63,11 @@ {:else if as === 'input'} +{:else if as === 'file'} + {:else} @@ -83,6 +95,11 @@ transition: opacity 0.5s ease-in-out, filter 0.2s ease-in-out, transform 0.05s ease-in-out, outline 0.2s ease-in-out; + &--raised { + background-color: var(--color-raised-bg); + box-shadow: var(--shadow-inset-sm), var(--shadow-raised); + } + &:hover:not(&--color-transparent, &:disabled) { filter: brightness(0.85); } @@ -93,11 +110,6 @@ } &--color { - &-raised { - background-color: var(--color-raised-bg); - box-shadow: var(--shadow-inset-sm), var(--shadow-raised); - } - &-primary { background-color: var(--color-brand); color: var(--color-brand-contrast); @@ -166,5 +178,10 @@ top: 0.5rem; right: 0.5rem; } + + /* Hides default file input */ + input[type='file'] { + display: none; + } } diff --git a/src/components/CheckboxVirtualList.svelte b/src/components/CheckboxVirtualList.svelte index 46d1df662..7a5d2131a 100644 --- a/src/components/CheckboxVirtualList.svelte +++ b/src/components/CheckboxVirtualList.svelte @@ -11,7 +11,12 @@ export let value = [] export let options: Option[] = [] + // Scroll into view selected options when created + let scrollToIndex = + Math.min(...value.map((val) => options.map((it) => it.value).indexOf(val))) || null + const handleChange = (event: any, key: string | number) => { + scrollToIndex = null if (event.target.checked) { if (!value) value = [] value = [key, ...value] @@ -21,7 +26,14 @@ } - +
file.name).includes(file.name)) { + // Check for duplicate files that aren't remote + if ( + !files + .filter((it) => it instanceof File) + .map((file) => file.name) + .includes(file.name) + ) { + if (files.map((file) => file.name).includes(file.name)) { + // Remove remote file with the same name + files = files.filter((it) => it.name !== file.name) + } files = [...files, file] } } @@ -53,7 +67,7 @@ {#each files as file (file.name)}
- {#if file.type.startsWith('image/')} + {#if file instanceof File && file.type.startsWith('image/')} {:else} @@ -65,7 +79,7 @@ files = files.filter((it) => it.name !== file.name) }}> Remove
- {#if file.type.startsWith('image/')} + {#if file instanceof File && file.type.startsWith('image/')}
diff --git a/src/components/Pagination.svelte b/src/components/Pagination.svelte index 544eda973..01ebb14a8 100644 --- a/src/components/Pagination.svelte +++ b/src/components/Pagination.svelte @@ -25,7 +25,7 @@ {#if count > 1}