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

101 lines
1.9 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
2021-11-28 11:07:37 +00:00
<template>
2023-05-27 02:35:26 +00: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"></i>
2021-11-28 11:07:37 +00:00
</span>
</a>
2023-05-27 02:35:26 +00: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"></i>
2021-11-28 11:07:37 +00:00
</span>
</MkA>
</div>
</template>
2022-07-25 12:24:37 +00:00
<script lang="ts" setup>
import { } from 'vue';
2021-11-28 11:07:37 +00:00
2022-07-25 12:24:37 +00:00
const props = defineProps<{
to: string;
active?: boolean;
external?: boolean;
2023-05-27 02:38:08 +00:00
behavior?: null | 'window' | 'browser';
2022-07-25 12:24:37 +00:00
inline?: boolean;
}>();
2021-11-28 11:07:37 +00:00
</script>
2023-05-27 02:35:26 +00:00
<style lang="scss" module>
.root {
2021-11-28 11:07:37 +00:00
display: block;
&.inline {
display: inline-block;
}
2023-05-27 02:35:26 +00:00
}
2021-11-28 11:07:37 +00:00
2023-05-27 02:35:26 +00: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 11:07:37 +00:00
2023-05-27 02:35:26 +00:00
&:hover {
text-decoration: none;
background: var(--buttonHoverBg);
}
2021-11-28 11:07:37 +00:00
2023-05-27 02:35:26 +00:00
&.active {
color: var(--accent);
background: var(--buttonHoverBg);
}
}
2021-11-28 11:07:37 +00:00
2023-05-27 02:35:26 +00:00
.icon {
margin-right: 0.75em;
flex-shrink: 0;
text-align: center;
color: var(--fgTransparentWeak);
2021-11-28 11:07:37 +00:00
2023-05-27 02:35:26 +00:00
&:empty {
display: none;
2021-11-28 11:07:37 +00:00
2023-05-27 02:35:26 +00:00
& + .text {
padding-left: 4px;
2021-11-28 11:07:37 +00:00
}
2023-05-27 02:35:26 +00:00
}
}
2021-11-28 11:07:37 +00:00
2023-05-27 02:35:26 +00:00
.text {
flex-shrink: 1;
white-space: normal;
padding-right: 12px;
text-align: center;
}
2021-11-28 11:07:37 +00:00
2023-05-27 02:35:26 +00:00
.suffix {
margin-left: auto;
opacity: 0.7;
white-space: nowrap;
2021-11-28 11:07:37 +00:00
2023-05-27 02:35:26 +00:00
> .suffixText:not(:empty) {
margin-right: 0.75em;
2021-11-28 11:07:37 +00:00
}
}
</style>