-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathButton.vue
More file actions
38 lines (33 loc) · 1.15 KB
/
Button.vue
File metadata and controls
38 lines (33 loc) · 1.15 KB
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
<template>
<component
:is="as"
:type="as === 'button' ? 'button' : undefined"
:class="buttonClasses"
v-bind="$attrs"
>
<slot />
</component>
</template>
<script setup>
import { computed } from 'vue';
const props = defineProps({
as: {
type: String,
default: 'button',
},
variant: {
type: String,
default: 'primary',
validator: (value) => ['primary', 'secondary'].includes(value),
},
});
const buttonClasses = computed(() => {
const baseClasses =
'inline-flex h-11 cursor-pointer gap-1.5 items-center justify-center rounded-lg px-5! py-2 text-base font-medium no-underline! transition-all! duration-200 not-disabled:hover:-translate-y-0.5 not-disabled:hover:transform not-disabled:hover:shadow-md focus:outline-none disabled:cursor-not-allowed disabled:opacity-60';
if (props.variant === 'secondary') {
return `${baseClasses} bg-soft-bg! text-text1! border border-primary! hover:!bg-primary/10 focus:shadow-[0_0_0_2px_rgba(252,209,90,0.3)]`;
}
// Primary variant (default)
return `${baseClasses} border-none bg-primary! text-[#1e1e1e]! focus:shadow-[0_0_0_2px_rgba(252,209,90,0.3)]`;
});
</script>