From bd8d8af9ac6e49696ef5716d922e483bc891937a Mon Sep 17 00:00:00 2001 From: Freeplay Date: Thu, 27 Apr 2023 08:16:25 -0400 Subject: [PATCH] add additional information & show more button in user preview popup --- .../client/src/components/MkUserPreview.vue | 133 +++++++++++++++++- 1 file changed, 132 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/MkUserPreview.vue b/packages/client/src/components/MkUserPreview.vue index 956dececb2..1e6db14423 100644 --- a/packages/client/src/components/MkUserPreview.vue +++ b/packages/client/src/components/MkUserPreview.vue @@ -46,7 +46,7 @@ />

-
+
+ + +
+
+
+ +
+
+ +
+
+

{{ i18n.ts.notes }}

@@ -110,9 +149,14 @@ let user = $ref(null); let top = $ref(0); let left = $ref(0); + +let isLong = $ref(false); +let collapsed = $ref(!isLong); + onMounted(() => { if (typeof props.q === "object") { user = props.q; + isLong = (user.description.split("\n").length > 9 || user.description.length > 400); } else { const query = props.q.startsWith("@") ? Acct.parse(props.q.substr(1)) @@ -121,8 +165,10 @@ onMounted(() => { os.api("users/show", query).then((res) => { if (!props.showing) return; user = res; + isLong = (user.description.split("\n").length > 9 || user.description.length > 400); }); } + const rect = props.source.getBoundingClientRect(); const x = @@ -219,6 +265,88 @@ onMounted(() => { padding: 0 16px; font-size: 0.8em; color: var(--fg); + &.collapsed { + position: relative; + max-height: calc(9em + 50px); + mask: linear-gradient(black calc(100% - 64px), transparent); + -webkit-mask: linear-gradient( + black calc(100% - 64px), + transparent + ); + } + } + :deep(.fade) { + position: relative; + display: block; + width: 100%; + margin-top: -2.5em; + z-index: 2; + > span { + display: inline-block; + background: var(--panel); + padding: 0.4em 1em; + font-size: 0.8em; + border-radius: 999px; + box-shadow: 0 2px 6px rgb(0 0 0 / 20%); + } + &:hover { + > span { + background: var(--panelHighlight); + } + } + } + :deep(.showLess) { + width: 100%; + margin-top: 1em; + position: sticky; + bottom: var(--stickyBottom); + + > span { + display: inline-block; + background: var(--panel); + padding: 6px 10px; + font-size: 0.8em; + border-radius: 999px; + box-shadow: 0 0 7px 7px var(--bg); + } + } + + > .fields { + padding: 0 16px; + font-size: .8em; + margin-top: 1em; + + > .field { + display: flex; + padding: 0; + margin: 0; + align-items: center; + + &:not(:last-child) { + margin-bottom: 8px; + } + + :deep(span) { + white-space: nowrap !important; + } + + > .name { + width: 30%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + font-weight: bold; + text-align: center; + } + + > .value { + width: 70%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + margin: 0; + } + } } > .status { @@ -237,6 +365,9 @@ onMounted(() => { > span { font-size: 1em; color: var(--accent); + :global(span) { + white-space: nowrap; + } } } }