Lib: Move form stuff into form/ directory

This commit is contained in:
2024-12-18 14:59:55 +01:00
parent 68d9d7e60d
commit 05e32b5ffb
5 changed files with 26 additions and 27 deletions

View File

@ -22,8 +22,8 @@
/** Make the button act as a link. */
href?: string | undefined;
/** Add the "w-full" class to the button. */
fullwidth?: boolean;
/** Add a width class to the button. */
width?: string;
/** Enable the button's ":hover" state manually. */
activate?: boolean;
@ -40,7 +40,7 @@
color = undefined,
submit = false,
href = undefined,
fullwidth = false,
width = "w-auto",
activate = false,
activate_href = false,
trigger_popup = { event: "click", target: "invalid" },
@ -53,9 +53,9 @@
<form action={href} class="contents">
<button
type="submit"
class="btn m-0 select-none px-2 py-2 {color ? `variant-filled-${color}` : ''} {fullwidth
? 'w-full'
: 'w-auto'} {activate ? 'btn-hover' : ''} {activate_href && is_at_path(href)
class="btn m-0 select-none px-2 py-2 {color
? `variant-filled-${color}`
: ''} {width} {activate ? 'btn-hover' : ''} {activate_href && is_at_path(href)
? 'btn-hover'
: ''}"
draggable="false"
@ -65,9 +65,9 @@
{:else}
<button
type={submit ? "submit" : "button"}
class="btn select-none px-2 py-2 {color ? `variant-filled-${color}` : ''} {fullwidth
? 'w-full'
: 'w-auto'} {activate ? 'btn-hover' : ''}"
class="btn select-none px-2 py-2 {color ? `variant-filled-${color}` : ''} {width} {activate
? 'btn-hover'
: ''}"
draggable="false"
use:popup={trigger_popup}
{...restProps}>{@render children()}</button

View File

@ -4,24 +4,7 @@
import type { Action } from "svelte/action";
import type { HTMLInputAttributes } from "svelte/elements";
import { v4 as uuid } from "uuid";
import LazyImage from "./LazyImage.svelte";
export interface LazyDropdownOption {
/** The label displayed in the list of options. */
label: string;
/** The value assigned to the dropdown value variable */
value: string;
/** An optional icon displayed left to the label */
icon_url?: string;
/** The aspect ratio width of the optional icon */
icon_width?: number;
/** The aspect ratio height of the optional icon */
icon_height?: number;
}
import { type LazyDropdownOption, LazyImage } from "$lib/components";
interface LazyDropdownProps extends HTMLInputAttributes {
children: Snippet;

View File

@ -0,0 +1,16 @@
export interface LazyDropdownOption {
/** The label displayed in the list of options. */
label: string;
/** The value assigned to the dropdown value variable */
value: string;
/** An optional icon displayed left to the label */
icon_url?: string;
/** The aspect ratio width of the optional icon */
icon_width?: number;
/** The aspect ratio height of the optional icon */
icon_height?: number;
}