Add datetime input

This commit is contained in:
Jon Staab
2024-09-12 16:56:33 -07:00
parent 6d9325dab4
commit 0d53934152
9 changed files with 156 additions and 69 deletions
+36
View File
@@ -0,0 +1,36 @@
<script lang="ts">
import cx from 'classnames'
import {DateInput} from "date-picker-svelte"
import {formatTimestamp} from '@welshman/app'
import Icon from '@lib/components/Icon.svelte'
import Button from '@lib/components/Button.svelte'
export let initialValue: Date | undefined = undefined
export let value: Date | undefined = initialValue
const init = () => {
if (!value) {
value = new Date()
value.setMinutes(0, 0, 0)
}
}
const clear = () => {
value = undefined
}
</script>
<label class="relative">
<DateInput format="yyyy-MM-dd HH:mm" placeholder="" bind:value />
<div class="absolute top-0 h-12 right-2 flex gap-2 items-center cursor-pointer">
{#if value}
<Button on:click={clear} class="h-5">
<Icon icon="close-circle" />
</Button>
{:else}
<Button on:click={init} class="h-5">
<Icon icon="calendar-minimalistic" />
</Button>
{/if}
</div>
</label>
+3 -31
View File
@@ -1,38 +1,10 @@
<script context="module" lang="ts">
import {emitter} from "@app/modal"
const modalHeight = tweened(0, {
duration: 700,
easing: quintOut,
})
emitter.on("close", () => modalHeight.set(0))
</script>
<script lang="ts">
import {onMount} from "svelte"
import {quintOut} from "svelte/easing"
import {tweened} from "svelte/motion"
import {fly} from "@lib/transition"
export let component
export let props = {}
let box: HTMLElement
let content: HTMLElement
let naturalHeight = 0
onMount(() => {
naturalHeight = content.clientHeight + 48
modalHeight.set(naturalHeight)
})
</script>
<div
class="modal-box"
bind:this={box}
style={`height: ${$modalHeight}px`}
class:overflow-hidden={$modalHeight !== naturalHeight}>
<div bind:this={content}>
<svelte:component this={component} {...props} />
</div>
<div class="modal-box" transition:fly={{duration: 100}}>
<svelte:component this={component} {...props} />
</div>