refactor to UI components

This commit is contained in:
2023-05-26 01:44:20 +02:00
parent 9ca0bba526
commit 87729c9c00
13 changed files with 112 additions and 36 deletions

View File

@@ -0,0 +1,46 @@
<script setup lang="ts">
interface Props {
modelValue?: any
size?: 'xs' | 'sm' | 'md' | 'lg'
color?: 'regular' | 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'
}
const props = withDefaults(defineProps<Props>(), {
size: 'md',
color: 'regular'
})
const emit = defineEmits<{
'update:modelValue': [value: any]
}>()
const styleClass = computed(() => {
const sizeVariants = {
xs: 'dui-input-xs',
sm: 'dui-input-sm',
md: 'dui-input-md',
lg: 'dui-input-lg'
}
const colorVariants = {
regular: '',
primary: 'dui-input-primary',
secondary: 'dui-input-secondary',
info: 'dui-input-info',
success: 'dui-input-success',
warning: 'dui-input-warning',
error: 'dui-input-error'
}
const sizeClass = sizeVariants[props.size]
const colorClass = colorVariants[props.color]
return [sizeClass, colorClass]
})
</script>
<template>
<input
type="text"
:value="props.modelValue"
@input="emit('update:modelValue', ($event.target as HTMLInputElement)?.value)"
class="dui-input-bordered dui-input my-1 ml-auto mr-1 max-w-xs flex-grow"
:class="styleClass"
/>
</template>