refactor: manually write like 3,000 import statements because i must test my willpower
This commit is contained in:
274 files changed
+1222
-1702
No files matched your search
@@ -1,4 +1,13 @@
|
||||
<script module lang="ts">
|
||||
import { Spinner } from 'mono-svelte'
|
||||
import type { Snippet } from 'svelte'
|
||||
import { type IconSource, Icon } from 'svelte-hero-icons/dist'
|
||||
import type {
|
||||
ClassValue,
|
||||
HTMLAnchorAttributes,
|
||||
HTMLButtonAttributes,
|
||||
} from 'svelte/elements'
|
||||
|
||||
export type ButtonColor = keyof typeof buttonColor
|
||||
export type ButtonAlignment = keyof typeof buttonAlignment
|
||||
export type ButtonShadow = keyof typeof buttonShadow
|
||||
@@ -83,16 +92,6 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type {
|
||||
ClassValue,
|
||||
HTMLAnchorAttributes,
|
||||
HTMLButtonAttributes,
|
||||
} from 'svelte/elements'
|
||||
|
||||
import Spinner from '../loader/Spinner.svelte'
|
||||
import type { Snippet } from 'svelte'
|
||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||
|
||||
let {
|
||||
loading = false,
|
||||
submit = false,
|
||||
@@ -163,7 +162,7 @@
|
||||
-->
|
||||
|
||||
<style>
|
||||
@reference "../../../app.css";
|
||||
@reference "../../../../app.css";
|
||||
|
||||
:global {
|
||||
.btn {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { Disclosure } from 'mono-svelte'
|
||||
import { Minus, Plus, Icon } from 'svelte-hero-icons'
|
||||
import { Icon, Minus, Plus } from 'svelte-hero-icons/dist'
|
||||
import type { ClassValue } from 'svelte/elements'
|
||||
|
||||
interface Props {
|
||||
open?: boolean
|
||||
icon?: boolean
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import Button from '../button/Button.svelte'
|
||||
import { generateID } from '../forms/helper.js'
|
||||
import { Label } from '../index.js'
|
||||
import { Button, Label } from 'mono-svelte'
|
||||
import { generateID } from './helper'
|
||||
|
||||
interface Props {
|
||||
accept?: string
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script module lang="ts">
|
||||
import { Label } from 'mono-svelte'
|
||||
import type { ClassValue, HTMLTextareaAttributes } from 'svelte/elements'
|
||||
import { generateID } from './helper'
|
||||
|
||||
export type Size = keyof typeof sizeClass
|
||||
|
||||
export const sizeClass = {
|
||||
@@ -27,11 +31,6 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { ClassValue, HTMLTextareaAttributes } from 'svelte/elements'
|
||||
|
||||
import Label from '../forms/Label.svelte'
|
||||
import { generateID } from '../forms/helper.js'
|
||||
|
||||
const borderClass = `
|
||||
border border-slate-200 dark:border-zinc-800
|
||||
`
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script module lang="ts">
|
||||
import { Label } from 'mono-svelte'
|
||||
import type { HTMLInputAttributes } from 'svelte/elements'
|
||||
import { generateID } from './helper'
|
||||
|
||||
export type Size = keyof typeof sizeClass
|
||||
export type Shadow = keyof typeof shadowClass
|
||||
|
||||
@@ -34,11 +38,6 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { HTMLInputAttributes } from 'svelte/elements'
|
||||
|
||||
import Label from '../forms/Label.svelte'
|
||||
import { generateID } from '../forms/helper.js'
|
||||
|
||||
const borderClass = `border border-slate-200 border-b-slate-300 dark:border-zinc-800`
|
||||
|
||||
let {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { locale } from '$lib/app/i18n'
|
||||
import { getContext, onDestroy, type Snippet } from 'svelte'
|
||||
import type { IconSource } from 'svelte-hero-icons'
|
||||
import { type Snippet, getContext, onDestroy } from 'svelte'
|
||||
import type { IconSource } from 'svelte-hero-icons/dist'
|
||||
import type { HTMLOptionAttributes } from 'svelte/elements'
|
||||
|
||||
interface Props extends Omit<HTMLOptionAttributes, 'prefix'> {
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
<script lang="ts" module>
|
||||
import { Label, Menu, MenuButton } from 'mono-svelte'
|
||||
import { buttonSize } from 'mono-svelte/button/Button.svelte'
|
||||
import { type Snippet, setContext, tick } from 'svelte'
|
||||
import type { Placement } from 'svelte-floating-ui/dom'
|
||||
import {
|
||||
CheckCircle,
|
||||
ChevronUpDown,
|
||||
Icon,
|
||||
type IconSource,
|
||||
} from 'svelte-hero-icons/dist'
|
||||
import type { Attachment } from 'svelte/attachments'
|
||||
import type { ClassValue, HTMLSelectAttributes } from 'svelte/elements'
|
||||
|
||||
interface Props<T> extends Omit<HTMLSelectAttributes, 'size'> {
|
||||
value?: T | string | undefined
|
||||
placeholder?: string | undefined
|
||||
@@ -33,21 +46,6 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" generics="T">
|
||||
import { setContext, tick, type Snippet } from 'svelte'
|
||||
import type { Placement } from 'svelte-floating-ui/dom'
|
||||
import {
|
||||
CheckCircle,
|
||||
ChevronUpDown,
|
||||
Icon,
|
||||
type IconSource,
|
||||
} from 'svelte-hero-icons'
|
||||
import type { Attachment } from 'svelte/attachments'
|
||||
import type { ClassValue, HTMLSelectAttributes } from 'svelte/elements'
|
||||
import { buttonSize } from '../../button/Button.svelte'
|
||||
import Menu from '../../popover/Menu.svelte'
|
||||
import MenuButton from '../../popover/MenuButton.svelte'
|
||||
import Label from '../Label.svelte'
|
||||
|
||||
let open = $state(false)
|
||||
let element: HTMLSelectElement | undefined = $state()
|
||||
|
||||
@@ -176,7 +174,3 @@
|
||||
{/if}
|
||||
{/each}
|
||||
</Menu>
|
||||
|
||||
<style>
|
||||
@reference '../../../../app.css';
|
||||
</style>
|
||||
@@ -1,14 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { pushState, replaceState } from '$app/navigation'
|
||||
import { page } from '$app/state'
|
||||
import { Button } from 'mono-svelte'
|
||||
import Portal from 'mono-svelte/popover/Portal.svelte'
|
||||
import type { Snippet } from 'svelte'
|
||||
import { XMark } from 'svelte-hero-icons'
|
||||
import { XMark } from 'svelte-hero-icons/dist'
|
||||
import { backOut } from 'svelte/easing'
|
||||
import type { ClassValue } from 'svelte/elements'
|
||||
import { fade, scale } from 'svelte/transition'
|
||||
import { trapFocus } from 'trap-focus-svelte'
|
||||
import { Button } from '../index.js'
|
||||
import Portal from '../popover/Portal.svelte'
|
||||
|
||||
interface Props {
|
||||
action?: string | undefined
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import Button from '../button/Button.svelte'
|
||||
import Modal from '../modal/Modal.svelte'
|
||||
import { Icon } from 'svelte-hero-icons'
|
||||
import { shownModal } from './modal.js'
|
||||
|
||||
let open = $state(false)
|
||||
|
||||
// reactivity hack
|
||||
run(() => {
|
||||
open = $shownModal ? true : false
|
||||
})
|
||||
import { Button, Modal } from 'mono-svelte'
|
||||
import { Icon } from 'svelte-hero-icons/dist'
|
||||
import { shownModal } from './modal'
|
||||
</script>
|
||||
|
||||
{#if $shownModal}
|
||||
@@ -19,7 +9,7 @@
|
||||
title={$shownModal.title}
|
||||
dismissable={$shownModal.dismissable}
|
||||
ondismissed={() => shownModal.set(undefined)}
|
||||
bind:open
|
||||
bind:open={$shownModal}
|
||||
>
|
||||
{#if $shownModal.snippet}
|
||||
{@render $shownModal.snippet()}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { t } from '$lib/app/i18n/translations'
|
||||
import { type Snippet } from 'svelte'
|
||||
import type { IconSource } from 'svelte-hero-icons'
|
||||
import { t } from '$lib/app/i18n'
|
||||
import type { IconSource } from '@xylightdev/svelte-hero-icons'
|
||||
import type { Snippet } from 'svelte'
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
export const shownModal = writable<Modal | undefined>()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { Material } from 'mono-svelte'
|
||||
import { Icon, InformationCircle } from 'svelte-hero-icons/dist'
|
||||
import type { ClassValue } from 'svelte/elements'
|
||||
import { Material } from '../index.js'
|
||||
import { Icon, InformationCircle } from 'svelte-hero-icons'
|
||||
|
||||
interface Props {
|
||||
content?: string | undefined
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
flip,
|
||||
offset,
|
||||
shift,
|
||||
type Middleware,
|
||||
type Placement,
|
||||
type Strategy,
|
||||
} from '@floating-ui/core'
|
||||
import Popover from '../popover/Popover.svelte'
|
||||
flip,
|
||||
offset,
|
||||
shift,
|
||||
} from '@floating-ui/dom'
|
||||
import { Popover } from 'mono-svelte'
|
||||
import type { Snippet } from 'svelte'
|
||||
import type { Attachment } from 'svelte/attachments'
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte'
|
||||
import Button, {
|
||||
import { Button } from 'mono-svelte'
|
||||
import {
|
||||
type ButtonAlignment,
|
||||
type ButtonColor,
|
||||
type ButtonProps,
|
||||
} from '../button/Button.svelte'
|
||||
import { ChevronRight, Icon, type IconSource } from 'svelte-hero-icons'
|
||||
} from 'mono-svelte/button/Button.svelte'
|
||||
import type { Snippet } from 'svelte'
|
||||
import { ChevronRight, Icon, type IconSource } from 'svelte-hero-icons/dist'
|
||||
import type { ClassValue } from 'svelte/elements'
|
||||
|
||||
interface Props extends ButtonProps {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
flip,
|
||||
offset,
|
||||
shift,
|
||||
type Middleware,
|
||||
type Placement,
|
||||
type Strategy,
|
||||
} from '@floating-ui/core'
|
||||
flip,
|
||||
offset,
|
||||
shift,
|
||||
} from '@floating-ui/dom'
|
||||
import { Material } from 'mono-svelte'
|
||||
import { createFloatingActions } from 'svelte-floating-ui'
|
||||
import type { Attachment } from 'svelte/attachments'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { scale } from 'svelte/transition'
|
||||
import { trapFocus } from 'trap-focus-svelte'
|
||||
import { Material } from '../index'
|
||||
import Portal from './Portal.svelte'
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { browser } from '$app/environment'
|
||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte'
|
||||
|
||||
// https://github.com/sveltejs/svelte/issues/3088#issuecomment-505785516
|
||||
import { onMount, onDestroy, createEventDispatcher } from 'svelte'
|
||||
|
||||
let slottedElements = $state<HTMLDivElement>(),
|
||||
portal: HTMLDivElement
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script lang="ts" module>
|
||||
import { Menu, MenuButton, Spinner, TextInput } from 'mono-svelte'
|
||||
import type { TextInputProps } from 'mono-svelte/forms/TextInput.svelte'
|
||||
import { debounce } from 'mono-svelte/util/time'
|
||||
import { Icon, MagnifyingGlass } from 'svelte-hero-icons/dist'
|
||||
|
||||
interface Props<T> extends Omit<TextInputProps, 'onselect' | 'children'> {
|
||||
query?: string
|
||||
selected?: T | undefined
|
||||
@@ -24,11 +29,6 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" generics="T">
|
||||
import type { TextInputProps } from 'mono-svelte/forms/TextInput.svelte'
|
||||
import { Menu, TextInput, Spinner, MenuButton } from '../index.js'
|
||||
import { debounce } from '../util/time.js'
|
||||
import { Icon, MagnifyingGlass } from 'svelte-hero-icons'
|
||||
|
||||
let items: T[] = $state([])
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<script lang="ts">
|
||||
import { Spinner } from '../index.js'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { type Toast, toasts, toastColors } from './toasts.js'
|
||||
import {
|
||||
InformationCircle,
|
||||
ExclamationTriangle,
|
||||
ExclamationCircle,
|
||||
CheckCircle,
|
||||
Icon,
|
||||
XMark,
|
||||
Check,
|
||||
} from 'svelte-hero-icons'
|
||||
import { fly } from 'svelte/transition'
|
||||
import Markdown from '$lib/app/markdown/Markdown.svelte'
|
||||
import { Spinner } from 'mono-svelte'
|
||||
import {
|
||||
Check,
|
||||
CheckCircle,
|
||||
ExclamationCircle,
|
||||
ExclamationTriangle,
|
||||
Icon,
|
||||
InformationCircle,
|
||||
XMark,
|
||||
} from 'svelte-hero-icons/dist'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { type Toast, toastColors, toasts } from './toasts'
|
||||
|
||||
interface Props {
|
||||
toast: Toast
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import Toast from './Toast.svelte'
|
||||
import { flip } from 'svelte/animate'
|
||||
import { toasts } from './toasts.js'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import Toast from './Toast.svelte'
|
||||
import { toasts } from './toasts'
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<script lang="ts" module>
|
||||
import { locale } from '$lib/app/i18n'
|
||||
import { settings } from '$lib/app/settings.svelte'
|
||||
|
||||
export function formatRelativeDate(
|
||||
date: Date,
|
||||
options: Intl.RelativeTimeFormatOptions,
|
||||
locale?: string,
|
||||
relativeTo?: Date,
|
||||
) {
|
||||
try {
|
||||
const now = relativeTo?.getTime() ?? Date.now()
|
||||
|
||||
const diffInMillis = now - date.getTime()
|
||||
|
||||
const thresholds = [
|
||||
{ unit: 'second', threshold: 1000 },
|
||||
{ unit: 'minute', threshold: 60 * 1000 },
|
||||
{ unit: 'hour', threshold: 60 * 60 * 1000 },
|
||||
{ unit: 'day', threshold: 24 * 60 * 60 * 1000 },
|
||||
{ unit: 'week', threshold: 7 * 24 * 60 * 60 * 1000 },
|
||||
{ unit: 'month', threshold: 30 * 24 * 60 * 60 * 1000 },
|
||||
{ unit: 'year', threshold: 365 * 24 * 60 * 60 * 1000 },
|
||||
]
|
||||
|
||||
for (let i = thresholds.length - 1; i >= 0; i--) {
|
||||
if (diffInMillis >= thresholds[i].threshold) {
|
||||
const value = Math.round(diffInMillis / thresholds[i].threshold)
|
||||
|
||||
let language = locale ?? 'en'
|
||||
|
||||
if (settings.absoluteDates) {
|
||||
const rtf = new Intl.DateTimeFormat(language, {
|
||||
...options,
|
||||
timeStyle: 'short',
|
||||
dateStyle: 'short',
|
||||
})
|
||||
return rtf.format(date)
|
||||
} else {
|
||||
const rtf = new Intl.RelativeTimeFormat(language, options)
|
||||
return rtf.format(-value, thresholds[i].unit as 'second')
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'Now'
|
||||
} catch {
|
||||
return 'Invalid Date'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
const toLocaleDateString = (date: Date): string => {
|
||||
try {
|
||||
return date.toLocaleString()
|
||||
} catch {
|
||||
return 'Invalid Date'
|
||||
}
|
||||
}
|
||||
|
||||
interface Props {
|
||||
date: Date
|
||||
relativeTo?: Date | undefined
|
||||
options?: Intl.RelativeTimeFormatOptions
|
||||
style?: string
|
||||
class?: string
|
||||
}
|
||||
|
||||
let {
|
||||
date,
|
||||
relativeTo = undefined,
|
||||
options = {
|
||||
numeric: 'always',
|
||||
style: 'narrow',
|
||||
},
|
||||
style = '',
|
||||
class: clazz = '',
|
||||
}: Props = $props()
|
||||
|
||||
let dateTime = $derived(toLocaleDateString(date))
|
||||
</script>
|
||||
|
||||
<time datetime={dateTime} title={dateTime} class={clazz} {style}>
|
||||
{formatRelativeDate(date, options, $locale, relativeTo)}
|
||||
</time>
|
||||
Reference in new issue
Block a user