Reactions: Add previews for new reactions

This commit is contained in:
Alexander Zinchuk 2022-02-01 04:36:13 +01:00
parent e5062ef42c
commit b1036d2d62
4 changed files with 6 additions and 47 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -55,12 +55,13 @@ const ReactionSelector: FC<OwnProps> = ({
<div className={cn('bubble-small')} /> <div className={cn('bubble-small')} />
<div className={cn('items-wrapper')}> <div className={cn('items-wrapper')}>
<div className={cn('items', ['no-scrollbar'])} ref={itemsScrollRef}> <div className={cn('items', ['no-scrollbar'])} ref={itemsScrollRef}>
{availableReactions?.map((reaction) => { {availableReactions?.map((reaction, i) => {
if (reaction.isInactive if (reaction.isInactive
|| (!isPrivate && (!enabledReactions || !enabledReactions.includes(reaction.reaction)))) return undefined; || (!isPrivate && (!enabledReactions || !enabledReactions.includes(reaction.reaction)))) return undefined;
return ( return (
<ReactionSelectorReaction <ReactionSelectorReaction
key={reaction.reaction} key={reaction.reaction}
previewIndex={i}
isReady={isReady} isReady={isReady}
onSendReaction={onSendReaction} onSendReaction={onSendReaction}
reaction={reaction} reaction={reaction}

View File

@ -16,50 +16,6 @@
left: 0; left: 0;
background: url('../../../assets/reaction-thumbs.png') no-repeat; background: url('../../../assets/reaction-thumbs.png') no-repeat;
background-size: auto 100%; background-size: auto 100%;
&--reaction-👍 {
background-position-x: 0;
}
&--reaction-👎 {
background-position-x: -32px;
}
&--reaction- {
background-position-x: -64px;
}
&--reaction-🔥 {
background-position-x: -96px;
}
&--reaction-🎉 {
background-position-x: -128px;
}
&--reaction-🤩 {
background-position-x: -160px;
}
&--reaction-😱 {
background-position-x: -192px;
}
&--reaction-😁 {
background-position-x: -224px;
}
&--reaction-😢 {
background-position-x: -256px;
}
&--reaction-💩 {
background-position-x: -288px;
}
&--reaction-🤮 {
background-position-x: -320px;
}
} }
.AnimatedSticker { .AnimatedSticker {

View File

@ -17,13 +17,14 @@ const REACTION_SIZE = 32;
type OwnProps = { type OwnProps = {
reaction: ApiAvailableReaction; reaction: ApiAvailableReaction;
previewIndex: number;
isReady?: boolean; isReady?: boolean;
onSendReaction: (reaction: string, x: number, y: number) => void; onSendReaction: (reaction: string, x: number, y: number) => void;
}; };
const cn = createClassNameBuilder('ReactionSelectorReaction'); const cn = createClassNameBuilder('ReactionSelectorReaction');
const ReactionSelectorReaction: FC<OwnProps> = ({ reaction, onSendReaction, isReady }) => { const ReactionSelectorReaction: FC<OwnProps> = ({ reaction, previewIndex, onSendReaction, isReady }) => {
// eslint-disable-next-line no-null/no-null // eslint-disable-next-line no-null/no-null
const containerRef = useRef<HTMLDivElement>(null); const containerRef = useRef<HTMLDivElement>(null);
@ -56,9 +57,10 @@ const ReactionSelectorReaction: FC<OwnProps> = ({ reaction, onSendReaction, isRe
<div <div
className={cn( className={cn(
'static', 'static',
`reaction-${reaction.reaction}`,
isReady ? [staticClassNames] : undefined, isReady ? [staticClassNames] : undefined,
)} )}
// @ts-ignore
style={`background-position-x: ${previewIndex * -32}px;`}
/> />
)} )}
{shouldRenderAnimated && ( {shouldRenderAnimated && (