Newer
Older
import { convertThemeToColorBlackDefault, convertThemeToColorWhiteDefault } from '@/app/helpers';
label?: string;
iconPos?: 'left' | 'top' | 'right' | 'bottom';
textStyle?: 'bold' | 'italic';
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
border?:
| 'white'
| 'slate'
| 'blue'
| 'sky'
| 'teal'
| 'lime'
| 'green'
| 'yellow'
| 'orange'
| 'pink'
| 'fuchsia'
| 'purple'
| 'indigo'
| 'rose'
| 'red'
| 'black';
size?: 'small' | 'medium' | 'large' | 'extraLarge';
textColor?:
| 'white'
| 'slate'
| 'blue'
| 'sky'
| 'teal'
| 'lime'
| 'green'
| 'yellow'
| 'orange'
| 'pink'
| 'fuchsia'
| 'purple'
| 'indigo'
| 'rose'
| 'red'
| 'black';
theme?:
| 'white'
| 'slate'
| 'blue'
| 'sky'
| 'teal'
| 'lime'
| 'green'
| 'yellow'
| 'orange'
| 'pink'
| 'fuchsia'
| 'purple'
| 'indigo'
| 'rose'
| 'red'
const themeColor = computed(() => convertThemeToColorWhiteDefault(props.theme));
const textColor = computed(() => convertThemeToColorBlackDefault(props.textColor));
const borderColor = computed(() => convertThemeToColorBlackDefault(props.border));
const textSize = computed(() => {
if (!props?.size) return '16px';
switch (props.size) {
case 'small':
return '12px';
case 'medium':
return '16px';
case 'large':
return '20px';
case 'extraLarge':
return '24px';
const buttonPadding = computed(() => {
if (!props?.size) return '0.75rem 0.5rem';
switch (props.size) {
case 'small':
return '0.5rem 0.375rem';
case 'medium':
return '0.75rem 0.5rem';
case 'large':
return '1.2rem 0.8rem';
case 'extraLarge':
return '1.8rem 1.2rem';
}
</script>
<template>
<button
:class="[
'button',
{
'flex-column': iconPos === 'top' || iconPos === 'bottom'
:style="`padding: ${buttonPadding}; border: 1px solid ${borderColor}`"
<span :style="`background-color: ${themeColor}`" class="background"></span>
<span
:class="[
'icon',
{
'order-2': iconPos === 'right' || iconPos === 'bottom'
}
]"
>
<slot name="icon" />
</span>
<span
:style="`color: ${textColor}; font-size: ${textSize}`"
:class="[
'text',
{
bold: textStyle === 'bold',
italic: textStyle === 'italic'
}
]"
>{{ label ?? 'Button' }}</span
>
</button>
</template>
<style scoped>
.button {
position: relative;
border-radius: 5px;
display: flex;
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
align-items: center;
user-select: none;
}
.button:hover .background {
filter: brightness(90%);
}
.background {
width: 100%;
height: 100%;
position: absolute;
z-index: -1;
top: 0;
left: 0;
border-radius: 5px;
transition: filter 0.2s ease-in-out;
}
.icon {
display: flex;
align-items: center;
justify-content: center;
}
.flex-column {
flex-direction: column;
}
.order-2 {
order: 2;
}
.bold {
font-weight: bold;
}
.italic {
font-style: italic;
}
</style>