Files
arboretum/packages/web/src/components/DirectoryPicker.vue
Johan LEROY 063f5e928b feat(web): refonte visuelle « Emerald » (thème clair/sombre, polices, tokens)
Adopte le langage visuel du design system Emerald dans l'IDE web :
neutres zinc + accent emerald, polices auto-hébergées Inter + JetBrains
Mono, radii/pills mono, points de statut, motif terminal, halo/grain.
Refonte purement visuelle et additive (layout, routing, stores, protocole
inchangés).

- style.css : défauts sombres dans @theme + override clair sous
  html[data-theme=light] ; accent scindé (bright #34d399 / solid #059669 /
  hover) ; tokens border-soft/info/warn/danger/coffee ; idiomes globaux
  (focus/selection accent, scrollbars fines, jl-pulse/jl-blink, classes
  .chip/.status/.eyebrow/.label-mono/.caret/.halo/.grain, .btn*/.badge pill).
- lib/theme.ts : singleton themeMode/resolvedTheme (dark/light/system,
  persistedRef arb.theme) + application dataset.theme/metas ; script
  anti-FOUC inline dans index.html ; toggle ActivityBar + Réglages.
- Thèmes Monaco + xterm dark/light réactifs (palette ANSI + coloration
  syntaxique) ; fonts.ready + remeasureFonts pour l'alignement des glyphes.
- status-tokens : tons sémantiques tokenisés ; balayage des ~340 couleurs
  Tailwind brutes vers les tokens sur tout components/* et views/*
  (exceptions assumées commentées).
- GroupSummary.color exploité : icône de groupe teintée + ColorSwatchPicker
  (lib/group-colors.ts) dans les modals de groupe.
- Polices via @fontsource-variable/{inter,jetbrains-mono} (offline).
2026-07-20 21:30:57 +02:00

85 lines
3.4 KiB
Vue

<template>
<section class="flex flex-col gap-2 rounded-lg border border-border bg-surface-0/40 p-2">
<header class="flex items-center gap-2">
<button type="button" class="btn text-xs" :disabled="loading || parent === null" @click="load(parent ?? undefined)">
{{ t('fs.up') }}
</button>
<span class="min-w-0 flex-1 truncate font-mono text-xs text-fg-muted" :title="current">{{ current }}</span>
<button type="button" class="btn text-xs" @click="emit('close')">{{ t('common.cancel') }}</button>
</header>
<p v-if="error" class="text-sm text-danger">{{ error }}</p>
<ul class="flex max-h-60 flex-col gap-0.5 overflow-y-auto">
<li v-if="loading" class="px-2 py-1 text-xs text-fg-subtle">{{ t('fs.loading') }}</li>
<li v-else-if="entries.length === 0" class="px-2 py-1 text-xs text-fg-subtle">{{ t('fs.empty') }}</li>
<li v-for="e in entries" :key="e.path">
<button
type="button"
class="flex w-full items-center gap-2 rounded px-2 py-1 text-left text-sm text-fg hover:bg-surface-2"
@click="load(e.path)"
>
<span class="flex-1 truncate font-mono">{{ e.name }}</span>
<span v-if="e.isRepo" class="badge bg-accent/15 text-accent">{{ t('fs.repoBadge') }}</span>
</button>
</li>
</ul>
<footer class="flex items-center gap-2">
<label class="flex items-center gap-1 text-xs text-fg-muted">
<input v-model="showHidden" type="checkbox" @change="load(current || undefined)" /> {{ t('fs.showHidden') }}
</label>
<button type="button" class="btn-primary ml-auto text-xs" :disabled="loading || current === ''" @click="emit('select', current)">
{{ t('fs.useFolder') }}
</button>
</footer>
</section>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import type { FsEntry, FsListResponse } from '@arboretum/shared';
import { api } from '../lib/api';
// mode 'repo' : annote les sous-dossiers qui sont des dépôts git (badge). 'dir' : navigation simple.
const props = withDefaults(defineProps<{ mode?: 'dir' | 'repo'; initialPath?: string }>(), {
mode: 'dir',
initialPath: '',
});
const emit = defineEmits<{ select: [path: string]; close: [] }>();
const { t } = useI18n();
const current = ref('');
const parent = ref<string | null>(null);
const entries = ref<FsEntry[]>([]);
const loading = ref(false);
const error = ref<string | null>(null);
const showHidden = ref(false);
/** path absent → le serveur retombe sur le home. En cas d'erreur, on garde l'écoute précédente affichée. */
async function load(path?: string): Promise<void> {
loading.value = true;
error.value = null;
try {
const params = new URLSearchParams();
if (path) params.set('path', path);
if (props.mode === 'repo') params.set('markRepos', '1');
if (showHidden.value) params.set('showHidden', '1');
const res = await api.get<FsListResponse>(`/api/v1/fs/list?${params.toString()}`);
current.value = res.path;
parent.value = res.parent;
entries.value = res.entries;
} catch (err) {
error.value = err instanceof Error ? err.message : String(err);
} finally {
loading.value = false;
}
}
onMounted(() => {
// démarre sur le chemin déjà saisi s'il est absolu, sinon sur le home (path absent).
void load(props.initialPath.startsWith('/') ? props.initialPath : undefined);
});
</script>