paimon-moe/src/components/Input.svelte

36 lines
881 B
Svelte
Raw Normal View History

2020-10-23 19:36:12 +02:00
<script>
import Icon from './Icon.svelte';
2020-10-30 00:44:51 +01:00
export let icon = null;
2020-10-23 19:36:12 +02:00
export let placeholder;
2020-10-30 00:44:51 +01:00
export let type = 'text';
export let min;
export let 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
2020-10-30 00:44:51 +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">
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}
class={`w-full ${icon ? 'pl-12' : 'pl-4'} 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>