Refactor: Split components
This commit is contained in:
parent
c4f95179c9
commit
8a9e878d5f
@ -5,21 +5,27 @@
|
|||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text> Last updated {{ prettyDate }} </v-card-text>
|
<v-card-text> Last updated {{ prettyDate }} </v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<div class="tags">
|
<TagsGroup :tags="tags" />
|
||||||
<v-chip v-for="tag in tags" :key="tag" active color="secondary">
|
<v-spacer />
|
||||||
{{ tag }}
|
<v-btn text color="accent" @click="$router.push(`/notes/${uuid}`)"
|
||||||
</v-chip>
|
>View</v-btn
|
||||||
</div>
|
>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { format } from 'timeago.js'
|
import { format } from 'timeago.js'
|
||||||
|
import TagsGroup from '@/components/TagsGroup'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Note',
|
name: 'NoteCard',
|
||||||
|
components: { TagsGroup },
|
||||||
props: {
|
props: {
|
||||||
|
uuid: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
@ -40,17 +46,3 @@ export default {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
.tags {
|
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tags .v-chip {
|
|
||||||
margin: 4px 8px 4px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.v-card.hover {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
27
frontend/components/TagsGroup.vue
Normal file
27
frontend/components/TagsGroup.vue
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tags">
|
||||||
|
<v-chip v-for="tag in tags" :key="tag" active color="secondary">
|
||||||
|
{{ tag }}
|
||||||
|
</v-chip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'TagsGroup',
|
||||||
|
props: {
|
||||||
|
tags: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.tags {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags .v-chip {
|
||||||
|
margin: 4px 8px 4px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
40
frontend/pages/notes/_uuid.vue
Normal file
40
frontend/pages/notes/_uuid.vue
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<template>
|
||||||
|
<v-card>
|
||||||
|
<v-card-title>
|
||||||
|
{{ note.title }}
|
||||||
|
<v-spacer />
|
||||||
|
<TagsGroup :tags="note.tags" />
|
||||||
|
</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<div v-html="renderedMarkdown"></div>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import TagsGroup from '@/components/TagsGroup'
|
||||||
|
import renderMarkdown from '@/utils/markdown'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Note',
|
||||||
|
components: {
|
||||||
|
TagsGroup,
|
||||||
|
},
|
||||||
|
data: () => ({
|
||||||
|
note: {
|
||||||
|
tags: [],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
computed: {
|
||||||
|
renderedMarkdown() {
|
||||||
|
if (!this.note.chapters) return ''
|
||||||
|
return renderMarkdown(this.note.chapters[0].content).contents
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$axios
|
||||||
|
.$get(`/notes/${this.$route.params.uuid}`)
|
||||||
|
.then((note) => (this.note = note))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -16,7 +16,8 @@
|
|||||||
lg="4"
|
lg="4"
|
||||||
xl="3"
|
xl="3"
|
||||||
>
|
>
|
||||||
<Note
|
<NoteCard
|
||||||
|
:uuid="note.uuid"
|
||||||
:title="note.title"
|
:title="note.title"
|
||||||
:updated-at="note.updatedAt"
|
:updated-at="note.updatedAt"
|
||||||
:tags="note.tags"
|
:tags="note.tags"
|
||||||
@ -28,11 +29,11 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import Note from '@/components/Note.vue'
|
import NoteCard from '@/components/NoteCard.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Notes',
|
name: 'Notes',
|
||||||
components: { Note },
|
components: { NoteCard },
|
||||||
data: () => ({
|
data: () => ({
|
||||||
loading: true,
|
loading: true,
|
||||||
}),
|
}),
|
||||||
Loading…
x
Reference in New Issue
Block a user