2
0
mirror of https://github.com/frappe/books.git synced 2025-02-11 00:18:45 +00:00
books/src/components/Button.vue
18alantom 06f981163d refactor: use typed injections
- use contextual shortcuts
- type Sidebar.vue, App.vue, ListView.vue
- improve types for search.ts
2023-03-27 00:27:00 -07:00

65 lines
1.2 KiB
Vue

<template>
<button
class="
focus:outline-none
rounded-md
flex
justify-center
items-center
text-sm
"
:class="_class"
v-bind="$attrs"
>
<slot></slot>
</button>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
name: 'Button',
props: {
type: {
type: String,
default: 'secondary',
},
icon: {
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
padding: {
type: Boolean,
default: true,
},
background: {
type: Boolean,
default: true,
},
},
computed: {
_class() {
return {
'opacity-50 cursor-not-allowed pointer-events-none': this.disabled,
'text-white': this.type === 'primary',
'bg-blue-500': this.type === 'primary' && this.background,
'text-gray-700': this.type !== 'primary',
'bg-gray-200': this.type !== 'primary' && this.background,
'h-8': this.background,
'px-3': this.padding && this.icon,
'px-6': this.padding && !this.icon,
};
},
},
});
</script>
<style scoped>
button:focus {
filter: brightness(0.95);
}
</style>