Skip to content

Commit 13f85d8

Browse files
BillLeoutsakosvl346Bill Leoutsakos
authored andcommitted
improvement(ui): reuse compact buttons for message actions (#8087)
Co-authored-by: Bill Leoutsakos <billleoutsakos@Mac.localdomain>
1 parent 18c007a commit 13f85d8

2 files changed

Lines changed: 23 additions & 15 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/components/message-actions/message-actions.test.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @vitest-environment jsdom
33
*/
4-
import { act, type ReactNode } from 'react'
4+
import { act, type ComponentProps, type ReactNode } from 'react'
55
import { createRoot, type Root } from 'react-dom/client'
66
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
77

@@ -19,6 +19,11 @@ vi.mock('next/navigation', () => ({
1919
}))
2020

2121
vi.mock('@sim/emcn', () => ({
22+
Button: ({
23+
variant,
24+
iconSize,
25+
...props
26+
}: ComponentProps<'button'> & { variant?: string; iconSize?: string }) => <button {...props} />,
2227
Check: () => null,
2328
Duplicate: () => null,
2429
Split: () => null,

‎apps/sim/app/workspace/[workspaceId]/components/message-actions/message-actions.tsx‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { memo, useEffect, useRef, useState } from 'react'
44
import {
5+
Button,
56
Check,
67
ChipModal,
78
ChipModalBody,
@@ -27,8 +28,6 @@ import { useForkMothershipChat } from '@/hooks/queries/mothership-chats'
2728
import { useFolderStore } from '@/stores/folders/store'
2829

2930
const ICON_CLASS = 'size-[14px]'
30-
const BUTTON_CLASS =
31-
'flex size-[26px] items-center justify-center rounded-[6px] text-[var(--text-icon)] transition-colors hover-hover:bg-[var(--surface-hover)] focus-visible:outline-hidden'
3231

3332
interface MessageActionsProps {
3433
content: string
@@ -162,14 +161,15 @@ export const MessageActions = memo(function MessageActions({
162161
{canCopyContent && (
163162
<Tooltip.Root>
164163
<Tooltip.Trigger asChild>
165-
<button
164+
<Button
166165
type='button'
167166
aria-label='Copy message'
168167
onClick={copyToClipboard}
169-
className={BUTTON_CLASS}
168+
variant='quiet'
169+
iconSize='compact-fixed'
170170
>
171171
{copied ? <Check className={ICON_CLASS} /> : <Duplicate className={ICON_CLASS} />}
172-
</button>
172+
</Button>
173173
</Tooltip.Trigger>
174174
<Tooltip.Content side='top'>
175175
{copied ? 'Copied message' : 'Copy message'}
@@ -180,27 +180,29 @@ export const MessageActions = memo(function MessageActions({
180180
<>
181181
<Tooltip.Root>
182182
<Tooltip.Trigger asChild>
183-
<button
183+
<Button
184184
type='button'
185185
aria-label='Like'
186186
onClick={() => handleFeedbackClick('up')}
187-
className={BUTTON_CLASS}
187+
variant='quiet'
188+
iconSize='compact-fixed'
188189
>
189190
<ThumbsUp className={ICON_CLASS} />
190-
</button>
191+
</Button>
191192
</Tooltip.Trigger>
192193
<Tooltip.Content side='top'>Good response</Tooltip.Content>
193194
</Tooltip.Root>
194195
<Tooltip.Root>
195196
<Tooltip.Trigger asChild>
196-
<button
197+
<Button
197198
type='button'
198199
aria-label='Dislike'
199200
onClick={() => handleFeedbackClick('down')}
200-
className={BUTTON_CLASS}
201+
variant='quiet'
202+
iconSize='compact-fixed'
201203
>
202204
<ThumbsDown className={ICON_CLASS} />
203-
</button>
205+
</Button>
204206
</Tooltip.Trigger>
205207
<Tooltip.Content side='top'>Bad response</Tooltip.Content>
206208
</Tooltip.Root>
@@ -209,15 +211,16 @@ export const MessageActions = memo(function MessageActions({
209211
{canFork && (
210212
<Tooltip.Root>
211213
<Tooltip.Trigger asChild>
212-
<button
214+
<Button
213215
type='button'
214216
aria-label='Fork in new chat'
215217
onClick={handleFork}
216218
disabled={forkChat.isPending}
217-
className={cn(BUTTON_CLASS, forkChat.isPending && 'cursor-not-allowed opacity-50')}
219+
variant='quiet'
220+
iconSize='compact-fixed'
218221
>
219222
<Split className={cn(ICON_CLASS, 'rotate-90')} />
220-
</button>
223+
</Button>
221224
</Tooltip.Trigger>
222225
<Tooltip.Content side='top'>Fork in new chat</Tooltip.Content>
223226
</Tooltip.Root>

0 commit comments

Comments
 (0)