yandere_fe/src/components/link-preview/link-preview.vue

94 lines
2.0 KiB
Vue
Raw Normal View History

2019-01-27 05:47:30 -08:00
<template>
<div>
2019-07-05 00:17:44 -07:00
<a
class="link-preview-card"
:href="card.url"
target="_blank"
rel="noopener"
>
<div
v-if="useImage && imageLoaded"
2019-07-05 00:17:44 -07:00
class="card-image"
>
2019-07-06 14:54:17 -07:00
<img :src="card.image">
2019-01-27 05:47:30 -08:00
</div>
2019-01-27 12:33:36 -08:00
<div class="card-content">
<span class="card-host faint">
<span
v-if="censored"
class="nsfw-alert alert warning"
>{{ $t('status.nsfw') }}</span>
{{ card.provider_name }}
</span>
2019-01-27 12:33:36 -08:00
<h4 class="card-title">{{ card.title }}</h4>
2019-07-05 00:17:44 -07:00
<p
v-if="useDescription"
class="card-description"
>{{ card.description }}</p>
2019-01-27 05:47:30 -08:00
</div>
</a>
</div>
</template>
<script src="./link-preview.js"></script>
<style lang="scss">
@import '../../_variables.scss';
.link-preview-card {
2019-01-27 12:33:36 -08:00
display: flex;
2019-01-27 05:47:30 -08:00
flex-direction: row;
cursor: pointer;
2019-01-27 12:33:36 -08:00
overflow: hidden;
margin-top: 0.5em;
2019-01-27 05:47:30 -08:00
2019-01-27 12:33:36 -08:00
.card-image {
flex-shrink: 0;
width: 120px;
max-width: 25%;
img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: $fallback--attachmentRadius;
border-radius: var(--attachmentRadius, $fallback--attachmentRadius);
}
}
.card-content {
max-height: 100%;
margin: 0.5em;
display: flex;
flex-direction: column;
2019-01-27 05:47:30 -08:00
}
2019-01-27 12:33:36 -08:00
.card-host {
font-size: 12px;
}
2019-01-27 05:47:30 -08:00
2019-01-27 12:33:36 -08:00
.card-description {
margin: 0.5em 0 0 0;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-word;
line-height: 1.2em;
// cap description at 3 lines, the 1px is to clean up some stray pixels
// TODO: fancier fade-out at the bottom to show off that it's too long?
max-height: calc(1.2em * 3 - 1px);
2019-01-27 05:47:30 -08:00
}
.nsfw-alert {
margin: 2em 0;
}
2019-01-27 05:47:30 -08:00
color: $fallback--text;
2019-01-27 12:33:36 -08:00
color: var(--text, $fallback--text);
2019-01-27 05:47:30 -08:00
border-style: solid;
border-width: 1px;
border-radius: $fallback--attachmentRadius;
border-radius: var(--attachmentRadius, $fallback--attachmentRadius);
border-color: $fallback--border;
border-color: var(--border, $fallback--border);
}
</style>