Evenly space reactions

This commit is contained in:
Half-Shot 2024-11-14 15:32:13 +00:00
parent c770603beb
commit b49bfbb481
2 changed files with 51 additions and 10 deletions

View File

@ -4,19 +4,35 @@
.reactionPopupMenu { .reactionPopupMenu {
display: flex; display: flex;
width: fit-content;
} }
.reactionPopupMenuModal { .reactionPopupMenuModal {
top: 82vh !important; top: 82vh !important;
} }
.reactionPopupMenu section { .reactionPopupMenuRoot {
height: fit-content; width: fit-content !important;
flex: auto;
} }
.reactionsMenuSection { .reactionPopupMenuRoot > div {
width: fit-content;
}
.reactionPopupMenuModal > div > div {
padding-inline: var(--cpd-space-6x) !important;
padding-block: var(--cpd-space-6x) !important;
}
.reactionPopupMenu section {
height: fit-content;
flex: 1;
max-width: fit-content;
}
.reactionPopupMenu section.reactionsMenuSection {
margin: auto 0; margin: auto 0;
flex: auto;
} }
:root { :root {
@ -31,8 +47,7 @@
); );
margin: 0; margin: 0;
padding: 0; padding: 0;
display: flex; flex-grow: 1;
flex-wrap: wrap;
gap: var(--cpd-separator-spacing); gap: var(--cpd-separator-spacing);
/* Height of 3 rows plus padding. */ /* Height of 3 rows plus padding. */
max-height: calc( max-height: calc(
@ -41,9 +56,26 @@
var(--cpd-separator-spacing) var(--cpd-separator-spacing)
) * 4 ) * 4
); );
max-width: 22.5em; width: calc(
(
var(--reaction-button-size) + var(--reaction-button-padding) +
var(--cpd-separator-spacing)
) * 6.5
);
overflow-x: hidden;
overflow-y: auto; overflow-y: auto;
list-style: none; list-style: none;
flex-wrap: wrap;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: start;
align-items: auto;
align-content: start;
}
.reactionsMenu > * {
flex: 0 0 auto;
} }
.reactionButton { .reactionButton {

View File

@ -79,10 +79,9 @@ export function ReactionPopupMenu({
const [isFullyExpanded, setExpanded] = useState(false); const [isFullyExpanded, setExpanded] = useState(false);
const filteredReactionSet = useMemo( const filteredReactionSet = useMemo(
() => (isFullyExpanded ? ReactionSet : ReactionSet.slice(0, 6)), () => (isFullyExpanded ? ReactionSet : ReactionSet.slice(0, 5)),
[isFullyExpanded], [isFullyExpanded],
); );
const label = isHandRaised ? t("action.lower_hand") : t("action.raise_hand"); const label = isHandRaised ? t("action.lower_hand") : t("action.raise_hand");
return ( return (
<> <>
@ -110,7 +109,12 @@ export function ReactionPopupMenu({
</section> </section>
<div className={styles.verticalSeperator} /> <div className={styles.verticalSeperator} />
<section className={styles.reactionsMenuSection}> <section className={styles.reactionsMenuSection}>
<menu className={styles.reactionsMenu}> <menu
className={classNames(
isFullyExpanded && styles.reactionsMenuExpanded,
styles.reactionsMenu,
)}
>
{filteredReactionSet.map((reaction) => ( {filteredReactionSet.map((reaction) => (
<li key={reaction.name}> <li key={reaction.name}>
<Tooltip label={reaction.name}> <Tooltip label={reaction.name}>
@ -173,6 +177,10 @@ export function ReactionToggleButton({
setErrorText(undefined); setErrorText(undefined);
}, [showReactionsMenu]); }, [showReactionsMenu]);
useEffect(() => {
return () => setShowReactionsMenu(false);
}, [setShowReactionsMenu]);
const canReact = !reactions[userId]; const canReact = !reactions[userId];
const sendRelation = useCallback( const sendRelation = useCallback(
@ -273,6 +281,7 @@ export function ReactionToggleButton({
title={t("action.pick_reaction")} title={t("action.pick_reaction")}
hideHeader hideHeader
classNameModal={styles.reactionPopupMenuModal} classNameModal={styles.reactionPopupMenuModal}
className={styles.reactionPopupMenuRoot}
onDismiss={() => setShowReactionsMenu(false)} onDismiss={() => setShowReactionsMenu(false)}
> >
<ReactionPopupMenu <ReactionPopupMenu