- {#if file instanceof File && file.type.startsWith('image/')}
+ {#if !('remote' in file) && file.type.startsWith('image/')}
{:else}
@@ -79,7 +79,7 @@
files = files.filter((it) => it.name !== file.name)
}}> Remove
- {#if file instanceof File && file.type.startsWith('image/')}
+ {#if !('remote' in file) && file.type.startsWith('image/')}
![]()
import { browser, prerendering } from '$app/env'
import { page } from '$app/stores'
- import { onMount } from 'svelte'
+ import { onDestroy, onMount } from 'svelte'
import { debounce } from 'throttle-debounce'
interface Link {
@@ -53,18 +53,24 @@
$: if (activeIndex > -1 && browser && linkElements.length > 0) startAnimation()
function startAnimation() {
- indicator.direction = activeIndex < oldIndex ? 'left' : 'right'
+ // Avoids error that `linkElements[activeIndex]` is null
+ if (linkElements[activeIndex]) {
+ indicator.direction = activeIndex < oldIndex ? 'left' : 'right'
- indicator.left = linkElements[activeIndex].offsetLeft
- indicator.right =
- linkElements[activeIndex].parentElement.offsetWidth -
- linkElements[activeIndex].offsetLeft -
- linkElements[activeIndex].offsetWidth
- indicator.top = linkElements[activeIndex].offsetTop + linkElements[activeIndex].offsetHeight - 2
+ indicator.left = linkElements[activeIndex].offsetLeft
+ indicator.right =
+ linkElements[activeIndex].parentElement.offsetWidth -
+ linkElements[activeIndex].offsetLeft -
+ linkElements[activeIndex].offsetWidth
+ indicator.top =
+ linkElements[activeIndex].offsetTop + linkElements[activeIndex].offsetHeight - 2
+ }
oldIndex = activeIndex
}
+ const debounced = debounce(100, startAnimation)
+
let useAnimation = false
onMount(() => {
@@ -72,7 +78,11 @@
useAnimation = true
}, 300)
- window.addEventListener('resize', debounce(100, startAnimation))
+ window.addEventListener('resize', debounced)
+ })
+
+ onDestroy(() => {
+ if (browser) window.removeEventListener('resize', debounced)
})
diff --git a/src/components/Select.svelte b/src/components/Select.svelte
index 1ff6d9dd7..9077eebbb 100644
--- a/src/components/Select.svelte
+++ b/src/components/Select.svelte
@@ -2,8 +2,9 @@
import IconChevronDown from 'virtual:icons/lucide/chevron-down'
import IconCheck from 'virtual:icons/heroicons-outline/check'
import { clickOutside } from 'svelte-use-click-outside'
- import { onMount, tick } from 'svelte'
+ import { onDestroy, onMount, tick } from 'svelte'
import { debounce } from 'throttle-debounce'
+ import { browser } from '$app/env'
interface Option {
label: string
@@ -129,12 +130,20 @@
}
}
+ const debounced = debounce(100, checkDirection)
+
onMount(() => {
checkDirection()
- const debounced = debounce(100, checkDirection)
window.addEventListener('resize', debounced)
- window.addEventListener('scroll', debounced)
+ document.body.addEventListener('scroll', debounced)
+ })
+
+ onDestroy(() => {
+ if (browser) {
+ window.removeEventListener('resize', debounced)
+ document.body.removeEventListener('scroll', debounced)
+ }
})
diff --git a/src/components/TextInput.svelte b/src/components/TextInput.svelte
index d1fedb962..e7c6856b2 100644
--- a/src/components/TextInput.svelte
+++ b/src/components/TextInput.svelte
@@ -10,13 +10,14 @@
export let id: string = undefined
export let fill = false
export let raised = false
+ export let autofocus = false
{#if multiline}
-
+
{:else}
-
+
{#if icon}
{/if}
diff --git a/src/index.ts b/src/index.ts
index ecf439c42..e35610a2f 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -12,6 +12,8 @@ export { default as CheckboxVirtualList } from './components/CheckboxVirtualList
export { default as Chips } from './components/Chips.svelte'
+export { default as Code } from './components/Code.svelte'
+
export { default as Field } from './components/Field.svelte'
export { default as FileUpload } from './components/FileUpload.svelte'
diff --git a/src/styles/classes/file.postcss b/src/styles/classes/file.postcss
index 7245a9ff7..92fd96512 100644
--- a/src/styles/classes/file.postcss
+++ b/src/styles/classes/file.postcss
@@ -16,8 +16,10 @@
align-items: center;
padding: 0.75rem 1rem;
gap: 1rem;
+ /* Prevents shifting in height when button added */
+ min-height: 3.5rem;
- :global(.icon) {
+ > .icon {
/* Uses `px` to make icons slightly larger */
min-width: 18px;
height: 18px;