Message / Reactions: Fix layout (#2940)
This commit is contained in:
parent
11d77e14c4
commit
690c77c3b5
@ -5,6 +5,7 @@ import React, {
|
|||||||
import { getGlobal } from '../../global';
|
import { getGlobal } from '../../global';
|
||||||
|
|
||||||
import { ANIMATION_LEVEL_MAX } from '../../config';
|
import { ANIMATION_LEVEL_MAX } from '../../config';
|
||||||
|
import buildClassName from '../../util/buildClassName';
|
||||||
import useLang from '../../hooks/useLang';
|
import useLang from '../../hooks/useLang';
|
||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
|
|
||||||
@ -12,10 +13,12 @@ import styles from './AnimatedCounter.module.scss';
|
|||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
text: string;
|
text: string;
|
||||||
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const AnimatedCounter: FC<OwnProps> = ({
|
const AnimatedCounter: FC<OwnProps> = ({
|
||||||
text,
|
text,
|
||||||
|
className,
|
||||||
}) => {
|
}) => {
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
|
|
||||||
@ -59,7 +62,7 @@ const AnimatedCounter: FC<OwnProps> = ({
|
|||||||
}, [text]);
|
}, [text]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={styles.root} dir={lang.isRtl ? 'rtl' : undefined}>
|
<span className={buildClassName(styles.root, className)} dir={lang.isRtl ? 'rtl' : undefined}>
|
||||||
{textElement}
|
{textElement}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
width: 1.75rem;
|
width: 1.75rem;
|
||||||
height: 1.75rem;
|
height: 1.75rem;
|
||||||
margin-right: 0.125rem;
|
margin-inline-end: 0.125rem;
|
||||||
|
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|
||||||
&.is-custom-emoji {
|
&.is-custom-emoji {
|
||||||
margin-right: 0.375rem;
|
margin-inline-end: 0.375rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -78,7 +78,7 @@ const ReactionButton: FC<{
|
|||||||
<div className="avatars">
|
<div className="avatars">
|
||||||
{recentReactors.map((user) => <Avatar user={user} size="micro" />)}
|
{recentReactors.map((user) => <Avatar user={user} size="micro" />)}
|
||||||
</div>
|
</div>
|
||||||
) : <AnimatedCounter text={formatIntegerCompact(reaction.count)} />}
|
) : <AnimatedCounter text={formatIntegerCompact(reaction.count)} className="counter" />}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -33,7 +33,8 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
.Avatar {
|
.Avatar {
|
||||||
margin: 0 0 0 -0.25rem;
|
margin: 0;
|
||||||
|
margin-inline-start: -0.25rem;
|
||||||
border: 0.0625rem solid var(--reaction-background);
|
border: 0.0625rem solid var(--reaction-background);
|
||||||
width: 1.5rem;
|
width: 1.5rem;
|
||||||
height: 1.5rem;
|
height: 1.5rem;
|
||||||
@ -50,16 +51,20 @@
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.counter {
|
||||||
|
margin-inline-end: 0.125rem;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
--reaction-background: var(--hover-color-reaction);
|
--reaction-background: var(--hover-color-reaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:first-of-type {
|
&:first-of-type {
|
||||||
margin-left: 0;
|
margin-inline-start: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
margin-right: 0;
|
margin-inline-end: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,13 +77,13 @@
|
|||||||
|
|
||||||
.Button {
|
.Button {
|
||||||
&:first-of-type {
|
&:first-of-type {
|
||||||
margin-left: 0.125rem;
|
margin-inline-start: 0.125rem;
|
||||||
margin-right: 0;
|
margin-inline-end: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
margin-right: 0.125rem;
|
margin-inline-end: 0.125rem;
|
||||||
margin-left: 0;
|
margin-inline-start: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import type { ObserveFn } from '../../../hooks/useIntersectionObserver';
|
|||||||
|
|
||||||
import { getReactionUniqueKey } from '../../../global/helpers';
|
import { getReactionUniqueKey } from '../../../global/helpers';
|
||||||
import buildClassName from '../../../util/buildClassName';
|
import buildClassName from '../../../util/buildClassName';
|
||||||
|
import useLang from '../../../hooks/useLang';
|
||||||
|
|
||||||
import ReactionButton from './ReactionButton';
|
import ReactionButton from './ReactionButton';
|
||||||
|
|
||||||
@ -37,6 +38,8 @@ const Reactions: FC<OwnProps> = ({
|
|||||||
observeIntersection,
|
observeIntersection,
|
||||||
noRecentReactors,
|
noRecentReactors,
|
||||||
}) => {
|
}) => {
|
||||||
|
const lang = useLang();
|
||||||
|
|
||||||
const totalCount = useMemo(() => (
|
const totalCount = useMemo(() => (
|
||||||
message.reactions!.results.reduce((acc, reaction) => acc + reaction.count, 0)
|
message.reactions!.results.reduce((acc, reaction) => acc + reaction.count, 0)
|
||||||
), [message]);
|
), [message]);
|
||||||
@ -45,6 +48,7 @@ const Reactions: FC<OwnProps> = ({
|
|||||||
<div
|
<div
|
||||||
className={buildClassName('Reactions', isOutside && 'is-outside')}
|
className={buildClassName('Reactions', isOutside && 'is-outside')}
|
||||||
style={maxWidth ? `max-width: ${maxWidth}px` : undefined}
|
style={maxWidth ? `max-width: ${maxWidth}px` : undefined}
|
||||||
|
dir={lang.isRtl ? 'rtl' : 'ltr'}
|
||||||
>
|
>
|
||||||
{message.reactions!.results.map((reaction) => (
|
{message.reactions!.results.map((reaction) => (
|
||||||
<ReactionButton
|
<ReactionButton
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user