2021-09-06 21:13:01 +02:00
|
|
|
<template>
|
2021-09-18 01:40:30 +02:00
|
|
|
<button class="icon-btn rounded-md border border-gray-600 flex items-center justify-center h-9 w-9 relative" :disabled="disabled" :class="className" @click="clickBtn">
|
2021-11-06 02:24:02 +01:00
|
|
|
<span :class="outlined ? 'material-icons-outlined' : 'material-icons'" :style="{ fontSize }">{{ icon }}</span>
|
2021-09-06 21:13:01 +02:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
icon: String,
|
2021-09-16 15:37:09 +02:00
|
|
|
disabled: Boolean,
|
|
|
|
bgColor: {
|
|
|
|
type: String,
|
|
|
|
default: 'primary'
|
2021-11-06 02:24:02 +01:00
|
|
|
},
|
|
|
|
outlined: Boolean
|
2021-09-06 21:13:01 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
2021-09-16 15:37:09 +02:00
|
|
|
computed: {
|
|
|
|
className() {
|
|
|
|
var classes = []
|
|
|
|
classes.push(`bg-${this.bgColor}`)
|
|
|
|
return classes.join(' ')
|
2021-10-30 03:42:28 +02:00
|
|
|
},
|
|
|
|
fontSize() {
|
|
|
|
if (this.icon === 'edit') return '1.25rem'
|
|
|
|
return '1.4rem'
|
2021-09-16 15:37:09 +02:00
|
|
|
}
|
|
|
|
},
|
2021-09-06 21:13:01 +02:00
|
|
|
methods: {
|
|
|
|
clickBtn(e) {
|
|
|
|
if (this.disabled) {
|
|
|
|
e.preventDefault()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.$emit('click')
|
|
|
|
e.stopPropagation()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2021-09-18 01:40:30 +02:00
|
|
|
button.icon-btn:disabled {
|
|
|
|
cursor: not-allowed;
|
|
|
|
}
|
2021-09-06 21:13:01 +02:00
|
|
|
button.icon-btn::before {
|
|
|
|
content: '';
|
|
|
|
position: absolute;
|
|
|
|
border-radius: 6px;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background-color: rgba(255, 255, 255, 0);
|
|
|
|
transition: all 0.1s ease-in-out;
|
|
|
|
}
|
|
|
|
button.icon-btn:hover:not(:disabled)::before {
|
|
|
|
background-color: rgba(255, 255, 255, 0.1);
|
|
|
|
}
|
|
|
|
button.icon-btn:disabled::before {
|
|
|
|
background-color: rgba(0, 0, 0, 0.2);
|
|
|
|
}
|
|
|
|
</style>
|