paimon-moe-fork/src/components/Input.svelte

37 lines
967 B
Svelte
Raw Normal View History

2020-10-23 18:36:12 +01:00
<script>
import Icon from './Icon.svelte';
2021-01-08 08:30:14 +00:00
export let className = '';
2020-10-29 23:44:51 +00:00
export let icon = null;
2020-11-08 19:57:56 +00:00
export let placeholder = '';
2020-10-29 23:44:51 +00:00
export let type = 'text';
2020-11-08 19:57:56 +00:00
export let min = Math.min();
export let max = Math.max();
2020-10-23 18:36:12 +01:00
export let value = '';
2020-10-29 23:44:51 +00:00
const handleInput = (event) => {
if (type === 'number') {
value = Number(event.target.value);
} else {
value = event.target.value;
}
};
2020-10-23 18:36:12 +01:00
</script>
<div
2021-01-08 08:30:14 +00: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 18:36:12 +01:00
{#if icon}
<Icon path={icon} color="white" className="absolute ml-4 w-6 h-6" />
{/if}
<input
{placeholder}
2020-10-29 23:44:51 +00:00
{type}
{value}
{min}
{max}
on:change
on:input={handleInput}
2021-01-13 07:33:09 +00: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 18:36:12 +01:00
</div>