forked from AkkomaGang/akkoma-fe
refactor the FE parts
This commit is contained in:
parent
2b86f6e883
commit
96c36af731
3 changed files with 74 additions and 37 deletions
|
@ -1,8 +1,21 @@
|
||||||
const LinkPreview = {
|
const LinkPreview = {
|
||||||
name: 'LinkPreview',
|
name: 'LinkPreview',
|
||||||
props: [
|
props: [
|
||||||
'card'
|
'card',
|
||||||
]
|
'size',
|
||||||
|
'nsfw'
|
||||||
|
],
|
||||||
|
computed: {
|
||||||
|
useImage () {
|
||||||
|
// Currently BE shoudn't give cards if tagged NSFW, this is a bit paranoid
|
||||||
|
// as it makes sure to hide the image if somehow NSFW tagged preview can
|
||||||
|
// exist.
|
||||||
|
return this.card.image && !this.nsfw && this.size !== 'hide'
|
||||||
|
},
|
||||||
|
useDescription () {
|
||||||
|
return this.card.description && /\S/.test(this.card.description)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default LinkPreview
|
export default LinkPreview
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<a class="link-preview-card" :href="card.url" target="_blank" rel="noopener">
|
<a class="link-preview-card" :href="card.url" target="_blank" rel="noopener">
|
||||||
<div class="image">
|
<div class="card-image" :class="{ 'small-image': size === 'small' }" v-if="useImage">
|
||||||
<div :style="{ backgroundImage: 'url(' + card.image + ')' }"></div>
|
<img :src="card.image"></img>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="card-content">
|
||||||
<strong>{{ card.title }}</strong>
|
<span class="card-host faint">{{ card.provider_name }}</span>
|
||||||
<p>{{ card.description }}</p>
|
<h4 class="card-title">{{ card.title }}</h4>
|
||||||
<span class="host">{{ card.provider_name }}</span>
|
<p class="card-description" v-if="useDescription">{{ card.description }}</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,36 +19,56 @@
|
||||||
@import '../../_variables.scss';
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
.link-preview-card {
|
.link-preview-card {
|
||||||
display: flex !important;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin: 0.5em 0.7em 0.6em 0.0em;
|
overflow: hidden;
|
||||||
|
|
||||||
.image {
|
// TODO: clean up the random margins in attachments, this makes preview line
|
||||||
flex: 0 0 100px;
|
// up with attachments...
|
||||||
position: relative;
|
margin-right: 0.7em;
|
||||||
}
|
|
||||||
|
|
||||||
.image > div {
|
.card-image {
|
||||||
display: block;
|
flex-shrink: 0;
|
||||||
margin: 0;
|
width: 120px;
|
||||||
width: 100%;
|
max-width: 25%;
|
||||||
height: 100%;
|
img {
|
||||||
object-fit: cover;
|
width: 100%;
|
||||||
background-size: cover;
|
height: 100%;
|
||||||
background-position: center center;
|
object-fit: cover;
|
||||||
}
|
border-radius: $fallback--attachmentRadius;
|
||||||
|
border-radius: var(--attachmentRadius, $fallback--attachmentRadius);
|
||||||
.content {
|
|
||||||
padding: 1em;
|
|
||||||
flex: 1;
|
|
||||||
|
|
||||||
.host {
|
|
||||||
font-size: 90%;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.small-image {
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-content {
|
||||||
|
max-height: 100%;
|
||||||
|
margin: 0.5em;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-host {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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);
|
||||||
|
}
|
||||||
|
|
||||||
color: $fallback--text;
|
color: $fallback--text;
|
||||||
|
color: var(--text, $fallback--text);
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-radius: $fallback--attachmentRadius;
|
border-radius: $fallback--attachmentRadius;
|
||||||
|
|
|
@ -98,8 +98,8 @@
|
||||||
</attachment>
|
</attachment>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if='status.card && !hideSubjectStatus && !noHeading' class='link-preview media-body'>
|
<div v-if="status.card && !hideSubjectStatus && !noHeading" class="link-preview media-body">
|
||||||
<link-preview :card="status.card"></link-preview>
|
<link-preview :card="status.card" :size="attachmentSize" :nsfw="nsfwClickthrough" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="!noHeading && !noReplyLinks" class='status-actions media-body'>
|
<div v-if="!noHeading && !noReplyLinks" class='status-actions media-body'>
|
||||||
|
@ -225,6 +225,11 @@
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
flex-basis: 100%;
|
flex-basis: 100%;
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: inline-block;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
small {
|
small {
|
||||||
font-weight: lighter;
|
font-weight: lighter;
|
||||||
}
|
}
|
||||||
|
@ -300,11 +305,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
|
||||||
display: inline-block;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tall-status {
|
.tall-status {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 220px;
|
height: 220px;
|
||||||
|
@ -313,6 +313,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.tall-status-hider {
|
.tall-status-hider {
|
||||||
|
display: inline-block;
|
||||||
|
word-break: break-all;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
margin-top: 150px;
|
margin-top: 150px;
|
||||||
|
@ -330,6 +332,8 @@
|
||||||
.status-unhider, .cw-status-hider {
|
.status-unhider, .cw-status-hider {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
display: inline-block;
|
||||||
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-content {
|
.status-content {
|
||||||
|
|
Loading…
Reference in a new issue