paimon-moe/src/components/Input.svelte

37 lines
967 B
Svelte
Raw Normal View History

2020-10-23 19:36:12 +02:00
<script>
import Icon from './Icon.svelte';
2021-01-08 09:30:14 +01:00
export let className = '';
2020-10-30 00:44:51 +01:00
export let icon = null;
2020-11-08 20:57:56 +01:00
export let placeholder = '';
2020-10-30 00:44:51 +01:00
export let type = 'text';
2020-11-08 20:57:56 +01:00
export let min = Math.min();
export let max = Math.max();
2020-10-23 19:36:12 +02:00
export let value = '';
2020-10-30 00:44:51 +01:00
const handleInput = (event) => {
if (type === 'number') {
value = Number(event.target.value);
} else {
value = event.target.value;
}
};
2020-10-23 19:36:12 +02:00
</script>
<div
2021-01-08 09:30:14 +01:00
class={`flex flex-1 relative items-center bg-background rounded-2xl h-14 focus-within:border-primary border-2 border-transparent ease-in duration-100 ${className}`}>
2020-10-23 19:36:12 +02:00
{#if icon}
<Icon path={icon} color="white" className="absolute ml-4 w-6 h-6" />
{/if}
<input
{placeholder}
2020-10-30 00:44:51 +01:00
{type}
{value}
{min}
{max}
on:change
on:input={handleInput}
2021-01-13 08:33:09 +01:00
class={`w-full ${icon ? 'pl-12' : 'pl-4'} min-h-full pr-4 text-white placeholder-gray-500 leading-none bg-transparent border-none focus:outline-none`} />
2020-10-23 19:36:12 +02:00
</div>