aboutsummaryrefslogtreecommitdiffstats
path: root/components/Control/Button.vue
blob: efd91c2c709bee58422e7f0a83e698190b506770 (plain)
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
73
74
75
76
77
78
79
80
81
82
<script setup lang="ts">
const props = defineProps({
  type: {
    type: String,
    required: false,    
    default: 'text',
  },
  label: String,
  icon: Array<String>,
  disabled: Boolean,
});

const emit = defineEmits(['click']);

const onClick = (event: MouseEvent) => {
  if (!props.disabled) {
    emit('click', event);
  }
};
</script>

<template>
  <a id="button" :class="{text: type === 'text', solid: type === 'solid', disabled: disabled}" @click.stop="onClick">
    <font-awesome-icon :icon="icon" />
    {{ label }}
  </a>
</template>

<style scoped>
#button {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  user-select: none;
}
    
.text {
  background-color: transparent;
  color: var(--color-text-primary);
  transition: color 0.3s;
  font-weight: 700;
  cursor: pointer;
  
  &.disabled {
    color: var(--color-text-mute);
    cursor: not-allowed;
  }
  
  &:hover {
    color: var(--color-primary-dark);
  }
  
  &.disabled:hover {
    color: var(--color-text-mute);
  }
}

.solid {
  background-color: var(--color-primary);
  transition: background-color 0.3s;
  color: var(--color-text);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
  
  &.disabled {
    background-color: var(--color-border);
    color: var(--color-text-mute);
    cursor: not-allowed;
  }
  
  &:hover {
    background-color: var(--color-primary-dark);
  }
  
  &.disabled:hover {
    background-color: var(--color-border);
  }
}

</style>