Skip to content

Commit d6d9652

Browse files
committed
#6: Small updates to the UI, showing exact creation time on hovering the time ago. Saving a snapshot with the contents of the repl right before restoring an existing snapshot.
1 parent b9f8c69 commit d6d9652

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

src/components/YvVersioningDrawer/YvSnapshot.vue

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import type { Snapshot, SnapshotType } from '@/db';
33
import { useTimeAgoIntl } from '@vueuse/core';
4-
import { Menu } from 'floating-vue';
4+
import { Menu, Tooltip } from 'floating-vue';
55
import { motion } from 'motion-v';
66
import { CodeDiff } from 'v-code-diff';
77
import { computed } from 'vue';
@@ -120,12 +120,21 @@ const didFilesChange = computed(() => {
120120
</p>
121121
</div>
122122

123-
<span
124-
inline-block
125-
text="xs neutral-400 dark:neutral-500"
126-
>
127-
{{ useTimeAgoIntl(props.snapshot.createdAt) }}
128-
</span>
123+
<Tooltip placement="bottom">
124+
<span
125+
cursor-pointer
126+
inline-block
127+
text="xs neutral-400 dark:neutral-500"
128+
>
129+
{{ useTimeAgoIntl(props.snapshot.createdAt) }}
130+
</span>
131+
132+
<template #popper>
133+
<p text="xs">
134+
{{ new Intl.DateTimeFormat(undefined, { hour: '2-digit', minute: '2-digit', second: '2-digit' }).format(props.snapshot.createdAt) }}
135+
</p>
136+
</template>
137+
</Tooltip>
129138
</div>
130139

131140
<div
@@ -146,7 +155,7 @@ const didFilesChange = computed(() => {
146155
:class="typeColors.line"
147156
pl-5 pb-3 ml-1
148157
>
149-
<p font-bold class="text-foreground/70">
158+
<p font-bold text-xs class="text-foreground/70">
150159
{{ props.snapshot.message }}
151160
</p>
152161

src/components/toasts/YvToasts.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const hiddenCount = computed(() => {
168168
:key="activeToast.id"
169169
sc-toast-base bg="opacity-90 background"
170170
flex="~ items-center gap-3"
171-
p-2 cursor-pointer select-none
171+
py-2 px-4 cursor-pointer select-none
172172
hover="opacity-100 scale-105"
173173
transition="transition-all duration-200 ease-in-out"
174174
class="border rounded-lg pointer-events-auto active:scale-98"

src/composables/useFileManagerStore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ export const useFileManagerStore = defineStore('file-manager', () => {
125125
}
126126

127127
async function restoreSnapshot(snapshot: Snapshot): Promise<void> {
128+
// save the current contents of the repl in a snapshot before updating the repl
129+
await saveSnapshot({
130+
type: 'auto',
131+
message: 'Before a snapshot was restored',
132+
});
133+
128134
replStore.setFiles(snapshot.files);
129135
}
130136

0 commit comments

Comments
 (0)