-
-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathFlatButton.vue
72 lines (67 loc) · 1.55 KB
/
FlatButton.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<template>
<!-- Use `button` instead of DIV as it is semantically correct and accessibility best-practice -->
<button
v-non-collapsing
type="button"
class="flat-button"
:class="{
disabled,
}"
@click="onClicked"
>
<AppIcon v-if="icon" :icon="icon" />
<span v-if="label">{{ label }}</span>
</button>
</template>
<script lang="ts">
import { defineComponent, type PropType } from 'vue';
import { NonCollapsing } from '@/presentation/components/Scripts/View/Cards/NonCollapsingDirective';
import type { IconName } from '@/presentation/components/Shared/Icon/IconName';
import AppIcon from '@/presentation/components/Shared/Icon/AppIcon.vue';
export default defineComponent({
components: { AppIcon },
directives: { NonCollapsing },
props: {
label: {
type: String,
default: undefined,
required: false,
},
disabled: {
type: Boolean,
default: false,
required: false,
},
icon: {
type: String as PropType<IconName | undefined>,
default: undefined,
required: false,
},
},
emits: [
'click',
],
setup(props, { emit }) {
function onClicked() {
if (props.disabled) {
return;
}
emit('click');
}
return { onClicked };
},
});
</script>
<style lang="scss" scoped>
@use "@/presentation/assets/styles/main" as *;
.flat-button {
display: inline-flex;
gap: $spacing-relative-small;
&.disabled {
@include flat-button($disabled: true);
}
&:not(.disabled) {
@include flat-button($disabled: false);
}
}
</style>