Improved UX on pages.meet collapsible posts

This commit is contained in:
Niko 2022-02-19 17:16:40 +01:00
parent 7ce1522234
commit 63941493a9
5 changed files with 43 additions and 11 deletions

View File

@ -141,18 +141,27 @@ main {
} }
.meet.item .status { color: #fff } .meet.item .status { color: #fff }
.meet.item .status-content { .meet.item .status-content {
padding: 1em;
box-shadow: 0px 2px 1px #0000008c; box-shadow: 0px 2px 1px #0000008c;
margin-bottom: 1em; margin-bottom: 1em;
} }
.meet.item .status-content.full {
position: fixed;
display: flex;
top: 0;
height: 100%;
z-index: 10;
}
.meet.item .status-content.full .text { margin: auto !important }
.meet.item .status-content .text { .meet.item .status-content .text {
margin: 0; margin: 0;
padding: 1em;
text-align: center; text-align: center;
font-size: 1.2em; font-size: 1.2em;
word-break: break-word; word-break: break-word;
} }
.meet.item .status-content .text p { .meet.item .status-content .text p {
margin: 0 !important; margin: 0 !important;
line-height: 1.3em;
} }
.meet.item .status-content .text a { .meet.item .status-content .text a {
text-decoration: none; text-decoration: none;
@ -175,6 +184,11 @@ main {
font-size: .8em; font-size: .8em;
} }
*[id*="collapse-link-"][collapsed="true"] .link {
padding: 2em;
padding-bottom: .8em;
}
.meet.item .content { .meet.item .content {
display: grid; display: grid;
} }

View File

@ -38,6 +38,9 @@ body {
*[collapsed="true"]::before { *[collapsed="true"]::before {
content: '... '; content: '... ';
} }
*[id*="collapse-link-"] .link {
user-select: none;
}
@media (max-width: 400px) { .media-max400 { display: none } } @media (max-width: 400px) { .media-max400 { display: none } }
@media (max-width: 500px) { .media-max500 { display: none } } @media (max-width: 500px) { .media-max500 { display: none } }

View File

@ -124,20 +124,27 @@ app.post = {
return _default; return _default;
return app.post._collapsed[id] === true; return app.post._collapsed[id] === true;
}, },
collapse: function(id, strs) { collapse: function(id, strs, userClicked, cback) {
cback = cback || function() {};
const co = document.querySelector(`#collapse-${id}`); const co = document.querySelector(`#collapse-${id}`);
const cl = document.querySelector(`#collapse-link-${id} .link`); const cl = document.querySelector(`#collapse-link-${id} .link`);
const collapsed = co.classList.contains('collapsed'); const collapsed = co.classList.contains('collapsed');
if (collapsed) { if (collapsed) {
app.post._collapsed[id] = false; app.post._collapsed[id] = false;
co.classList.remove('collapsed'); co.classList.remove('collapsed');
if (userClicked) {
co.style = 'background: #f4f4f436';
setTimeout(function() { co.removeAttribute('style') }, 1000);
}
cl.innerText = strs[1]; cl.innerText = strs[1];
cl.parentNode.removeAttribute('collapsed'); cl.parentNode.removeAttribute('collapsed');
cback(id, 'uncollapsed');
} else { } else {
app.post._collapsed[id] = true; app.post._collapsed[id] = true;
co.classList.add('collapsed'); co.classList.add('collapsed');
cl.innerText = strs[0]; cl.innerText = strs[0];
cl.parentNode.setAttribute('collapsed', 'true'); cl.parentNode.setAttribute('collapsed', 'true');
cback(id, 'collapsed');
} }
}, },
prepare4html: function(value, tags) { prepare4html: function(value, tags) {

View File

@ -99,15 +99,16 @@ app.pages.meet = {
} }
if (ok && ti > 0) { if (ok && ti > 0) {
var value = ptext.innerHTML; var value = ptext.innerHTML;
const id = item._id; const id = 'meet'+item._id;
const t1 = (app.strings.app.view_more || 'view more').replaceAll(/('|")/g, ''); const t1 = (app.strings.app.view_more || 'view more').replaceAll(/('|")/g, '') + ' >>';
const t2 = (app.strings.app.view_less || 'view less').replaceAll(/('|")/g, ''); const t2 = '<< ' + (app.strings.app.view_less || 'view less').replaceAll(/('|")/g, '');
const act = `app.post.collapse('${id}', ['${t1}', '${t2}'])`; const act = `app.post.collapse('${id}', ['${t1}', '${t2}'], true, app.pages.meet.onPostCollapse)`;
value = value.substr(0, gi)+ `<span id="collapse-${id}" class="collapse collapsed">`+value.substr(gi)+ value = value.substr(0, gi)+ `<span id="collapse-${id}" class="collapse collapsed">`+value.substr(gi)+
`</span>&nbsp;<span id="collapse-link-${id}" collapsed="true"><a class="link" onclick="${act}">${t1}</a></span>`; `</span>&nbsp;<span id="collapse-link-${id}" collapsed="true"><br><a class="link" onclick="${act}">${t1}</a></span>`;
ptext.innerHTML = value; ptext.innerHTML = value;
if (!app.post.collapsed(id, true)) if (!app.post.collapsed(id, true))
app.post.collapse(id, [t1, t2]); app.post.collapse(id, [t1, t2],
false, app.pages.meet.onPostCollapse);
} }
} }
} }
@ -131,6 +132,14 @@ app.pages.meet = {
} else index = 0; } else index = 0;
app.pages.meet.carousel.set(parseInt(index)); app.pages.meet.carousel.set(parseInt(index));
}, },
onPostCollapse: function(id, state) {
id = id.replace(/^meet/, '');
const elem = document.querySelector(`*[data-id="${id}"] .status-content`);
if (state === 'uncollapsed')
elem.classList.add('full');
else if (state === 'collapsed')
elem.classList.remove('full');
},
actions: { actions: {
crush: function() { crush: function() {
document.activeElement.blur(); document.activeElement.blur();

View File

@ -20,9 +20,8 @@
</i>{.date} </i>{.date}
</div> </div>
</div> </div>
<div class="status-content center width-max" <div class="status-content center width-max">
style="background: {postBgColor};"> <div class="text" style="background: {postBgColor}">
<div class="text">
<p style="color: {postFgColor} !important">{.text}</p> <p style="color: {postFgColor} !important">{.text}</p>
</div> </div>
</div> </div>