Sharkey/packages/frontend/src/components/form/link.vue

96 lines
1.9 KiB
Vue
Raw Normal View History

2021-11-28 12:07:37 +01:00
<template>
2023-05-27 04:35:26 +02:00
<div :class="[$style.root, { [$style.inline]: inline }]">
<a v-if="external" :class="$style.main" class="_button" :href="to" target="_blank">
<span :class="$style.icon"><slot name="icon"></slot></span>
<span :class="$style.text"><slot></slot></span>
<span :class="$style.suffix">
<span :class="$style.suffixText"><slot name="suffix"></slot></span>
<i class="ti ti-external-link" :class="$style.suffixIcon"></i>
2021-11-28 12:07:37 +01:00
</span>
</a>
2023-05-27 04:35:26 +02:00
<MkA v-else :class="[$style.main, { [$style.active]: active }]" class="_button" :to="to" :behavior="behavior">
<span :class="$style.icon"><slot name="icon"></slot></span>
<span :class="$style.text"><slot></slot></span>
<span :class="$style.suffix">
<span :class="$style.suffixText"><slot name="suffix"></slot></span>
<i class="ti ti-chevron-right" :class="$style.suffixIcon"></i>
2021-11-28 12:07:37 +01:00
</span>
</MkA>
</div>
</template>
2022-07-25 14:24:37 +02:00
<script lang="ts" setup>
import { } from 'vue';
2021-11-28 12:07:37 +01:00
2022-07-25 14:24:37 +02:00
const props = defineProps<{
to: string;
active?: boolean;
external?: boolean;
behavior?: null | 'window' | 'browser' | 'modalWindow';
inline?: boolean;
}>();
2021-11-28 12:07:37 +01:00
</script>
2023-05-27 04:35:26 +02:00
<style lang="scss" module>
.root {
2021-11-28 12:07:37 +01:00
display: block;
&.inline {
display: inline-block;
}
2023-05-27 04:35:26 +02:00
}
2021-11-28 12:07:37 +01:00
2023-05-27 04:35:26 +02:00
.main {
display: flex;
align-items: center;
width: 100%;
box-sizing: border-box;
padding: 10px 14px;
background: var(--buttonBg);
border-radius: 6px;
font-size: 0.9em;
2021-11-28 12:07:37 +01:00
2023-05-27 04:35:26 +02:00
&:hover {
text-decoration: none;
background: var(--buttonHoverBg);
}
2021-11-28 12:07:37 +01:00
2023-05-27 04:35:26 +02:00
&.active {
color: var(--accent);
background: var(--buttonHoverBg);
}
}
2021-11-28 12:07:37 +01:00
2023-05-27 04:35:26 +02:00
.icon {
margin-right: 0.75em;
flex-shrink: 0;
text-align: center;
color: var(--fgTransparentWeak);
2021-11-28 12:07:37 +01:00
2023-05-27 04:35:26 +02:00
&:empty {
display: none;
2021-11-28 12:07:37 +01:00
2023-05-27 04:35:26 +02:00
& + .text {
padding-left: 4px;
2021-11-28 12:07:37 +01:00
}
2023-05-27 04:35:26 +02:00
}
}
2021-11-28 12:07:37 +01:00
2023-05-27 04:35:26 +02:00
.text {
flex-shrink: 1;
white-space: normal;
padding-right: 12px;
text-align: center;
}
2021-11-28 12:07:37 +01:00
2023-05-27 04:35:26 +02:00
.suffix {
margin-left: auto;
opacity: 0.7;
white-space: nowrap;
2021-11-28 12:07:37 +01:00
2023-05-27 04:35:26 +02:00
> .suffixText:not(:empty) {
margin-right: 0.75em;
2021-11-28 12:07:37 +01:00
}
}
</style>