mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
feat: add customizable skin support
This commit is contained in:
1 parent
0ea85752fd
commit
2b7e908d31
33 files changed
+3645
-494
No files matched your search
@@ -239,40 +239,40 @@ onUnmounted(() => document.removeEventListener("pointerdown", onDocumentPointerD
|
||||
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||
}
|
||||
|
||||
:global(html[data-theme="dark"]) .language-trigger,
|
||||
:global(:root[data-theme="dark"]) .language-trigger {
|
||||
:global(html[data-theme="dark"] .admin-root) .language-trigger,
|
||||
:global(:root[data-theme="dark"] .admin-root) .language-trigger {
|
||||
color: #a9d9d1;
|
||||
background: #203531;
|
||||
border-color: #38564f;
|
||||
}
|
||||
|
||||
:global(html[data-theme="dark"]) .language-trigger:hover,
|
||||
:global(html[data-theme="dark"]) .language-switcher.open .language-trigger,
|
||||
:global(:root[data-theme="dark"]) .language-trigger:hover,
|
||||
:global(:root[data-theme="dark"]) .language-switcher.open .language-trigger {
|
||||
:global(html[data-theme="dark"] .admin-root) .language-trigger:hover,
|
||||
:global(html[data-theme="dark"] .admin-root) .language-switcher.open .language-trigger,
|
||||
:global(:root[data-theme="dark"] .admin-root) .language-trigger:hover,
|
||||
:global(:root[data-theme="dark"] .admin-root) .language-switcher.open .language-trigger {
|
||||
color: #10201d;
|
||||
background: #69d2c7;
|
||||
border-color: #69d2c7;
|
||||
}
|
||||
|
||||
:global(html[data-theme="dark"]) .language-dropdown,
|
||||
:global(:root[data-theme="dark"]) .language-dropdown {
|
||||
:global(html[data-theme="dark"] .admin-root) .language-dropdown,
|
||||
:global(:root[data-theme="dark"] .admin-root) .language-dropdown {
|
||||
background: #172321;
|
||||
border-color: #30413d;
|
||||
box-shadow: 0 16px 36px rgba(0, 0, 0, .32);
|
||||
}
|
||||
|
||||
:global(html[data-theme="dark"]) .language-option,
|
||||
:global(:root[data-theme="dark"]) .language-option {
|
||||
:global(html[data-theme="dark"] .admin-root) .language-option,
|
||||
:global(:root[data-theme="dark"] .admin-root) .language-option {
|
||||
color: #d7e7e3;
|
||||
}
|
||||
|
||||
:global(html[data-theme="dark"]) .language-option:hover,
|
||||
:global(html[data-theme="dark"]) .language-option:focus-visible,
|
||||
:global(html[data-theme="dark"]) .language-option.selected,
|
||||
:global(:root[data-theme="dark"]) .language-option:hover,
|
||||
:global(:root[data-theme="dark"]) .language-option:focus-visible,
|
||||
:global(:root[data-theme="dark"]) .language-option.selected {
|
||||
:global(html[data-theme="dark"] .admin-root) .language-option:hover,
|
||||
:global(html[data-theme="dark"] .admin-root) .language-option:focus-visible,
|
||||
:global(html[data-theme="dark"] .admin-root) .language-option.selected,
|
||||
:global(:root[data-theme="dark"] .admin-root) .language-option:hover,
|
||||
:global(:root[data-theme="dark"] .admin-root) .language-option:focus-visible,
|
||||
:global(:root[data-theme="dark"] .admin-root) .language-option.selected {
|
||||
color: #69d2c7;
|
||||
background: #203531;
|
||||
border-color: #38564f;
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
<template>
|
||||
<div ref="root" class="skin-switcher" :class="{ open }" @keydown.esc="close">
|
||||
<button
|
||||
type="button"
|
||||
class="skin-trigger"
|
||||
:aria-label="menuLabel"
|
||||
:title="`${menuLabel}: ${selectedOption.label}`"
|
||||
aria-haspopup="listbox"
|
||||
:aria-expanded="open"
|
||||
:aria-controls="menuId"
|
||||
@click.stop="toggle"
|
||||
>
|
||||
<Icon :name="selectedOption.icon || 'compass'" :size="15" />
|
||||
<span>{{ menuLabel }}</span>
|
||||
<Icon name="chevron-down" :size="12" />
|
||||
</button>
|
||||
|
||||
<div v-if="open" :id="menuId" class="skin-dropdown" role="listbox" :aria-label="menuLabel" @click.stop>
|
||||
<button
|
||||
v-for="option in options"
|
||||
:key="option.value"
|
||||
type="button"
|
||||
class="skin-option"
|
||||
:class="{ selected: modelValue === option.value }"
|
||||
role="option"
|
||||
:aria-selected="modelValue === option.value"
|
||||
@click="select(option.value)"
|
||||
>
|
||||
<Icon :name="option.icon || 'compass'" :size="16" />
|
||||
<span>{{ option.label }}</span>
|
||||
<Icon v-if="modelValue === option.value" name="check" :size="14" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
||||
import Icon from "./Icon.vue";
|
||||
|
||||
export interface SkinOption {
|
||||
value: string;
|
||||
label: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: string;
|
||||
menuLabel: string;
|
||||
options: SkinOption[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:modelValue": [value: string];
|
||||
change: [value: string];
|
||||
}>();
|
||||
|
||||
const options = computed(() => props.options);
|
||||
const selectedOption = computed(() => options.value.find((option) => option.value === props.modelValue) ?? options.value[0]);
|
||||
const root = ref<HTMLElement | null>(null);
|
||||
const open = ref(false);
|
||||
const menuId = `skin-menu-${Math.random().toString(36).slice(2, 9)}`;
|
||||
|
||||
function toggle() { open.value = !open.value; }
|
||||
function close() { open.value = false; }
|
||||
function select(value: string) {
|
||||
emit("update:modelValue", value);
|
||||
emit("change", value);
|
||||
close();
|
||||
}
|
||||
function onDocumentPointerDown(event: PointerEvent) {
|
||||
if (root.value && !root.value.contains(event.target as Node)) close();
|
||||
}
|
||||
|
||||
onMounted(() => document.addEventListener("pointerdown", onDocumentPointerDown));
|
||||
onUnmounted(() => document.removeEventListener("pointerdown", onDocumentPointerDown));
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.skin-switcher {
|
||||
position: relative;
|
||||
z-index: 20;
|
||||
flex: 0 0 auto;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.skin-trigger {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 5px;
|
||||
min-width: 34px;
|
||||
min-height: 32px;
|
||||
padding: 0 8px;
|
||||
color: var(--accent);
|
||||
background: color-mix(in srgb, var(--accent) 8%, var(--surface-1));
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
font: inherit;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
transition: color .16s, background .16s, border-color .16s;
|
||||
}
|
||||
|
||||
.skin-trigger:hover,
|
||||
.skin-switcher.open .skin-trigger {
|
||||
color: var(--accent);
|
||||
background: color-mix(in srgb, var(--accent) 14%, var(--surface-1));
|
||||
border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
|
||||
}
|
||||
|
||||
.skin-trigger > .ui-icon:last-child { margin-left: 1px; }
|
||||
|
||||
.skin-dropdown {
|
||||
position: absolute;
|
||||
top: calc(100% + 7px);
|
||||
right: 0;
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
min-width: 176px;
|
||||
padding: 6px;
|
||||
background: var(--surface-1);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 11px;
|
||||
box-shadow: 0 14px 32px color-mix(in srgb, var(--text-primary) 16%, transparent);
|
||||
}
|
||||
|
||||
.skin-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
min-height: 36px;
|
||||
padding: 0 9px;
|
||||
color: var(--text-primary);
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 7px;
|
||||
font: inherit;
|
||||
font-size: 11px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.skin-option > .ui-icon:first-child { color: var(--text-muted); }
|
||||
.skin-option > .ui-icon:last-child { margin-left: auto; color: var(--accent); }
|
||||
.skin-option:hover,
|
||||
.skin-option:focus-visible,
|
||||
.skin-option.selected {
|
||||
color: var(--accent);
|
||||
background: color-mix(in srgb, var(--accent) 10%, var(--surface-1));
|
||||
border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
|
||||
}
|
||||
|
||||
@media (max-width: 520px) {
|
||||
.skin-trigger { min-height: 36px; }
|
||||
.skin-dropdown { min-width: 190px; }
|
||||
}
|
||||
|
||||
.skin-switcher.mobile-skin-switcher .skin-trigger {
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
justify-content: flex-start;
|
||||
padding-inline: 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 420px) {
|
||||
.skin-switcher.join-skin-switcher .skin-trigger {
|
||||
width: 28px;
|
||||
min-width: 28px;
|
||||
min-height: 28px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.skin-switcher.join-skin-switcher .skin-trigger > span,
|
||||
.skin-switcher.join-skin-switcher .skin-trigger > .ui-icon:last-child { display: none; }
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user