Profile: Design tweaks (#6299)

This commit is contained in:
zubiden 2025-09-30 16:52:24 +02:00 committed by Alexander Zinchuk
parent 11b8d0c318
commit 3e19a911e1
4 changed files with 36 additions and 11 deletions

View File

@ -35,7 +35,7 @@ import renderText from './helpers/renderText';
import { useFastClick } from '../../hooks/useFastClick'; import { useFastClick } from '../../hooks/useFastClick';
import useLastCallback from '../../hooks/useLastCallback'; import useLastCallback from '../../hooks/useLastCallback';
import useMedia from '../../hooks/useMedia'; import useMedia from '../../hooks/useMedia';
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated'; import useMediaTransition from '../../hooks/useMediaTransition';
import useOldLang from '../../hooks/useOldLang'; import useOldLang from '../../hooks/useOldLang';
import OptimizedVideo from '../ui/OptimizedVideo'; import OptimizedVideo from '../ui/OptimizedVideo';
@ -189,7 +189,7 @@ const Avatar: FC<OwnProps> = ({
// `videoBlobUrl` can be taken from memory cache, so we need to check `shouldLoadVideo` again // `videoBlobUrl` can be taken from memory cache, so we need to check `shouldLoadVideo` again
const shouldPlayVideo = Boolean(videoBlobUrl && shouldLoadVideo); const shouldPlayVideo = Boolean(videoBlobUrl && shouldLoadVideo);
const transitionClassNames = useMediaTransitionDeprecated(hasBlobUrl); const { ref: mediaRef } = useMediaTransition<HTMLImageElement>({ hasMediaData: hasBlobUrl });
const handleVideoEnded = useLastCallback((e) => { const handleVideoEnded = useLastCallback((e) => {
const video = e.currentTarget; const video = e.currentTarget;
@ -221,8 +221,9 @@ const Avatar: FC<OwnProps> = ({
content = ( content = (
<> <>
<img <img
ref={mediaRef}
src={imgUrl} src={imgUrl}
className={buildClassName(cn.media, 'avatar-media', transitionClassNames, videoBlobUrl && 'poster')} className={buildClassName(cn.media, 'avatar-media', videoBlobUrl && 'poster')}
alt={author} alt={author}
decoding="async" decoding="async"
draggable={false} draggable={false}

View File

@ -104,6 +104,8 @@ const LOAD_MORE_THRESHOLD = 3;
const MAX_PHOTO_DASH_COUNT = 30; const MAX_PHOTO_DASH_COUNT = 30;
const STATUS_UPDATE_INTERVAL = 1000 * 60; // 1 min const STATUS_UPDATE_INTERVAL = 1000 * 60; // 1 min
const PATTERN_COLOR = '#000000'; const PATTERN_COLOR = '#000000';
const PATTERN_SIZE_FACTOR = 0.75;
const PATTERN_OPACITY = 0.75;
const ProfileInfo = ({ const ProfileInfo = ({
isExpanded, isExpanded,
@ -167,7 +169,7 @@ const ProfileInfo = ({
if (collectibleEmojiStatus) { if (collectibleEmojiStatus) {
return { return {
bgColors: [collectibleEmojiStatus.centerColor, collectibleEmojiStatus.edgeColor], bgColors: [collectibleEmojiStatus.centerColor, collectibleEmojiStatus.edgeColor],
storyColors: [collectibleEmojiStatus.centerColor, collectibleEmojiStatus.edgeColor], storyColors: [collectibleEmojiStatus.textColor, collectibleEmojiStatus.textColor],
}; };
} }
@ -482,7 +484,8 @@ const ProfileInfo = ({
patternIcon={backgroundEmoji} patternIcon={backgroundEmoji}
patternColor={collectibleEmojiStatus?.patternColor || PATTERN_COLOR} patternColor={collectibleEmojiStatus?.patternColor || PATTERN_COLOR}
className={styles.radialPatternBackground} className={styles.radialPatternBackground}
patternSize={0.75} patternSize={PATTERN_SIZE_FACTOR}
patternOpacity={collectibleEmojiStatus ? 1 : PATTERN_OPACITY}
/> />
)} )}
{pinnedGifts && ( {pinnedGifts && (

View File

@ -16,8 +16,19 @@
} }
.canvas { .canvas {
pointer-events: none;
position: relative; position: relative;
width: 100%; width: 100%;
height: 100%; height: 100%;
opacity: 0;
object-fit: cover; object-fit: cover;
transition: opacity 0.15s ease-out;
&.showing {
opacity: 1;
}
} }

View File

@ -9,6 +9,7 @@ import { getStickerMediaHash } from '../../../global/helpers';
import buildClassName from '../../../util/buildClassName'; import buildClassName from '../../../util/buildClassName';
import buildStyle from '../../../util/buildStyle'; import buildStyle from '../../../util/buildStyle';
import { preloadImage } from '../../../util/files'; import { preloadImage } from '../../../util/files';
import { clamp } from '../../../util/math';
import useLastCallback from '../../../hooks/useLastCallback'; import useLastCallback from '../../../hooks/useLastCallback';
import useMedia from '../../../hooks/useMedia'; import useMedia from '../../../hooks/useMedia';
@ -24,6 +25,7 @@ type OwnProps = {
className?: string; className?: string;
clearBottomSector?: boolean; clearBottomSector?: boolean;
patternSize?: number; patternSize?: number;
patternOpacity?: number;
}; };
const RINGS = 3; const RINGS = 3;
@ -39,6 +41,7 @@ const RadialPatternBackground = ({
backgroundColors, backgroundColors,
patternColor, patternColor,
patternIcon, patternIcon,
patternOpacity,
clearBottomSector, clearBottomSector,
className, className,
patternSize = 1, patternSize = 1,
@ -140,8 +143,11 @@ const RadialPatternBackground = ({
} }
const radialGradient = ctx.createRadialGradient(width / 2, height / 2, 0, width / 2, height / 2, width / 2); const radialGradient = ctx.createRadialGradient(width / 2, height / 2, 0, width / 2, height / 2, width / 2);
radialGradient.addColorStop(0, '#FFFFFF77');
radialGradient.addColorStop(1, '#FFFFFF'); const alpha = clamp(0.6 * (patternOpacity ?? 1), 0, 1);
radialGradient.addColorStop(0, `rgb(255 255 255 / ${1 - alpha})`);
radialGradient.addColorStop(1, `rgb(255 255 255 / 1)`);
// Alpha mask // Alpha mask
ctx.save(); ctx.save();
@ -153,12 +159,12 @@ const RadialPatternBackground = ({
useEffect(() => { useEffect(() => {
draw(); draw();
}, [emojiImage]); }, [emojiImage, patternOpacity, patternSize, patternColor, patternPositions]);
useEffect(() => { useEffect(() => {
const { width, height } = getContainerSize(); const { width, height } = getContainerSize();
const canvas = canvasRef.current!; const canvas = canvasRef.current;
if (!width || !height) { if (!width || !height || !canvas) {
return; return;
} }
@ -180,7 +186,11 @@ const RadialPatternBackground = ({
`--_bg-2: ${backgroundColors[1] || backgroundColors[0]}`, `--_bg-2: ${backgroundColors[1] || backgroundColors[0]}`,
)} )}
> >
<canvas className={styles.canvas} ref={canvasRef} /> <canvas
ref={canvasRef}
className={buildClassName(styles.canvas, emojiImage && styles.showing)}
aria-hidden="true"
/>
</div> </div>
); );
}; };