SHA256
Профиль: «Официальный» и «Сияющий» снова по бокам аватара
- Слева «Официальный», справа «Сияющий»: числа «подтвердили» и «подтвердил(а)» открывают списки. - У активного статуса числа его цветом; на своём профиле обе стороны видны всегда, пустая – бледнее. - Значки под именем и нижний раздел «Сияние» убраны – они повторяли эти числа.
This commit is contained in:
@@ -13,35 +13,23 @@ export function escapeProfileHtml(text) {
|
||||
|
||||
const esc = escapeProfileHtml;
|
||||
|
||||
// Раздел статуса («Сияние», «Официальный»): кто подтвердил этот аккаунт и кого подтвердил он сам.
|
||||
function statusSectionHtml({ kind, title, received, given, receivedLabel, givenLabel }) {
|
||||
const receivedCount = Number(received || 0);
|
||||
const givenCount = Number(given || 0);
|
||||
// Карточка статуса у аватара: кто подтвердил этот аккаунт и кого подтвердил он сам.
|
||||
function statusSideHtml({ kind, title, active, received, given, verb }) {
|
||||
const isOfficial = kind === 'primary';
|
||||
const receivedKind = isOfficial ? 'primary_received' : 'shine_received';
|
||||
const givenKind = isOfficial ? 'primary_given' : 'shine_given';
|
||||
return `
|
||||
<section class="pf-status-section pf-status-section--${esc(kind)}" aria-label="${esc(title)}">
|
||||
<h3 class="nav-list__title">${esc(title)}</h3>
|
||||
<div class="nav-list">
|
||||
<button type="button" class="nav-row" data-profile-list="${isOfficial ? 'primary_received' : 'shine_received'}">
|
||||
<span class="nav-row__label">${esc(receivedLabel)}</span>
|
||||
<span class="nav-row__hint">${esc(peopleCount(receivedCount))}</span>
|
||||
</button>
|
||||
<button type="button" class="nav-row" data-profile-list="${isOfficial ? 'primary_given' : 'shine_given'}">
|
||||
<span class="nav-row__label">${esc(givenLabel)}</span>
|
||||
<span class="nav-row__hint">${esc(peopleCount(givenCount))}</span>
|
||||
</button>
|
||||
</div>
|
||||
<section class="pf-sc pf-sc--${esc(kind)}${active ? ' is-active' : ' is-empty'}" aria-label="${esc(title)}">
|
||||
<div class="pf-sc__title">${esc(title)}</div>
|
||||
<button type="button" class="pf-sc__row" data-profile-list="${receivedKind}" aria-label="${esc(title)}: подтвердили ${Number(received || 0)}">
|
||||
<strong>${Number(received || 0)}</strong><span>подтвердили</span>
|
||||
</button>
|
||||
<button type="button" class="pf-sc__row" data-profile-list="${givenKind}" aria-label="${esc(title)}: ${esc(verb)} ${Number(given || 0)}">
|
||||
<strong>${Number(given || 0)}</strong><span>${esc(verb)}</span>
|
||||
</button>
|
||||
</section>`;
|
||||
}
|
||||
|
||||
function peopleCount(count) {
|
||||
if (!count) return 'Пока никого';
|
||||
const mod10 = count % 10;
|
||||
const mod100 = count % 100;
|
||||
const word = mod10 === 1 && mod100 !== 11 ? 'человек' : (mod10 >= 2 && mod10 <= 4 && (mod100 < 12 || mod100 > 14)) ? 'человека' : 'человек';
|
||||
return `${count} ${word}`;
|
||||
}
|
||||
|
||||
function statHtml({ kind, label, valueHtml, ariaLabel }) {
|
||||
return `
|
||||
<button type="button" class="pf-stat" data-profile-list="${esc(kind)}" aria-label="${esc(ariaLabel)}">
|
||||
@@ -103,39 +91,26 @@ export function profileCardHtml({ card, login = '', tilesHtml = '', tilesWrapCla
|
||||
const shineGiven = Number(stats.shineGivenCount || 0);
|
||||
const primaryReceived = Number(stats.primaryReceivedCount || 0);
|
||||
const primaryGiven = Number(stats.primaryGivenCount || 0);
|
||||
// Раздел виден у сияющих и у всех, кого уже подтверждали или кто подтверждал сам.
|
||||
const shineSection = (shining || shineReceived || shineGiven)
|
||||
? statusSectionHtml({
|
||||
kind: 'shine',
|
||||
title: 'Сияние',
|
||||
received: shineReceived,
|
||||
given: shineGiven,
|
||||
receivedLabel: 'Подтвердили, что сияющий',
|
||||
givenLabel: 'Подтвердил сияющими',
|
||||
})
|
||||
// Статусы по бокам аватара: слева «Официальный», справа «Сияние». На своём профиле – всегда
|
||||
// (пустая сторона бледнее), на чужом – если статус есть или уже есть подтверждения.
|
||||
const verb = card?.gender === 'female' ? 'подтвердила' : card?.gender === 'male' ? 'подтвердил' : 'подтвердил(а)';
|
||||
const officialSide = (isSelf || official || primaryReceived || primaryGiven)
|
||||
? statusSideHtml({ kind: 'primary', title: 'Официальный', active: official, received: primaryReceived, given: primaryGiven, verb })
|
||||
: '';
|
||||
const officialSection = (official || primaryReceived || primaryGiven)
|
||||
? statusSectionHtml({
|
||||
kind: 'primary',
|
||||
title: 'Официальный аккаунт',
|
||||
received: primaryReceived,
|
||||
given: primaryGiven,
|
||||
receivedLabel: 'Подтвердили, что официальный',
|
||||
givenLabel: 'Подтвердил официальными',
|
||||
})
|
||||
const shineSide = (isSelf || shining || shineReceived || shineGiven)
|
||||
? statusSideHtml({ kind: 'shine', title: 'Сияющий', active: shining, received: shineReceived, given: shineGiven, verb })
|
||||
: '';
|
||||
const badges = [
|
||||
shining ? '<span class="pf-badge pf-badge--shine">Сияющий</span>' : '',
|
||||
official ? '<span class="pf-badge pf-badge--official">Официальный</span>' : '',
|
||||
].join('');
|
||||
|
||||
return `
|
||||
<div class="pf-hero" aria-label="Профиль ${esc(cardLogin)}">
|
||||
<div class="pf-avatar user-profile-avatar-slot${shining ? ' is-shining' : ''}"></div>
|
||||
<div class="pf-identity">
|
||||
<div class="pf-side pf-side--left">${officialSide}</div>
|
||||
<div class="pf-avatar user-profile-avatar-slot${shining ? ' is-shining' : ''}"></div>
|
||||
<div class="pf-side pf-side--right">${shineSide}</div>
|
||||
</div>
|
||||
<h2 class="pf-name">${esc(displayName)}</h2>
|
||||
<div class="pf-login">@${esc(cardLogin)}</div>
|
||||
${city ? `<div class="pf-city">${iconHtml('place')}<span>${esc(city)}</span></div>` : ''}
|
||||
${badges ? `<div class="pf-badges">${badges}</div>` : ''}
|
||||
</div>
|
||||
|
||||
<div class="pf-stats">
|
||||
@@ -150,8 +125,6 @@ export function profileCardHtml({ card, login = '', tilesHtml = '', tilesWrapCla
|
||||
<div class="pf-tiles user-profile-actions">${tilesHtml}</div>
|
||||
</div>` : ''}
|
||||
|
||||
${shineSection}
|
||||
${officialSection}
|
||||
${listHtml}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user