Management / Boosts: Fix styles and format for boost statistics (#4552)

This commit is contained in:
Alexander Zinchuk 2024-05-14 04:23:46 +02:00
parent 84af0ce28a
commit c15c8a0eed
5 changed files with 24 additions and 8 deletions

View File

@ -12,7 +12,9 @@
} }
.badgeContainer { .badgeContainer {
--shift-x: calc(clamp(10%, var(--percent), 90%) - 50%); --min-shift: calc(10% + var(--digits-count, 1) * 0.4ch);
--max-shift: calc(85% - var(--digits-count, 1) * 0.4ch);
--shift-x: calc(clamp(var(--min-shift), var(--percent), var(--max-shift)) - 50%);
display: flex; display: flex;
justify-content: center; justify-content: center;
position: absolute; position: absolute;

View File

@ -35,6 +35,7 @@ const LimitPreview: FC<OwnProps> = ({
const hasFloatingBadge = Boolean(floatingBadgeIcon || floatingBadgeText); const hasFloatingBadge = Boolean(floatingBadgeIcon || floatingBadgeText);
const isProgressFull = Boolean(progress) && progress > 0.99; const isProgressFull = Boolean(progress) && progress > 0.99;
const digitsCount = floatingBadgeText?.length;
const tailPosition = progress && (progress < PROGRESS_LOCK ? 0 : progress > 1 - PROGRESS_LOCK ? 1 : 0.5); const tailPosition = progress && (progress < PROGRESS_LOCK ? 0 : progress > 1 - PROGRESS_LOCK ? 1 : 0.5);
@ -48,6 +49,7 @@ const LimitPreview: FC<OwnProps> = ({
style={buildStyle( style={buildStyle(
progress !== undefined && `--progress: ${progress}`, progress !== undefined && `--progress: ${progress}`,
tailPosition !== undefined && `--tail-position: ${tailPosition}`, tailPosition !== undefined && `--tail-position: ${tailPosition}`,
digitsCount !== undefined && `--digits-count: ${digitsCount}`,
)} )}
> >
{hasFloatingBadge && ( {hasFloatingBadge && (

View File

@ -34,6 +34,7 @@
.down { .down {
font-size: 1.5rem; font-size: 1.5rem;
margin-right: 0.5rem;
} }
.loadMoreSpinner { .loadMoreSpinner {
@ -106,3 +107,7 @@
display: flex; display: flex;
flex-direction: column-reverse; flex-direction: column-reverse;
} }
.giveawayButton {
margin-bottom: 0.5rem;
}

View File

@ -18,6 +18,7 @@ import {
import buildClassName from '../../../util/buildClassName'; import buildClassName from '../../../util/buildClassName';
import { formatDateAtTime } from '../../../util/date/dateFormat'; import { formatDateAtTime } from '../../../util/date/dateFormat';
import { CUSTOM_PEER_TO_BE_DISTRIBUTED } from '../../../util/objects/customPeer'; import { CUSTOM_PEER_TO_BE_DISTRIBUTED } from '../../../util/objects/customPeer';
import { formatInteger } from '../../../util/textFormat';
import { getBoostProgressInfo } from '../../common/helpers/boostInfo'; import { getBoostProgressInfo } from '../../common/helpers/boostInfo';
import useLang from '../../../hooks/useLang'; import useLang from '../../../hooks/useLang';
@ -111,12 +112,18 @@ const BoostStatistics = ({
const tabs = useMemo(() => { const tabs = useMemo(() => {
if (shouldDisplayGiftList) { if (shouldDisplayGiftList) {
return [ return [
{ type: 'boostList', title: lang('BoostingBoostsCount', boostStatistics?.boosts?.count) }, {
{ type: 'giftedBoostList', title: lang('BoostingGiftsCount', boostStatistics?.giftedBoosts?.count) }, type: 'boostList',
title: lang('BoostingBoostsCount', boostStatistics?.boosts?.count, 'i'),
},
{
type: 'giftedBoostList',
title: lang('BoostingGiftsCount', boostStatistics?.giftedBoosts?.count, 'i'),
},
]; ];
} }
return []; return [];
}, [shouldDisplayGiftList, boostStatistics?.boosts?.count, boostStatistics?.giftedBoosts?.count, lang]); }, [shouldDisplayGiftList, lang, boostStatistics?.boosts?.count, boostStatistics?.giftedBoosts?.count]);
const initialTab = useMemo(() => { const initialTab = useMemo(() => {
return boostStatistics?.boosts && boostStatistics.boosts?.list.length > 0 ? 1 : 0; return boostStatistics?.boosts && boostStatistics.boosts?.list.length > 0 ? 1 : 0;
@ -252,7 +259,7 @@ const BoostStatistics = ({
leftText={lang('BoostsLevel', currentLevel!)} leftText={lang('BoostsLevel', currentLevel!)}
rightText={hasNextLevel ? lang('BoostsLevel', currentLevel! + 1) : undefined} rightText={hasNextLevel ? lang('BoostsLevel', currentLevel! + 1) : undefined}
progress={levelProgress} progress={levelProgress}
floatingBadgeText={boosts.toString()} floatingBadgeText={formatInteger(boosts)}
floatingBadgeIcon="boost" floatingBadgeIcon="boost"
/> />
<StatisticsOverview className={styles.stats} statistics={statsOverview} type="boost" /> <StatisticsOverview className={styles.stats} statistics={statsOverview} type="boost" />
@ -338,14 +345,14 @@ const BoostStatistics = ({
) : ( ) : (
<Icon name="down" className={styles.down} /> <Icon name="down" className={styles.down} />
)} )}
{lang('ShowVotes', boostersToLoadCount)} {lang('ShowVotes', boostersToLoadCount, 'i')}
</ListItem> </ListItem>
)} )}
</div> </div>
<LinkField className={styles.section} link={status!.boostUrl} withShare title={lang('LinkForBoosting')} /> <LinkField className={styles.section} link={status!.boostUrl} withShare title={lang('LinkForBoosting')} />
{isGiveawayAvailable && ( {isGiveawayAvailable && (
<div className={styles.section}> <div className={styles.section}>
<ListItem icon="gift" ripple onClick={handleGiveawayClick}> <ListItem icon="gift" ripple onClick={handleGiveawayClick} className={styles.giveawayButton}>
{lang('BoostingGetBoostsViaGifts')} {lang('BoostingGetBoostsViaGifts')}
</ListItem> </ListItem>
<p className="text-muted hint" key="links-hint">{lang( <p className="text-muted hint" key="links-hint">{lang(

View File

@ -3033,8 +3033,8 @@ export interface ActionPayloads {
forMultipleUsers?: boolean; forMultipleUsers?: boolean;
forUserIds?: string[]; forUserIds?: string[];
} & WithTabId) | undefined; } & WithTabId) | undefined;
closeGiftPremiumModal: WithTabId | undefined; closeGiftPremiumModal: WithTabId | undefined;
setEmojiStatus: { setEmojiStatus: {
emojiStatus: ApiSticker; emojiStatus: ApiSticker;
expires?: number; expires?: number;