From 132f8ba9342536082a90dade05ecb9dfe1828f3c Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Wed, 16 Dec 2020 13:28:02 +0100 Subject: [PATCH] Add read-more button --- src/components/Entry.vue | 48 +++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/src/components/Entry.vue b/src/components/Entry.vue index 3b61608..7421799 100644 --- a/src/components/Entry.vue +++ b/src/components/Entry.vue @@ -15,7 +15,7 @@

-
+
{{ outside_author_name }} :
@@ -35,9 +35,15 @@
- -

- + + +

+
+
+ +
+
+ Like · Reply @@ -46,8 +52,8 @@ · Follow · Debug - -

+
+
@@ -126,7 +132,8 @@ export default { selected: [], destinations: [], selectedDestinations: [], - categories: [] + categories: [], + hiddenContentVisible: false } }, @@ -206,6 +213,9 @@ export default { } return false }, + toggleHiddenContent() { + this.hiddenContentVisible = !this.hiddenContentVisible + } }, mounted() { @@ -213,6 +223,15 @@ export default { }, computed: { + hasHiddenContent () { + const el = this.$refs['content-container'] + if (!el) { + // eslint-disable-next-line + console.log('ref content-container not found') + return true + } + return el.scrollHeight > el.clientHeight + }, currentItem() { if (this.isRef) { return this.innerRef @@ -317,7 +336,11 @@ export default { } if (!this.currentItem.author.name) { if (this.currentItem.author.url) { - return new URL(this.currentItem.author.url).hostname + try { + return new URL(this.currentItem.author.url).hostname + } catch (e) { + return this.currentItem.author.url + } } } return this.currentItem.author.name @@ -366,4 +389,13 @@ export default { white-space: pre-wrap; } + .content-container { + max-height: 20vh; + overflow: hidden; + } + + .content-container.open { + max-height: fit-content; + } + \ No newline at end of file