First version running with npm run dev

This commit is contained in:
pascalyazid committed 2026-03-11 15:11:57 +00:00
commit f90ec06a4f
28 files changed
+12042

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
<script setup lang="ts">
import { useLanguages } from "~/composables/useLanguages";
interface Props {
label?: string;
modelValue: string;
}
const props = defineProps<Props>();
const emit = defineEmits<{
(e: "update:modelValue", value: string): void;
}>();
const { languages } = useLanguages();
</script>
<template>
<div class="language-selector">
<label v-if="props.label" class="language-selector-label">
{{ props.label }}
</label>
<select
class="language-selector-input select"
:value="props.modelValue"
@change="
emit('update:modelValue', ($event.target as HTMLSelectElement).value)
"
>
<option v-for="lang in languages" :key="lang.code" :value="lang.code">
{{ lang.name }}
</option>
</select>
</div>
</template>
<style scoped>
.language-selector {
display: flex;
flex-direction: column;
flex: 1;
min-width: 150px;
}
.language-selector-label {
margin-bottom: 0.25rem;
font-size: 0.875rem;
font-weight: 500;
}
.language-selector-input {
padding: 0.5rem;
font-size: 0.875rem;
}
</style>
+322
View File
@@ -0,0 +1,322 @@
<script setup lang="ts">
interface Props {
visible: boolean;
currentModel: string;
}
const props = defineProps<Props>();
const emit = defineEmits<{
(e: "update:visible", value: boolean): void;
(e: "update:currentModel", value: string): void;
}>();
const MODEL_OPTIONS = [
{
value: "translategemma:1b",
label: "TranslateGemma 1B",
description: "Faster, lower quality (~2GB VRAM)",
},
{
value: "translategemma:2b",
label: "TranslateGemma 2B",
description: "Balanced speed/quality (~3GB VRAM)",
},
{
value: "translategemma:4b",
label: "TranslateGemma 4B",
description: "Best quality (~4GB VRAM)",
},
];
const selectedModel = ref(props.currentModel);
watch(
() => props.currentModel,
(val) => {
selectedModel.value = val;
},
);
watch(
() => props.visible,
(val) => {
if (val) {
selectedModel.value = props.currentModel;
}
},
);
function save() {
emit("update:currentModel", selectedModel.value);
close();
}
function close() {
emit("update:visible", false);
}
function handleOverlayClick(event: MouseEvent) {
if ((event.target as HTMLElement).classList.contains("settings-overlay")) {
close();
}
}
function handleKeydown(event: KeyboardEvent) {
if (event.key === "Escape") {
close();
}
}
onMounted(() => {
document.addEventListener("keydown", handleKeydown);
});
onUnmounted(() => {
document.removeEventListener("keydown", handleKeydown);
});
</script>
<template>
<Teleport to="body">
<Transition name="modal">
<div v-if="visible" class="settings-overlay" @click="handleOverlayClick">
<div
class="settings-modal"
role="dialog"
aria-modal="true"
aria-label="Settings"
>
<div class="settings-header">
<h2 class="settings-title">Settings</h2>
<button
class="settings-close"
@click="close"
type="button"
aria-label="Close settings"
>
&#10005;
</button>
</div>
<div class="settings-body">
<div class="setting-group">
<label class="setting-label">Translation Model</label>
<p class="setting-description">
Choose the model size for translation quality vs speed.
</p>
<div class="model-options">
<label
v-for="option in MODEL_OPTIONS"
:key="option.value"
class="model-option"
:class="{ selected: selectedModel === option.value }"
>
<input
type="radio"
:value="option.value"
v-model="selectedModel"
class="model-radio"
/>
<div class="model-info">
<span class="model-name">{{ option.label }}</span>
<span class="model-desc">{{ option.description }}</span>
</div>
</label>
</div>
</div>
</div>
<div class="settings-footer">
<button
class="btn settings-cancel-btn"
@click="close"
type="button"
>
Cancel
</button>
<button class="btn settings-save-btn" @click="save" type="button">
Save
</button>
</div>
</div>
</div>
</Transition>
</Teleport>
</template>
<style scoped>
.settings-overlay {
position: fixed;
inset: 0;
background-color: var(--overlay-color);
display: flex;
align-items: center;
justify-content: center;
z-index: 9000;
padding: 1rem;
}
.settings-modal {
background-color: var(--modal-bg);
border: 1px solid var(--border-color);
border-radius: 12px;
width: 100%;
max-width: 480px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
.settings-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1.25rem 1.5rem;
border-bottom: 1px solid var(--border-color);
}
.settings-title {
font-size: 1.25rem;
font-weight: 600;
}
.settings-close {
background: none;
border: none;
font-size: 1.25rem;
cursor: pointer;
color: var(--muted-color);
padding: 0.25rem;
line-height: 1;
border-radius: 4px;
transition: color 0.2s;
}
.settings-close:hover {
color: var(--text-color);
}
.settings-body {
padding: 1.5rem;
}
.setting-group {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.setting-label {
font-weight: 600;
font-size: 0.9375rem;
}
.setting-description {
font-size: 0.8125rem;
color: var(--muted-color);
margin-bottom: 0.5rem;
}
.model-options {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.model-option {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 1rem;
border: 1px solid var(--border-color);
border-radius: 8px;
cursor: pointer;
transition:
border-color 0.2s,
background-color 0.2s;
}
.model-option:hover {
border-color: var(--primary-color);
}
.model-option.selected {
border-color: var(--primary-color);
background-color: var(--surface-alt-color);
}
.model-radio {
accent-color: var(--primary-color);
width: 1rem;
height: 1rem;
flex-shrink: 0;
}
.model-info {
display: flex;
flex-direction: column;
gap: 0.125rem;
}
.model-name {
font-weight: 500;
font-size: 0.9375rem;
}
.model-desc {
font-size: 0.75rem;
color: var(--muted-color);
}
.settings-footer {
display: flex;
justify-content: flex-end;
gap: 0.75rem;
padding: 1rem 1.5rem;
border-top: 1px solid var(--border-color);
}
.settings-cancel-btn {
background-color: var(--clear-btn-color);
}
.settings-save-btn {
background-color: var(--primary-color);
}
.modal-enter-active {
transition: opacity 0.2s ease;
}
.modal-enter-active .settings-modal {
transition: transform 0.2s ease;
}
.modal-leave-active {
transition: opacity 0.2s ease;
}
.modal-leave-active .settings-modal {
transition: transform 0.2s ease;
}
.modal-enter-from {
opacity: 0;
}
.modal-enter-from .settings-modal {
transform: scale(0.95);
}
.modal-leave-to {
opacity: 0;
}
.modal-leave-to .settings-modal {
transform: scale(0.95);
}
@media (max-width: 640px) {
.settings-modal {
max-width: 100%;
}
}
</style>
+120
View File
@@ -0,0 +1,120 @@
<script setup lang="ts">
interface Props {
label?: string;
modelValue: string;
placeholder?: string;
disabled?: boolean;
minRows?: number;
maxRows?: number;
}
const props = withDefaults(defineProps<Props>(), {
placeholder: "Enter text to translate...",
disabled: false,
minRows: 3,
maxRows: 12,
});
const emit = defineEmits<{
(e: "update:modelValue", value: string): void;
}>();
const textareaRef = ref<HTMLTextAreaElement | null>(null);
function autoResize() {
const textarea = textareaRef.value;
if (!textarea) return;
textarea.style.height = "auto";
textarea.style.height = `${textarea.scrollHeight}px`;
const style = getComputedStyle(textarea);
const lineHeight = parseFloat(style.lineHeight) || 24;
const minRows = props.minRows * lineHeight;
const maxRows = props.maxRows * lineHeight;
const currentHeight = textarea.scrollHeight;
if (currentHeight < minRows) {
textarea.style.height = `${minRows}px`;
} else if (currentHeight > maxRows) {
textarea.style.height = `${maxRows}px`;
textarea.style.overflowY = "auto";
} else {
textarea.style.overflowY = "hidden";
}
}
function handleInput(event: Event) {
const target = event.target as HTMLTextAreaElement;
emit("update:modelValue", target.value);
autoResize();
}
const charCount = computed(() => props.modelValue.length);
const wordCount = computed(() => {
const text = props.modelValue.trim();
return text ? text.split(/\s+/).length : 0;
});
watch(
() => props.modelValue,
() => {
nextTick(autoResize);
},
);
</script>
<template>
<div class="text-input">
<label v-if="props.label" class="text-input-label">
{{ props.label }}
</label>
<textarea
ref="textareaRef"
class="text-input-area textarea"
:value="props.modelValue"
:placeholder="props.placeholder"
:disabled="props.disabled"
:rows="minRows"
@input="handleInput"
/>
<div class="text-input-stats">
<span class="stat">{{ wordCount }} words</span>
<span class="stat">{{ charCount }} characters</span>
</div>
</div>
</template>
<style scoped>
.text-input {
display: flex;
flex-direction: column;
flex: 1;
}
.text-input-label {
margin-bottom: 0.25rem;
font-size: 0.875rem;
font-weight: 500;
}
.text-input-area {
min-height: calc(24px * 3);
font-size: 1rem;
overflow-y: auto;
resize: none;
}
.text-input-stats {
display: flex;
gap: 1rem;
margin-top: 0.5rem;
font-size: 0.75rem;
color: var(--muted-color);
}
.stat {
background: var(--stat-bg-color);
padding: 0.25rem 0.5rem;
border-radius: 4px;
}
</style>
+50
View File
@@ -0,0 +1,50 @@
<script setup lang="ts">
import { useTheme } from "~/composables/useTheme";
const { theme, toggleTheme } = useTheme();
const label = computed(() =>
theme.value === "dark" ? "Switch to light mode" : "Switch to dark mode",
);
</script>
<template>
<button
class="theme-toggle"
@click="toggleTheme"
type="button"
:aria-label="label"
:title="label"
>
<span v-if="theme === 'dark'" class="theme-icon">&#9788;</span>
<span v-else class="theme-icon">&#9790;</span>
</button>
</template>
<style scoped>
.theme-toggle {
background: none;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 4px;
color: white;
cursor: pointer;
padding: 0.25rem 0.5rem;
font-size: 1.25rem;
line-height: 1;
transition:
border-color 0.2s,
background-color 0.2s;
display: flex;
align-items: center;
justify-content: center;
}
.theme-toggle:hover {
border-color: rgba(255, 255, 255, 0.6);
background-color: rgba(255, 255, 255, 0.1);
}
.theme-icon {
display: inline-block;
}
</style>
+93
View File
@@ -0,0 +1,93 @@
<script setup lang="ts">
import { useToast } from "~/composables/useToast";
const { toasts, dismiss } = useToast();
</script>
<template>
<Teleport to="body">
<div class="toast-container" aria-live="polite">
<TransitionGroup name="toast">
<div
v-for="toast in toasts"
:key="toast.id"
class="toast"
:class="`toast--${toast.type}`"
@click="dismiss(toast.id)"
role="status"
>
<span class="toast-icon">
<template v-if="toast.type === 'success'">&#10003;</template>
<template v-else-if="toast.type === 'error'">&#10007;</template>
<template v-else>&#9432;</template>
</span>
<span class="toast-message">{{ toast.message }}</span>
</div>
</TransitionGroup>
</div>
</Teleport>
</template>
<style scoped>
.toast-container {
position: fixed;
bottom: 1.5rem;
right: 1.5rem;
z-index: 9999;
display: flex;
flex-direction: column-reverse;
gap: 0.5rem;
pointer-events: none;
}
.toast {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1rem;
border-radius: 6px;
color: white;
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
pointer-events: auto;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
max-width: 320px;
}
.toast--success {
background-color: var(--success-color);
}
.toast--error {
background-color: var(--error-color);
}
.toast--info {
background-color: var(--secondary-color);
}
.toast-icon {
flex-shrink: 0;
font-size: 1rem;
}
.toast-message {
line-height: 1.4;
}
.toast-enter-active,
.toast-leave-active {
transition: all 0.3s ease;
}
.toast-enter-from {
opacity: 0;
transform: translateX(1rem);
}
.toast-leave-to {
opacity: 0;
transform: translateX(1rem);
}
</style>
+160
View File
@@ -0,0 +1,160 @@
<script setup lang="ts">
import { useToast } from "~/composables/useToast";
interface Props {
label?: string;
text: string;
loading?: boolean;
error?: string;
}
const props = defineProps<Props>();
const emit = defineEmits<{
(e: "copy"): void;
}>();
const { show: showToast } = useToast();
const isCopied = ref(false);
async function copyToClipboard() {
if (!props.text) return;
try {
await navigator.clipboard.writeText(props.text);
isCopied.value = true;
emit("copy");
showToast("Copied to clipboard", "success");
setTimeout(() => {
isCopied.value = false;
}, 2000);
} catch {
isCopied.value = false;
showToast("Failed to copy text", "error");
}
}
const outputRef = computed(() => props.text);
</script>
<template>
<div class="translation-output">
<div class="translation-output-header">
<label v-if="label" class="translation-output-label">
{{ label }}
</label>
<button
v-if="outputRef"
class="copy-btn btn"
@click="copyToClipboard"
:disabled="loading"
type="button"
:aria-label="isCopied ? 'Copied!' : 'Copy to clipboard'"
:title="isCopied ? 'Copied!' : 'Copy to clipboard'"
>
{{ isCopied ? "✓ Copied" : "Copy" }}
</button>
</div>
<div
class="translation-output-area textarea"
:class="{ loading: loading, error: !!error }"
>
<div v-if="loading" class="translation-loading">
<div class="loading-spinner"></div>
<span>Translating...</span>
</div>
<div v-else-if="error" class="translation-error">
<span class="error-icon">⚠</span>
{{ error }}
</div>
<div v-else-if="text" class="translation-result">
{{ text }}
</div>
<span v-else class="translation-placeholder">
Translation will appear here...
</span>
</div>
</div>
</template>
<style scoped>
.translation-output {
display: flex;
flex-direction: column;
flex: 1;
}
.translation-output-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.25rem;
}
.translation-output-label {
font-size: 0.875rem;
font-weight: 500;
}
.copy-btn {
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
background-color: var(--secondary-color);
}
.copy-btn:hover {
opacity: 0.9;
}
.copy-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.translation-output-area {
position: relative;
min-height: 120px;
background-color: var(--surface-alt-color);
}
.translation-output-area.loading {
opacity: 0.7;
}
.translation-loading {
display: flex;
align-items: center;
gap: 0.5rem;
color: var(--muted-color);
}
.loading-spinner {
width: 16px;
height: 16px;
border: 2px solid var(--border-color);
border-top-color: var(--primary-color);
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.translation-error {
color: var(--error-color);
display: flex;
align-items: center;
gap: 0.5rem;
}
.error-icon {
font-size: 1rem;
}
.translation-placeholder {
color: var(--placeholder-color);
font-style: italic;
}
</style>