169 lines
3.2 KiB
Vue
169 lines
3.2 KiB
Vue
<template>
|
|
<div class="ui-button">
|
|
<Button
|
|
:class="buttonClasses"
|
|
:style="buttonStyle"
|
|
:disabled="disabled"
|
|
:loading="loading"
|
|
:label="buttonLabel"
|
|
:size="size"
|
|
:severity="severity"
|
|
:outlined="outlined"
|
|
:text="text"
|
|
:raised="raised"
|
|
:rounded="rounded"
|
|
:link="link"
|
|
:plain="plain"
|
|
:pt="pt"
|
|
@click="handleClick"
|
|
>
|
|
<template v-if="icon && iconPosition === 'start'" #icon>
|
|
<i :class="[icon, iconClass]" class="ui-button-icon"></i>
|
|
</template>
|
|
|
|
<template v-if="icon && iconPosition === 'end'" #default>
|
|
{{ label }}
|
|
<i :class="[icon, iconClass]" class="ui-button-icon-end"></i>
|
|
</template>
|
|
|
|
<slot />
|
|
</Button>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { computed } from 'vue'
|
|
import Button from 'primevue/button'
|
|
|
|
const props = defineProps({
|
|
label: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
icon: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
icon: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
iconPosition: {
|
|
type: String,
|
|
default: 'start',
|
|
validator: (value) => ['start', 'end'].includes(value)
|
|
},
|
|
iconClass: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
size: {
|
|
type: String,
|
|
default: 'default',
|
|
validator: (value) => ['small', 'default', 'large'].includes(value)
|
|
},
|
|
severity: {
|
|
type: String,
|
|
default: 'primary',
|
|
validator: (value) => ['primary', 'secondary', 'success', 'info', 'warning', 'danger', 'dominant'].includes(value)
|
|
},
|
|
variant: {
|
|
type: String,
|
|
default: 'filled',
|
|
validator: (value) => ['filled', 'outlined', 'text', 'link', 'plain'].includes(value)
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
loading: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
outlined: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
text: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
raised: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
rounded: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
link: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
plain: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
fullWidth: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
height: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
pt: {
|
|
type: Object,
|
|
default: () => ({})
|
|
}
|
|
})
|
|
|
|
const emit = defineEmits(['click'])
|
|
|
|
const buttonClasses = computed(() => {
|
|
const classes = []
|
|
|
|
if (props.fullWidth) {
|
|
classes.push('ui-button--full-width')
|
|
}
|
|
|
|
if (props.severity === 'dominant') {
|
|
classes.push('ui-button--dominant')
|
|
}
|
|
if (props.severity === 'secondary') {
|
|
classes.push('!font-[600] !text-[11px] !rounded-[6px]')
|
|
}
|
|
if (props.severity === 'success') {
|
|
classes.push('ui-button--success !font-[600] !text-[11px] !rounded-[6px]')
|
|
}
|
|
if (props.severity === 'danger') {
|
|
classes.push('!font-[600] !text-[11px] !rounded-[6px]')
|
|
}
|
|
|
|
return classes.join(' ')
|
|
})
|
|
|
|
const buttonLabel = computed(() => {
|
|
if (props.icon && props.iconPosition === 'end') {
|
|
return ''
|
|
}
|
|
return props.label
|
|
})
|
|
|
|
const buttonStyle = computed(() => {
|
|
const style = {}
|
|
|
|
if (props.height) {
|
|
style.height = props.height
|
|
}
|
|
|
|
return style
|
|
})
|
|
|
|
const handleClick = (event) => {
|
|
emit('click', event)
|
|
}
|
|
</script>
|
|
|
|
|