profile fields: add #each loop, allow custom emoji, tweak CSS

This commit is contained in:
Nolan Lawson 2018-08-23 18:58:25 -07:00
parent 698d8f5730
commit 91a92b0003

View file

@ -1,50 +1,52 @@
{#if emojifiedFields.length}
<div class="account-profile-meta"> <div class="account-profile-meta">
{@html meta} <div class="account-profile-meta-border"></div>
{#each emojifiedFields as field, i}
<div class="account-profile-meta-cell account-profile-meta-name">
{field.name}
</div> </div>
<div class="account-profile-meta-cell account-profile-meta-value">
{@html field.value}
</div>
{/each}
<div class="account-profile-meta-border"></div>
</div>
{/if}
<style> <style>
.account-profile-meta { .account-profile-meta {
display: grid;
grid-template-areas: "meta-name-1 meta-value-1"
"meta-name-2 meta-value-2"
"meta-name-3 meta-value-3"
"meta-name-4 meta-value-4";
grid-template-columns: max-content 1fr;
grid-template-rows: max-content;
grid-area: meta; grid-area: meta;
display: grid;
grid-template-columns: max-content 1fr;
grid-row-gap: 5px;
align-items: center;
padding: 10px 0; padding: 10px 0;
font-size: 0.9em; }
.account-profile-meta-border {
height: 1px;
width: 100%;
grid-column: 1 / 3;
background: var(--main-border);
justify-self: center;
}
.account-profile-meta-cell {
word-wrap: break-word; word-wrap: break-word;
overflow: hidden; overflow: hidden;
white-space: pre-wrap; white-space: pre-wrap;
text-overflow: ellipsis;
font-size: 1.1em;
} }
:global(.account-profile-meta p) { .account-profile-meta-name {
margin: 0 0 20px; padding: 10px 20px 10px 0;
} text-transform: uppercase;
color: var(--deemphasized-text-color);
:global(.account-profile-meta p:first-child) {
margin: 0 0 20px;
}
:global(.account-profile-meta p:last-child) {
margin: 0;
}
:global(.account-profile-meta > *:last-child,.account-profile-meta > *:nth-last-child(2)) {
border-bottom: 1px solid var(--main-border);
}
:global(.account-profile-meta > *) {
border-top: 1px solid var(--main-border);
}
:global(.account-profile-meta-field-name) {
position: relative; position: relative;
padding: 10px 20px 10px 30px; max-width: 40vw;
font-weight: bold;
} }
:global(.account-profile-meta-field-name:after) { .account-profile-meta-name:after {
content: ''; content: '';
position: absolute; position: absolute;
right: 0; right: 0;
@ -53,80 +55,38 @@
border-right: 1px solid var(--main-border); border-right: 1px solid var(--main-border);
} }
:global(.account-profile-meta-field-value) { .account-profile-meta-value {
padding: 10px 30px 10px 20px; padding: 10px 10px 10px 20px;
} }
.meta-name-1 { grid-area: meta-name-1; }
.meta-value-1 { grid-area: meta-value-1; }
.meta-name-2 { grid-area: meta-name-2; }
.meta-value-2 { grid-area: meta-value-2; }
.meta-name-3 { grid-area: meta-name-3; }
.meta-value-3 { grid-area: meta-value-3; }
.meta-name-4 { grid-area: meta-name-4; }
.meta-value-4 { grid-area: meta-value-4; }
@media (max-width: 767px) { @media (max-width: 767px) {
.account-profile-meta { .account-profile-meta {
padding: 5px 0; padding: 5px 0;
grid-template-areas: "meta-name-1"
"meta-value-1"
"meta-name-2"
"meta-value-2"
"meta-name-3"
"meta-value-3"
"meta-name-4"
"meta-value-4";
grid-template-columns: 100%;
} }
.account-profile-meta-cell {
:global(.account-profile-meta > *) { font-size: 1em;
border: none;
} }
.account-profile-meta-name {
:global(.account-profile-meta > *:last-child,.account-profile-meta > *:nth-last-child(2)) { padding: 5px 10px 5px 0;
border: none;
} }
.account-profile-meta-value {
:global(.account-profile-meta-field-name:after) { padding: 5px 10px 5px 10px;
border: none;
}
:global(.account-profile-meta-field-name) {
text-align: center;
padding: 10px 0px 0px;
border-top: 1px solid var(--main-border);
}
:global(.account-profile-meta-field-value) {
text-align: center;
padding: 0px 0px 10px;
}
:global(.account-profile-meta-field-name:nth-last-child(2)) {
border-top: 1px solid var(--main-border);
}
:global(.account-profile-meta-field-value:last-child) {
border-bottom: 1px solid var(--main-border);
} }
} }
</style> </style>
<script> <script>
import { emojifyText } from '../../_utils/emojifyText'
import { store } from '../../_store/store'
export default { export default {
store: () => store,
computed: { computed: {
meta: ({ account }) => { emojis: ({ account }) => account.emojis || [],
let metaHTML = ''; fields: ({ account }) => account.fields || [],
for(var i=0; i < account.fields.length; i++) { emojifiedFields: ({ fields, emojis, $autoplayGifs }) => (fields.map(field => ({
metaHTML += `<div class="account-profile-meta-field-name meta-name-${i+1}">`; name: field.name,
metaHTML += `<p>${account.fields[i].name}</p>`; value: emojifyText(field.value, emojis, $autoplayGifs)
metaHTML += `</div>`; })))
metaHTML += `<div class="account-profile-meta-field-value meta-value-${i+1}">`;
metaHTML += `<p>${account.fields[i].value}</p>`;
metaHTML += `</div>`;
}
return metaHTML;
}
} }
} }
</script> </script>