Welcome screen with recent repositories and a folder picker when gites starts outside a repository
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<script setup lang="ts">
|
||||
defineProps<{ recents: string[] }>();
|
||||
const emit = defineEmits<{ pick: [path: string]; browse: []; remove: [path: string] }>();
|
||||
|
||||
// Paths on Windows use backslashes.
|
||||
const name = (p: string) => p.split(/[\\/]/).filter(Boolean).pop() ?? p;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="welcome">
|
||||
<div class="card">
|
||||
<img src="/logo.svg" class="logo" alt="" />
|
||||
<h2>Open a repository</h2>
|
||||
<template v-if="recents.length">
|
||||
<div class="head">Recent repositories</div>
|
||||
<div class="list">
|
||||
<div v-for="p in recents" :key="p" class="item">
|
||||
<button class="open" :title="`open ${p}`" @click="emit('pick', p)">
|
||||
<span class="name">{{ name(p) }}</span>
|
||||
<span class="path">{{ p }}</span>
|
||||
</button>
|
||||
<button class="x" title="remove from the list" @click="emit('remove', p)">×</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<button class="browse" @click="emit('browse')">Choose a folder…</button>
|
||||
<p class="hint">You can also start gites with a path: <code>gites ~/code/my-project</code></p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.welcome { flex: 1; min-width: 0; display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 12vh 24px 24px; }
|
||||
.card { width: min(560px, 100%); display: flex; flex-direction: column; gap: 12px; }
|
||||
.logo { width: 112px; height: 112px; align-self: center; }
|
||||
h2 { margin: 0 0 4px; font-size: 20px; }
|
||||
.head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
|
||||
.list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: var(--bg-side); }
|
||||
.item { display: flex; align-items: center; border-radius: 6px; }
|
||||
.item:hover, .item:focus-within { background: var(--bg-hover); }
|
||||
.open { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; border: none; padding: 7px 10px; text-align: left; background: none; }
|
||||
.open:hover { background: none; }
|
||||
.name { font-weight: 600; flex: none; }
|
||||
.path { flex: 1; min-width: 0; color: var(--text-dim); font: 11.5px ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.x { border: none; padding: 2px 10px; color: var(--text-dim); opacity: 0; }
|
||||
.item:hover .x, .item:focus-within .x { opacity: 1; }
|
||||
.browse { align-self: flex-start; padding: 6px 14px; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
|
||||
.hint { margin: 4px 0 0; color: var(--text-dim); font-size: 12px; }
|
||||
.hint code { font-family: ui-monospace, monospace; color: var(--text); }
|
||||
button:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user