Tweaking Post UI
This commit is contained in:
@@ -1,15 +1,47 @@
|
|||||||
<script setup>
|
<template>
|
||||||
|
<div class="shadow-md rounded-2xl bg-gray-50 px-6 ">
|
||||||
|
<div>
|
||||||
|
<v-card-title>
|
||||||
|
{{ props.content.title }}
|
||||||
|
<span class="text-subtitle-2">
|
||||||
|
{{ time_ago(props.content.createdAt) }}
|
||||||
|
</span>
|
||||||
|
<v-card-text>
|
||||||
|
{{ props.content.description }}
|
||||||
|
</v-card-text>
|
||||||
|
</v-card-title>
|
||||||
|
|
||||||
import {computed, reactive, onMounted} from 'vue';
|
<v-carousel v-if="hasUrls" hide-delimiter-background show-arrows="hover">
|
||||||
|
<v-carousel-item
|
||||||
|
v-for="url in props.content.urls"
|
||||||
|
:key="url"
|
||||||
|
class="image-container rounded-2xl"
|
||||||
|
>
|
||||||
|
<component :is="getComponent(url)" :src="url"></component>
|
||||||
|
</v-carousel-item>
|
||||||
|
</v-carousel>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<h2 class="font-sans font-semibold mt-4">Commentaires</h2>
|
||||||
|
<message-list :subject-id="props.content.id" :messages="messages"></message-list>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="py-2">
|
||||||
|
<post-message :subject-id="props.content.id" @message-posted="addMessage"></post-message>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {computed, reactive} from 'vue';
|
||||||
import {time_ago} from "@/internal_time_ago.js";
|
import {time_ago} from "@/internal_time_ago.js";
|
||||||
import MessageList from "@/views/messages/MessageList.vue";
|
import MessageList from "@/views/messages/MessageList.vue";
|
||||||
import PostMessage from "@/views/messages/PostMessage.vue";
|
import PostMessage from "@/views/messages/PostMessage.vue";
|
||||||
|
|
||||||
import YoutubePlayer from './YoutubePlayer.vue';
|
import YoutubePlayer from './YoutubePlayer.vue';
|
||||||
import ImageViewer from './ImageViewer.vue';
|
import ImageViewer from './ImageViewer.vue';
|
||||||
// import VimeoPlayer from '@/components/VimeoPlayer.vue';
|
|
||||||
// import AudioPlayer from '@/components/AudioPlayer.vue';
|
|
||||||
// import BlogViewer from '@/components/BlogViewer.vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
content: {
|
content: {
|
||||||
@@ -20,81 +52,32 @@ const props = defineProps({
|
|||||||
|
|
||||||
const hasUrls = computed(() => !!props.content.urls && props.content.urls.length > 0);
|
const hasUrls = computed(() => !!props.content.urls && props.content.urls.length > 0);
|
||||||
|
|
||||||
|
|
||||||
const messages = reactive([]);
|
const messages = reactive([]);
|
||||||
|
|
||||||
function addMessage(newMessage) {
|
function addMessage(newMessage) {
|
||||||
messages.unshift(newMessage)
|
messages.unshift(newMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getComponent(url) {
|
function getComponent(url) {
|
||||||
if (url.includes('youtube.com') || url.includes('youtu.be')) {
|
if (url.includes('youtube.com') || url.includes('youtu.be')) {
|
||||||
return YoutubePlayer;
|
return YoutubePlayer;
|
||||||
// } else if (url.includes('vimeo.com')) {
|
|
||||||
// return VimeoPlayer;
|
|
||||||
} else if (url.match(/\.(jpeg|jpg|gif|png)$/)) {
|
} else if (url.match(/\.(jpeg|jpg|gif|png)$/)) {
|
||||||
return ImageViewer;
|
return ImageViewer;
|
||||||
// } else if (url.match(/\.(mp3|wav|ogg)$/)) {
|
|
||||||
// return 'AudioPlayer';
|
|
||||||
// } else {
|
|
||||||
// return 'BlogViewer';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<style>
|
||||||
<div class="shadow-md rounded-lg bg-gray-50 px-10">
|
.image-container {
|
||||||
<v-card
|
display: flex;
|
||||||
outlined
|
justify-content: center;
|
||||||
tile
|
align-items: center;
|
||||||
>
|
overflow: hidden;
|
||||||
<v-card-title>
|
}
|
||||||
{{ props.content.title }}
|
|
||||||
<span class="text-subtitle-2">
|
|
||||||
{{ time_ago(props.content.createdAt) }}
|
|
||||||
</span>
|
|
||||||
</v-card-title>
|
|
||||||
|
|
||||||
<v-carousel v-if="hasUrls">
|
.image-container img {
|
||||||
|
width: 100%;
|
||||||
<v-carousel-item
|
height: 100%;
|
||||||
v-for="url in props.content.urls"
|
object-fit: cover;
|
||||||
:key="url"
|
}
|
||||||
>
|
</style>
|
||||||
<component :is="getComponent(url)"
|
|
||||||
:src="url"
|
|
||||||
></component>
|
|
||||||
</v-carousel-item>
|
|
||||||
|
|
||||||
</v-carousel>
|
|
||||||
|
|
||||||
<v-card-text>
|
|
||||||
{{ props.content.description }}
|
|
||||||
</v-card-text>
|
|
||||||
|
|
||||||
<v-card-actions>
|
|
||||||
<router-link :to="'content/' + content.id">
|
|
||||||
<div class="bg-blue-500 rounded-lg py-1 px-2">Plus ...</div>
|
|
||||||
</router-link>
|
|
||||||
</v-card-actions>
|
|
||||||
|
|
||||||
</v-card>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
<h2 class="font-sans font-semibold mt-4">Commentaires</h2>
|
|
||||||
<message-list :subject-id="props.content.id" :messages="messages">
|
|
||||||
</message-list>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="py-2">
|
|
||||||
<post-message :subject-id="props.content.id" @message-posted="addMessage">
|
|
||||||
</post-message>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="image-container">
|
<div class="image-container">
|
||||||
<img :src="src" alt="Image" class="image" />
|
<img :src="src" alt="Image" class="full-size-image" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user