From e770c1219f73f5aba569d5a3c0116db74637c680 Mon Sep 17 00:00:00 2001 From: Alexander Platov Date: Tue, 30 Nov 2021 23:55:28 +0300 Subject: [PATCH] Add ShowMore (#445) Signed-off-by: Alexander Platov --- .../src/components/ShowMore.svelte | 91 +++++++++++++++++++ .../src/components/TxView.svelte | 77 ++-------------- 2 files changed, 101 insertions(+), 67 deletions(-) create mode 100644 plugins/activity-resources/src/components/ShowMore.svelte diff --git a/plugins/activity-resources/src/components/ShowMore.svelte b/plugins/activity-resources/src/components/ShowMore.svelte new file mode 100644 index 0000000000..7e0e271b22 --- /dev/null +++ b/plugins/activity-resources/src/components/ShowMore.svelte @@ -0,0 +1,91 @@ + + + + +
+
+ + {#if !ignore && bigger} +
limit} on:click={toggle}> +
+ {/if} +
+ + diff --git a/plugins/activity-resources/src/components/TxView.svelte b/plugins/activity-resources/src/components/TxView.svelte index 220fbd186b..4470744940 100644 --- a/plugins/activity-resources/src/components/TxView.svelte +++ b/plugins/activity-resources/src/components/TxView.svelte @@ -35,8 +35,8 @@ } from '@anticrm/ui' import type { Action, AttributeModel } from '@anticrm/view' import { buildModel, getActions, getObjectPresenter } from '@anticrm/view-resources' - import { afterUpdate } from 'svelte' import { activityKey, ActivityKey, DisplayTx } from '../activity' + import ShowMore from './ShowMore.svelte' export let tx: DisplayTx export let viewlets: Map @@ -56,20 +56,6 @@ let actions: Action[] = [] let edit = false - let contentHTML: HTMLElement - let bigMsg: boolean | undefined = undefined - let outterBtn: boolean | undefined = undefined - - const showContent = (): void => { bigMsg = outterBtn = true } - const hideContent = (): void => { bigMsg = outterBtn = false } - const toggleContent = (): void => bigMsg ? hideContent() : showContent() - - afterUpdate(() => { - if (contentHTML) { - if (contentHTML.scrollHeight !== contentHTML.clientHeight) (edit) ? showContent() : hideContent() - if (contentHTML.clientHeight < 240) bigMsg = outterBtn = undefined - } - }) $: if (tx.tx._id !== ptx?.tx._id) { viewlet = undefined @@ -191,7 +177,7 @@ -
+
@@ -238,20 +224,16 @@
{#if viewlet && viewlet.component && viewlet.display !== 'inline'} -
- {#if typeof viewlet.component === 'string'} - - {:else} - - {/if} +
+ + {#if typeof viewlet.component === 'string'} + + {:else} + + {/if} +
- {#if typeof outterBtn !== 'undefined' && !edit} -
-
- {/if} {/if} -
{/if} @@ -328,46 +310,7 @@ .content { flex-shrink: 0; - overflow: hidden; margin-top: .5rem; - height: max-content; - max-height: 15rem; - - &.full { max-height: max-content; } - &.mask { mask: linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 75%); } - } - - .showMore { - position: absolute; - left: 0; - right: 0; - bottom: 0; - margin: 0 auto; - padding: .5rem 1rem; - width: fit-content; - - font-size: .75rem; - color: var(--theme-caption-color); - background: var(--theme-card-bg); - border: .5px solid var(--theme-card-divider); - box-shadow: 0px 8px 15px rgba(0, 0, 0, .1); - backdrop-filter: blur(120px); - border-radius: 2.5rem; - cursor: pointer; - - opacity: .3; - transform: scale(.9); - transition: opacity .1s ease-in-out, transform .1s ease-in-out; - &:hover { - opacity: 1; - transform: scale(1); - } - &:active { - opacity: .9; - transform: scale(.95); - } - - &.outter { bottom: -1.5rem; } } .emphasized {