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('items-wrapper')}>
<div className={cn('items', ['no-scrollbar'])} ref={itemsScrollRef}>
{availableReactions?.map((reaction) => {
{availableReactions?.map((reaction, i) => {
if (reaction.isInactive
|| (!isPrivate && (!enabledReactions || !enabledReactions.includes(reaction.reaction)))) return undefined;
return (
<ReactionSelectorReaction
key={reaction.reaction}
previewIndex={i}
isReady={isReady}
onSendReaction={onSendReaction}
reaction={reaction}

View File

@ -16,50 +16,6 @@
left: 0;
background: url('../../../assets/reaction-thumbs.png') no-repeat;
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 {

View File

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