mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-07 06:47:13 -04:00
50 lines
1,008 B
Vue
50 lines
1,008 B
Vue
![]() |
<template>
|
||
|
<component :is="tag" :href="href ?? to" class="c-link" :to="to">
|
||
|
<slot />
|
||
|
</component>
|
||
|
</template>
|
||
|
|
||
|
<script lang="ts" setup>
|
||
|
import { RouterLink, type RouteLocationRaw } from 'vue-router';
|
||
|
import { useTheme } from './c-link.theme';
|
||
|
|
||
|
const props = defineProps<{
|
||
|
href?: string;
|
||
|
to?: RouteLocationRaw;
|
||
|
}>();
|
||
|
|
||
|
const { href, to } = toRefs(props);
|
||
|
|
||
|
const theme = useTheme();
|
||
|
const tag = computed(() => (href?.value ? 'a' : RouterLink));
|
||
|
</script>
|
||
|
|
||
|
<style lang="less" scoped>
|
||
|
.c-link {
|
||
|
line-height: inherit;
|
||
|
font-family: inherit;
|
||
|
font-size: inherit;
|
||
|
border: none;
|
||
|
cursor: pointer;
|
||
|
text-decoration: none;
|
||
|
font-weight: 400;
|
||
|
color: v-bind('theme.default.textColor');
|
||
|
border-radius: 4px;
|
||
|
transition: color cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
|
||
|
|
||
|
outline-offset: 1px;
|
||
|
|
||
|
&:hover {
|
||
|
color: v-bind('theme.default.hover.textColor');
|
||
|
}
|
||
|
|
||
|
&:active {
|
||
|
color: v-bind('theme.default.textColor');
|
||
|
}
|
||
|
|
||
|
&:focus {
|
||
|
color: v-bind('theme.default.outline.color');
|
||
|
}
|
||
|
}
|
||
|
</style>
|