Spaces:
Running
Running
File size: 4,216 Bytes
8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 8b9f7d9 81046e2 |
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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
<script setup lang="ts">
import type { ModelInfo, StatsResponse, AuthUser } from '../types'
import type { Lang } from '../i18n'
import { t, storeLang } from '../i18n'
import Wc3Button from '../wc3/base/Button.vue'
import { RACE_KEY } from '../wc3/consts'
defineProps<{
models: Record<string, ModelInfo>
stats: StatsResponse
user: AuthUser | null
lang: Lang
}>()
const model = defineModel<string>('model', { required: true })
const showCitations = defineModel<boolean>('showCitations', { required: true })
const race = defineModel<RACE_KEY>('race', { required: true })
const emit = defineEmits<{
'clear-chat': []
'logout': []
'update:lang': [lang: Lang]
}>()
const races = [
{ key: RACE_KEY.HUMAN, label: 'Human' },
{ key: RACE_KEY.ORC, label: 'Orc' },
{ key: RACE_KEY.NIGHT_ELF, label: 'Night Elf' },
{ key: RACE_KEY.UNDEAD, label: 'Undead' },
]
function switchLang(newLang: Lang) {
storeLang(newLang)
emit('update:lang', newLang)
}
</script>
<template>
<div>
<!-- User info -->
<div v-if="user" class="user-badge">
<img v-if="user.picture" :src="user.picture" class="user-avatar" referrerpolicy="no-referrer" alt="" />
<div class="user-info">
<span class="user-name">{{ user.name }}</span>
<button class="logout-btn" @click="emit('logout')">{{ t('sidebar.logout', lang) }}</button>
</div>
</div>
<div v-if="user" class="gold-divider"></div>
<!-- Language -->
<h2>{{ t('sidebar.language', lang) }}</h2>
<div class="lang-switch">
<button
:class="['lang-switch-btn', { active: lang === 'en' }]"
@click="switchLang('en')"
>🇬🇧 English</button>
<button
:class="['lang-switch-btn', { active: lang === 'hr' }]"
@click="switchLang('hr')"
>🇭🇷 Hrvatski</button>
</div>
<div class="gold-divider"></div>
<!-- Model -->
<h2>{{ t('sidebar.selectModel', lang) }}</h2>
<select class="wc3-select" :value="model" @change="model = ($event.target as HTMLSelectElement).value">
<option v-for="(info, key) in models" :key="key" :value="key">
{{ info.name }}
</option>
</select>
<p class="model-caption" v-if="models[model]">
{{ models[model].description }}
</p>
<div class="gold-divider"></div>
<!-- Theme -->
<h2>{{ t('sidebar.theme', lang) }}</h2>
<select class="wc3-select" :value="race" @change="race = ($event.target as HTMLSelectElement).value as RACE_KEY">
<option v-for="r in races" :key="r.key" :value="r.key">
{{ r.label }}
</option>
</select>
<div class="gold-divider"></div>
<!-- Options -->
<h2>{{ t('sidebar.options', lang) }}</h2>
<label class="wc3-checkbox">
<input type="checkbox" :checked="showCitations" @change="showCitations = ($event.target as HTMLInputElement).checked" />
{{ t('sidebar.showSources', lang) }}
</label>
<div style="margin-top: 0.75rem; height: 32px; min-width: 100%;">
<Wc3Button size="s" @click="emit('clear-chat')">
{{ t('sidebar.newChat', lang) }}
</Wc3Button>
</div>
<div class="gold-divider"></div>
<!-- Stats -->
<h2>{{ t('sidebar.knowledgeBase', lang) }}</h2>
<div class="resource-bar">
{{ stats.documents.toLocaleString() }} {{ t('sidebar.documents', lang) }}
</div>
<!-- Footer -->
<div class="sidebar-footer">
<div class="gold-divider"></div>
Learn Pathophysiology<br>
Powered by Gemini AI
</div>
</div>
</template>
<style scoped>
.lang-switch {
display: flex;
gap: 0.4rem;
}
.lang-switch-btn {
flex: 1;
background: linear-gradient(180deg, #1a1a32, #13132a);
border: 1px solid var(--wc3-border-dim, #3a2e1e);
border-radius: 3px;
color: var(--wc3-text-dim, #7a6e5a);
font-family: var(--font-body, 'Crimson Text', serif);
font-size: 0.85rem;
padding: 0.4rem 0.5rem;
cursor: pointer;
transition: all 0.15s;
}
.lang-switch-btn:hover {
border-color: var(--wc3-gold-dim, #8b7b4f);
color: var(--wc3-text, #d4c4a0);
}
.lang-switch-btn.active {
border-color: var(--wc3-gold, #c8aa6e);
color: var(--wc3-gold, #c8aa6e);
background: rgba(200, 170, 110, 0.08);
}
</style>
|