@@ -63,9 +60,15 @@
class="document-item"
:class="{ active: currentDocumentId === document.id }"
>
+
{{
- document.title || t('documents.untitled')
+ document.title || t('document.untitled')
}}
{{ formatTime(document.updated) }}
@@ -73,11 +76,11 @@
v-if="document.word !== undefined"
class="document-word-count"
>
- {{ t('documents.stats.words', { count: document.word }) }}
+ {{ t('document.stat.word', { count: document.word }) }}
@@ -90,50 +93,98 @@
@@ -214,7 +250,7 @@ const formatTime = (timestamp: number): string => {
border: none;
border-radius: var(--radius-lg);
color: var(--text-secondary);
- background: var(--surface-raised);
+ background-color: var(--surface-raised-hover);
font-size: 0.85rem;
&:focus {
@@ -222,15 +258,6 @@ const formatTime = (timestamp: number): string => {
}
}
-.remove-btn {
- flex: 0 0 32px;
-
- &:hover,
- &:focus-visible {
- color: var(--color-danger);
- }
-}
-
.document-list {
display: flex;
max-height: calc(100vh - 200px);
@@ -240,6 +267,7 @@ const formatTime = (timestamp: number): string => {
}
.document-item {
+ position: relative;
display: flex;
width: 100%;
min-width: 0;
@@ -270,11 +298,13 @@ const formatTime = (timestamp: number): string => {
min-width: 0;
}
-.document-title,
-.document-time {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
+.document-pin {
+ position: absolute;
+ top: 8px;
+ left: 2px;
+ height: 1em;
+ pointer-events: none;
+ transform: rotate(280deg);
}
.document-title {
@@ -302,7 +332,11 @@ const formatTime = (timestamp: number): string => {
@media (width <= 900px) {
.document-item {
- padding: 10px 0;
+ padding: 10px 0 10px 16px;
+ }
+ .document-pin {
+ top: 8px;
+ left: -6px;
}
}
diff --git a/playground/src/document/component/preview.vue b/playground/src/document/component/preview.vue
index d03eeb7..2720731 100644
--- a/playground/src/document/component/preview.vue
+++ b/playground/src/document/component/preview.vue
@@ -20,7 +20,7 @@
diff --git a/playground/src/document/component/textarea.vue b/playground/src/document/component/textarea.vue
index bdac81c..4083a04 100644
--- a/playground/src/document/component/textarea.vue
+++ b/playground/src/document/component/textarea.vue
@@ -279,6 +279,8 @@ defineExpose({ textarea, replaceSource, stats, scrollToPercentage });
grid-column: 1;
padding: 0 12px;
text-align: right;
+ font-family: 'Google code sans';
+ font-size: 0.9rem;
color: #a0aec0;
user-select: none;
align-self: start;
diff --git a/playground/src/document/component/toolbar/clipboard.vue b/playground/src/document/component/toolbar/clipboard.vue
index 6c4f58a..b5aef4d 100644
--- a/playground/src/document/component/toolbar/clipboard.vue
+++ b/playground/src/document/component/toolbar/clipboard.vue
@@ -37,8 +37,8 @@
+
+
diff --git a/playground/src/document/index.vue b/playground/src/document/index.vue
index 26bd6f0..9c0774b 100644
--- a/playground/src/document/index.vue
+++ b/playground/src/document/index.vue
@@ -33,15 +33,15 @@ import Preview from './component/preview.vue';
import ShareModal from './component/toolbar/share.vue';
import { computed, ref, watch } from 'vue';
-import { useLocale } from '@fuyeor/locale';
-import { useToast, useCopy, LayoutAnchor } from '@fuyeor/interactify';
+import { t, locale } from '@fuyeor/vue-locale';
+import { toast, copyText, LayoutAnchor } from '@fuyeor/interactify';
import { useRoute, useRouter } from '@fuyeor/vue-router';
import { debounce } from '@fuyeor/commons';
+import { statText } from '@fuyeor/util';
import { get } from './api';
import { decodeSnippet } from './composable/useCompression';
import { usePlaygroundSource } from './composable/usePlaygroundSource';
import { useIndexedDb, type HistoryDocument } from './composable/useIndexedDb';
-import { countDocumentStats } from './composable/useDocumentStats';
const { mode = 'code' } = defineProps<{
mode: 'rich' | 'code';
@@ -50,9 +50,6 @@ const { mode = 'code' } = defineProps<{
const route = useRoute();
const router = useRouter();
-const { t, locale } = useLocale();
-const { copyText } = useCopy();
-const { showToast } = useToast();
const { source } = usePlaygroundSource();
const {
@@ -92,7 +89,7 @@ const handleCopyHtml = async () => {
'text/plain': new window.Blob([source.value], { type: 'text/plain' }),
});
await window.navigator.clipboard.write([clipboardItem]);
- showToast(t('copy.success'), { type: 'success' });
+ toast.show(t('copy.success'), { type: 'success' });
};
const handleEditorScroll = (percentage: number) => {
@@ -119,10 +116,10 @@ const saveDocumentContent = async (id: string, content: string) => {
const document: HistoryDocument = {
...previous,
- title: extractTitle(content, t('documents.untitled')),
+ title: extractTitle(content, t('document.untitled')),
updated: Date.now(),
content,
- word: countDocumentStats(content).words,
+ word: statText(content).word,
};
await saveDocument(document);
};
@@ -151,9 +148,9 @@ const createDocumentFromInput = async (content: string) => {
const now = Date.now();
const document: HistoryDocument = {
id: window.crypto.getRandomValues(new Uint8Array(6)).toHex(),
- title: extractTitle(content, t('documents.untitled')),
+ title: extractTitle(content, t('document.untitled')),
content,
- word: countDocumentStats(content).words,
+ word: statText(content).word,
created: now,
updated: now,
};
diff --git a/playground/src/document/util/formatTime.ts b/playground/src/document/util/formatTime.ts
new file mode 100644
index 0000000..0daa7f2
--- /dev/null
+++ b/playground/src/document/util/formatTime.ts
@@ -0,0 +1,31 @@
+// @/document/util/formatTime.ts
+import { t, locale } from '@fuyeor/vue-locale';
+
+// Format relative timestamps in the active locale.
+export const formatTime = (timestamp: number): string => {
+ const diff = Math.max(0, Date.now() - timestamp);
+ if (diff < 60000) return t('document.justNow');
+ if (diff < 3600000)
+ return t('document.minutesAgo', {
+ value: Math.floor(diff / 60000),
+ });
+ if (diff < 86400000)
+ return t('document.hoursAgo', {
+ value: Math.floor(diff / 3600000),
+ });
+ if (diff < 172800000) return t('document.yesterday');
+ if (diff < 604800000)
+ return t('document.daysAgo', {
+ value: Math.floor(diff / 86400000),
+ });
+ if (diff < 2592000000)
+ return t('document.weeksAgo', {
+ value: Math.floor(diff / 604800000),
+ });
+
+ return new Intl.DateTimeFormat(locale.value, {
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit',
+ }).format(timestamp);
+};
diff --git a/playground/src/home/component/campaign.vue b/playground/src/home/component/campaign.vue
index 065a3a8..85c3dec 100644
--- a/playground/src/home/component/campaign.vue
+++ b/playground/src/home/component/campaign.vue
@@ -22,12 +22,11 @@
diff --git a/playground/src/home/component/feature.vue b/playground/src/home/component/feature.vue
index 007dbb9..7b5f2ed 100644
--- a/playground/src/home/component/feature.vue
+++ b/playground/src/home/component/feature.vue
@@ -43,12 +43,10 @@
diff --git a/playground/src/home/component/intro.vue b/playground/src/home/component/intro.vue
index 831c2d9..d1ba9b3 100644
--- a/playground/src/home/component/intro.vue
+++ b/playground/src/home/component/intro.vue
@@ -13,9 +13,7 @@