From 5ba8e0a05fe6e7236c83ee5fd8ca4cb7684336c8 Mon Sep 17 00:00:00 2001 From: Emma Winston Date: Sat, 30 Nov 2019 12:48:13 +0000 Subject: [PATCH] Make fields in public profile expand on click --- app/javascript/packs/public.js | 36 ++++++++++++++++++++ app/javascript/styles/mastodon/accounts.scss | 1 + 2 files changed, 37 insertions(+) diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index ed713f335..8c0b34a3e 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -257,6 +257,42 @@ function main() { target.style.display = 'block'; } }); + + delegate(document, '.account__header__fields dl', 'click', ( { target } ) => { + const row = target.parentNode; + + if (row.children[0].style.maxHeight === '48px' || row.children[1].style.maxHeight === '48px') { + row.children[0].style.maxHeight = 'none'; + row.children[1].style.maxHeight = 'none'; + row.children[0].style.whiteSpace = 'normal'; + row.children[1].style.whiteSpace = 'normal'; + } else { + row.children[0].style.maxHeight = '48px'; + row.children[1].style.maxHeight = '48px'; + row.children[0].style.whiteSpace = 'nowrap'; + row.children[1].style.whiteSpace = 'nowrap'; + } + }); + + ready(() => { + + const dls = document.querySelectorAll('.account__header__fields dl'); + console.log(dls); + + for (let i = 0; i < dls.length; i++) { + + if(dls[i].children[0].offsetWidth < dls[i].children[0].scrollWidth || + dls[i].children[1].offsetWidth < dls[i].children[1].scrollWidth) { + dls[i].children[0].style.maxHeight = '48px'; + dls[i].children[1].style.maxHeight = '48px'; + dls[i].children[0].style.whiteSpace = 'nowrap'; + dls[i].children[1].style.whiteSpace = 'nowrap'; + dls[i].style.cursor = 'pointer'; + } + + } + + }); } loadPolyfills().then(main).catch(error => { diff --git a/app/javascript/styles/mastodon/accounts.scss b/app/javascript/styles/mastodon/accounts.scss index 5dc067f0e..78e5bb35b 100644 --- a/app/javascript/styles/mastodon/accounts.scss +++ b/app/javascript/styles/mastodon/accounts.scss @@ -236,6 +236,7 @@ dl { display: flex; border-bottom: 1px solid lighten($ui-base-color, 12%); + align-items: stretch; } dt,