2020-08-20 14:48:09 +02:00
|
|
|
<template>
|
|
|
|
|
<figure class="ui-module-preview-figure" :class="{'has-image': imageSource != null}">
|
|
|
|
|
<img v-if="imageSource" :src="imageSource" class="-image" />
|
|
|
|
|
<figcaption>
|
|
|
|
|
<article class="-text" v-if="text" v-html="text"></article>
|
2020-08-21 11:29:54 +02:00
|
|
|
<article class="-subline" v-if="subline">{{subline.replace(/<\/?[^>]+>/ig, " ")}}</article>
|
2020-08-20 14:48:09 +02:00
|
|
|
</figcaption>
|
|
|
|
|
</figure>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2020-11-20 15:17:41 +01:00
|
|
|
import MediaApi from 'zero/api/media.js'
|
2020-08-20 14:48:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'uiModulePreviewFigure',
|
|
|
|
|
|
|
|
|
|
props: {
|
|
|
|
|
text: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
subline: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
image: {
|
|
|
|
|
type: String
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
data: () => ({
|
|
|
|
|
imageSource: null
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
|
image(val)
|
|
|
|
|
{
|
|
|
|
|
this.loadImageSource();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mounted()
|
|
|
|
|
{
|
|
|
|
|
this.loadImageSource();
|
2020-08-20 15:11:41 +02:00
|
|
|
},
|
2020-08-20 14:48:09 +02:00
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
|
|
|
|
loadImageSource()
|
|
|
|
|
{
|
|
|
|
|
if (!this.image)
|
|
|
|
|
{
|
|
|
|
|
this.imageSource = null;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.imageSource = MediaApi.getImageSource(this.image);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.ui-module-preview-figure
|
|
|
|
|
{
|
|
|
|
|
font-size: var(--font-size);
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
|
|
|
|
&.has-image
|
|
|
|
|
{
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: auto 1fr;
|
2020-08-31 11:48:05 +02:00
|
|
|
gap: 20px;
|
2020-08-20 14:48:09 +02:00
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.-text
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.-subline
|
|
|
|
|
{
|
2020-09-07 14:55:05 +02:00
|
|
|
color: var(--color-text-dim);
|
2020-08-20 14:48:09 +02:00
|
|
|
font-size: var(--font-size-s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.-text, .-subline
|
|
|
|
|
{
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
-webkit-box-orient: vertical;
|
2020-08-20 15:11:41 +02:00
|
|
|
-webkit-line-clamp: 2;
|
2020-08-20 14:48:09 +02:00
|
|
|
display: -webkit-box;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.-image
|
|
|
|
|
{
|
|
|
|
|
border-radius: var(--radius);
|
2020-08-20 15:11:41 +02:00
|
|
|
max-width: 128px;
|
2020-08-20 14:48:09 +02:00
|
|
|
max-height: 64px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|