Skip to content

Commit bc96c17

Browse files
committed
updated Avatar and NoteHeader
1 parent e9b38b3 commit bc96c17

File tree

5 files changed

+57
-19
lines changed

5 files changed

+57
-19
lines changed

codex-ui/src/vue/components/avatar/Avatar.vue

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<img
33
:src="src"
44
:alt="`Avatar of ${username}`"
5-
:class="$style.avatar"
5+
:class="$style[`avatar--${size}`]"
66
referrerpolicy="no-referrer"
77
>
88
</template>
99

1010
<script setup lang="ts">
1111
import { defineProps } from 'vue';
1212
13-
defineProps<{
13+
withDefaults(defineProps<{
1414
/**
1515
* Path to the image
1616
*/
@@ -21,13 +21,33 @@ defineProps<{
2121
* In future, we can use this to generate initials
2222
*/
2323
username: string;
24-
}>();
24+
25+
/**
26+
* Size of the avatar image
27+
* medium by default
28+
*/
29+
size: 'medium' | 'small'
30+
}>(),
31+
{
32+
src: undefined,
33+
username: undefined,
34+
size: 'medium',
35+
});
36+
2537
</script>
2638

2739
<style module>
2840
.avatar {
29-
width: var(--size-avatar);
30-
height: var(--size-avatar);
31-
border-radius: var(--radius-m);
41+
&--small {
42+
width: var(--size-icon);
43+
height: var(--size-icon);
44+
border-radius: var(--radius-s);
45+
}
46+
47+
&--medium {
48+
width: var(--size-avatar);
49+
height: var(--size-avatar);
50+
border-radius: var(--radius-m);
51+
}
3252
}
3353
</style>

src/application/i18n/messages/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@
8585
"title": "Versions history",
8686
"view": "View",
8787
"useVersion": "Use this version",
88-
"confirmVersionRestore": "Do you really want to use this version?"
88+
"confirmVersionRestore": "Do you really want to use this version?",
89+
"editedTime": "edited on"
8990
},
9091
"noteList": {
9192
"emptyNoteList": "No Notes yet. Make your first note",

src/presentation/components/note-header/NoteHeader.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
&__right {
3131
display: flex;
3232
gap: var(--spacing-s);
33+
align-items: center;
3334
}
3435
}
3536
</style>

src/presentation/pages/HistoryVersion.vue

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
<template>
22
<div>
33
<NoteHeader>
4-
<template #left>
5-
{{
6-
historyMeta && 'createdAt' in historyMeta && historyMeta.createdAt
7-
? t('note.lastEdit') + ' ' + getTimeFromNow(historyMeta.createdAt)
8-
: t('note.lastEdit') + ' ' + 'a few seconds ago'
9-
}}
10-
</template>
114
<template #right>
5+
<div
6+
v-if="historyMeta !== undefined && historyMeta?.user.photo"
7+
:class="$style['head-meta']"
8+
>
9+
<Avatar
10+
:src="historyMeta.user.photo"
11+
:username="historyMeta.user.name"
12+
size="small"
13+
/>
14+
{{
15+
historyMeta?.user.name
16+
}}
17+
{{
18+
t('history.editedTime') + ' ' + parseDate(new Date(historyMeta.createdAt))
19+
}}
20+
</div>
1221
<Button
1322
@click="useThisVersion"
1423
>
@@ -21,7 +30,7 @@
2130
secondary
2231
@click="router.push(`/note/${noteId}/history`)"
2332
>
24-
👁️
33+
History
2534
</Button>
2635
</template>
2736
</NoteHeader>
@@ -35,11 +44,11 @@
3544

3645
<script lang="ts" setup>
3746
import { ref, toRef, watch } from 'vue';
38-
import { Editor, Button } from 'codex-ui/vue';
47+
import { Editor, Button, Avatar } from 'codex-ui/vue';
3948
import NoteHeader from '@/presentation/components/note-header/NoteHeader.vue';
4049
import useHistory from '@/application/services/useNoteHistory';
4150
import { useNoteEditor } from '@/application/services/useNoteEditor';
42-
import { getTimeFromNow, parseDate } from '@/infrastructure/utils/date';
51+
import { parseDate } from '@/infrastructure/utils/date';
4352
import useNote from '@/application/services/useNote';
4453
import { useI18n } from 'vue-i18n';
4554
import useHeader from '@/application/services/useHeader';
@@ -131,5 +140,12 @@ watch(noteTitle, (currentNoteTitle) => {
131140
132141
</script>
133142

134-
<style scoped>
143+
<style module>
144+
.head-meta {
145+
display: flex;
146+
align-items: center;
147+
color: var(--base--text-secondary);
148+
gap: var(--spacing-s);
149+
padding: 0 var(--spacing-s);
150+
}
135151
</style>

src/presentation/pages/Note.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
secondary
2424
@click="router.push(`/note/${noteId}/history`)"
2525
>
26-
👁️
26+
History
2727
</Button>
2828
<Button
2929
v-if="canEdit"

0 commit comments

Comments
 (0)