blob: d8ae52482e95ecd896776950ca6488a6e820c9de (
plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<div :class="$style.tabsRoot">
<button
v-for="option in tabs"
:key="option.key"
:class="['_button', $style.tabButton, { [$style.active]: modelValue === option.key }]"
:disabled="modelValue === option.key"
@click="update(option.key)"
>
<i v-if="option.icon" :class="[option.icon, $style.icon]"></i>
{{ option.label }}
</button>
</div>
</template>
<script lang="ts">
export type Tab<T = string> = {
key: T;
icon?: string;
label?: string;
};
</script>
<script setup lang="ts" generic="const T extends Tab">
import { defineProps, defineEmits } from 'vue';
defineProps<{
tabs: T[];
}>();
const model = defineModel<T['key']>();
function update(key: T['key']) {
model.value = key;
}
</script>
<style module lang="scss">
.tabsRoot {
display: flex;
font-size: 90%;
}
.tabButton {
flex: 1;
padding: 10px 8px;
border-radius: 999px;
&:disabled {
opacity: 1 !important;
cursor: default;
}
&.active {
color: var(--MI_THEME-accent);
background: var(--MI_THEME-accentedBg);
}
&:not(.active):hover {
color: var(--MI_THEME-fgHighlighted);
background: var(--MI_THEME-panelHighlight);
}
&:not(:first-child) {
margin-left: 8px;
}
> .icon {
margin-right: 6px;
}
}
@container (max-width: 500px) {
.tabsRoot {
font-size: 80%;
}
.tabButton {
padding: 11px 8px;
}
}
</style>
|