Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(chat): dim reaction chips you have already added (#7066)

Wolf Mermelsteinc584f0579784
diff --git a/apps/web/src/features/channel/Message/ReactionChip.tsx b/apps/web/src/features/channel/Message/ReactionChip.tsx
index 633b9b8d1a..bc624b0feb 100644
--- a/apps/web/src/features/channel/Message/ReactionChip.tsx
+++ b/apps/web/src/features/channel/Message/ReactionChip.tsx
@@ -78,6 +78,7 @@ export function ReactionChip(props: ReactionChipProps) {
<Button
data-message-reaction-chip
data-emoji={props.emoji}
+ data-user-reacted={props.selected ? '' : undefined}
noTouchResize
ref={(el) =>
touchHandler(el, () => ({
@@ -91,10 +92,11 @@ export function ReactionChip(props: ReactionChipProps) {
variant={props.selected ? 'accent' : 'outline'}
class={cn(
'flex flex-row items-center h-7 min-w-7 gap-1 rounded-full',
- {
- 'border-accent/10': props.selected,
- 'pointer-events-auto': !props.interactive,
- }
+ // Mix toward black, not ink. An ink wash lightens a dark theme, so
+ // it cannot show "you reacted" in both themes.
+ props.selected &&
+ 'bg-[color-mix(in_oklch,oklch(0_0_0)_16%,var(--color-control))] dark-mode:bg-[color-mix(in_oklch,oklch(0_0_0)_34%,var(--color-control))]',
+ !props.interactive && 'pointer-events-auto'
)}
disabled={!props.interactive}
onClick={(event) => {
diff --git a/apps/web/src/features/channel/Message/tests/reactions.test.tsx b/apps/web/src/features/channel/Message/tests/reactions.test.tsx
index 88144fbb2e..a6ae1a6046 100644
--- a/apps/web/src/features/channel/Message/tests/reactions.test.tsx
+++ b/apps/web/src/features/channel/Message/tests/reactions.test.tsx
@@ -48,6 +48,41 @@ describe('Reactions', () => {
expect(screen.queryByRole('button', { name: 'Add reaction' })).toBeNull();
});
+ it('dims a reaction the current user already added', () => {
+ render(() => (
+ <Root
+ message={{
+ ...baseMessage,
+ reactions: [
+ { emoji: '❤️', users: ['user-1', 'user-2'] },
+ { emoji: '👍', users: ['user-3'] },
+ ],
+ }}
+ actions={{
+ onReact: () => undefined,
+ }}
+ >
+ <Reactions />
+ </Root>
+ ));
+
+ const chips = () =>
+ screen
+ .getAllByRole('button')
+ .filter((el) => el.hasAttribute('data-message-reaction-chip'));
+ const heart = chips().find((el) => el.dataset.emoji === '❤️');
+ const thumb = chips().find((el) => el.dataset.emoji === '👍');
+
+ expect(heart?.hasAttribute('data-user-reacted')).toBe(true);
+ expect(heart?.className).toContain(
+ 'bg-[color-mix(in_oklch,oklch(0_0_0)_16%,var(--color-control))]'
+ );
+ expect(thumb?.hasAttribute('data-user-reacted')).toBe(false);
+ expect(thumb?.className).not.toContain(
+ 'bg-[color-mix(in_oklch,oklch(0_0_0)_16%,var(--color-control))]'
+ );
+ });
+
it('calls onReact with chip emoji when a reaction chip is clicked', async () => {
const user = userEvent.setup({ skipHover: true });
const onReact = vi.fn();