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>
|
2021-01-26 15:33:54 +01:00
|
|
|
<p>
|
|
|
|
|
<span class="-text" v-if="text" v-html="textContent"></span>
|
|
|
|
|
<span class="-subline" v-if="subline" v-html="sublineContent"></span>
|
|
|
|
|
</p>
|
2020-08-20 14:48:09 +02:00
|
|
|
</figcaption>
|
|
|
|
|
</figure>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-01-26 15:33:54 +01:00
|
|
|
import MediaApi from 'zero/api/media.js';
|
|
|
|
|
import Strings from 'zero/helpers/strings.js';
|
2020-08-20 14:48:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'uiModulePreviewFigure',
|
|
|
|
|
|
|
|
|
|
props: {
|
|
|
|
|
text: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
subline: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
image: {
|
|
|
|
|
type: String
|
2021-01-26 15:33:54 +01:00
|
|
|
},
|
2021-09-23 15:04:36 +02:00
|
|
|
imageSize: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'thumbnail'
|
|
|
|
|
},
|
2021-01-26 15:33:54 +01:00
|
|
|
html: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
2020-08-20 14:48:09 +02:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
data: () => ({
|
|
|
|
|
imageSource: null
|
|
|
|
|
}),
|
|
|
|
|
|
2021-01-26 15:33:54 +01:00
|
|
|
computed: {
|
|
|
|
|
textContent()
|
|
|
|
|
{
|
2021-10-11 13:58:14 +02:00
|
|
|
return this.html ? this.text : Strings.htmlToText(this.text, true);
|
2021-01-26 15:33:54 +01:00
|
|
|
},
|
|
|
|
|
sublineContent()
|
|
|
|
|
{
|
|
|
|
|
return this.html ? this.subline : Strings.htmlToText(this.subline);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2020-08-20 14:48:09 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-23 15:04:36 +02:00
|
|
|
this.imageSource = MediaApi.getImageSource(this.image, this.imageSize);
|
2020-08-20 14:48:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</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;
|
2021-10-11 13:58:14 +02:00
|
|
|
-webkit-line-clamp: 3;
|
2020-08-20 14:48:09 +02:00
|
|
|
display: -webkit-box;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.-image
|
|
|
|
|
{
|
2021-09-23 15:04:36 +02:00
|
|
|
border-radius: var(--radius-inner);
|
|
|
|
|
max-width: 218px;
|
|
|
|
|
max-height: 124px;
|
2020-08-20 14:48:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|