Lib: Move form stuff into form/ directory
This commit is contained in:
@ -22,8 +22,8 @@
|
|||||||
/** Make the button act as a link. */
|
/** Make the button act as a link. */
|
||||||
href?: string | undefined;
|
href?: string | undefined;
|
||||||
|
|
||||||
/** Add the "w-full" class to the button. */
|
/** Add a width class to the button. */
|
||||||
fullwidth?: boolean;
|
width?: string;
|
||||||
|
|
||||||
/** Enable the button's ":hover" state manually. */
|
/** Enable the button's ":hover" state manually. */
|
||||||
activate?: boolean;
|
activate?: boolean;
|
||||||
@ -40,7 +40,7 @@
|
|||||||
color = undefined,
|
color = undefined,
|
||||||
submit = false,
|
submit = false,
|
||||||
href = undefined,
|
href = undefined,
|
||||||
fullwidth = false,
|
width = "w-auto",
|
||||||
activate = false,
|
activate = false,
|
||||||
activate_href = false,
|
activate_href = false,
|
||||||
trigger_popup = { event: "click", target: "invalid" },
|
trigger_popup = { event: "click", target: "invalid" },
|
||||||
@ -53,9 +53,9 @@
|
|||||||
<form action={href} class="contents">
|
<form action={href} class="contents">
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="btn m-0 select-none px-2 py-2 {color ? `variant-filled-${color}` : ''} {fullwidth
|
class="btn m-0 select-none px-2 py-2 {color
|
||||||
? 'w-full'
|
? `variant-filled-${color}`
|
||||||
: 'w-auto'} {activate ? 'btn-hover' : ''} {activate_href && is_at_path(href)
|
: ''} {width} {activate ? 'btn-hover' : ''} {activate_href && is_at_path(href)
|
||||||
? 'btn-hover'
|
? 'btn-hover'
|
||||||
: ''}"
|
: ''}"
|
||||||
draggable="false"
|
draggable="false"
|
||||||
@ -65,9 +65,9 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<button
|
<button
|
||||||
type={submit ? "submit" : "button"}
|
type={submit ? "submit" : "button"}
|
||||||
class="btn select-none px-2 py-2 {color ? `variant-filled-${color}` : ''} {fullwidth
|
class="btn select-none px-2 py-2 {color ? `variant-filled-${color}` : ''} {width} {activate
|
||||||
? 'w-full'
|
? 'btn-hover'
|
||||||
: 'w-auto'} {activate ? 'btn-hover' : ''}"
|
: ''}"
|
||||||
draggable="false"
|
draggable="false"
|
||||||
use:popup={trigger_popup}
|
use:popup={trigger_popup}
|
||||||
{...restProps}>{@render children()}</button
|
{...restProps}>{@render children()}</button
|
||||||
@ -4,24 +4,7 @@
|
|||||||
import type { Action } from "svelte/action";
|
import type { Action } from "svelte/action";
|
||||||
import type { HTMLInputAttributes } from "svelte/elements";
|
import type { HTMLInputAttributes } from "svelte/elements";
|
||||||
import { v4 as uuid } from "uuid";
|
import { v4 as uuid } from "uuid";
|
||||||
import LazyImage from "./LazyImage.svelte";
|
import { type LazyDropdownOption, LazyImage } from "$lib/components";
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface LazyDropdownProps extends HTMLInputAttributes {
|
interface LazyDropdownProps extends HTMLInputAttributes {
|
||||||
children: Snippet;
|
children: Snippet;
|
||||||
16
src/lib/components/form/LazyDropdown.ts
Normal file
16
src/lib/components/form/LazyDropdown.ts
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user