Skip to content

Commit 7bf8fe3

Browse files
BillLeoutsakosvl346Bill Leoutsakos
andauthored
improvement(ui): use shared geometry for standard icon actions (#8153)
Co-authored-by: Bill Leoutsakos <billleoutsakos@Bills-MacBook-Pro.local>
1 parent 2365885 commit 7bf8fe3

7 files changed

Lines changed: 18 additions & 19 deletions

File tree

‎apps/sim/app/(interfaces)/chat/components/input/public-chat-action-button.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { Button } from '@sim/emcn'
44
interface PublicChatActionButtonProps
55
extends Omit<
66
ComponentProps<typeof Button>,
7-
'variant' | 'size' | 'iconSize' | 'iconPadding' | 'className'
7+
'variant' | 'size' | 'iconSize' | 'iconPadding' | 'className' | 'shape'
88
> {
99
variant: 'primary' | 'quiet'
1010
'aria-label': string
1111
}
1212

1313
/** Public chat's circular composer action, retaining its primary and quiet palettes. */
1414
export const PublicChatActionButton = forwardRef<HTMLButtonElement, PublicChatActionButtonProps>(
15-
(props, ref) => <Button {...props} ref={ref} className='size-[28px] rounded-full p-0' />
15+
(props, ref) => <Button {...props} ref={ref} iconSize='regular' shape='round' />
1616
)
1717
PublicChatActionButton.displayName = 'PublicChatActionButton'

‎apps/sim/app/playground/page.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export default function PlaygroundPage() {
172172
aria-label='Go back'
173173
variant='ghost'
174174
onClick={() => router.back()}
175-
className='size-8 p-0'
175+
iconSize='roomy'
176176
>
177177
<ArrowLeft className='size-4' />
178178
</Button>
@@ -187,7 +187,7 @@ export default function PlaygroundPage() {
187187
aria-label={isDarkMode ? 'Light mode' : 'Dark mode'}
188188
variant='default'
189189
onClick={toggleDarkMode}
190-
className='size-8 p-0'
190+
iconSize='roomy'
191191
>
192192
{isDarkMode ? <Sun className='size-4' /> : <Moon className='size-4' />}
193193
</Button>

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/image.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ export function ResizableImageView({ node, selected, editor, getPos }: ReactNode
282282
type='button'
283283
variant='ghost'
284284
size='icon'
285+
iconSize={{ base: 'touch', sm: 'roomy' }}
286+
iconPadding='sm'
285287
aria-label='Resize image'
286288
onPointerDown={startResize}
287-
className='absolute right-0 bottom-0 flex size-10 cursor-nwse-resize touch-none items-end justify-end p-1 sm:size-8'
289+
className='absolute right-0 bottom-0 cursor-nwse-resize touch-none items-end justify-end'
288290
>
289291
<span className='size-3 rounded-[3px] border border-[var(--bg)] bg-[var(--brand-secondary)]' />
290292
</Button>

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/toolbar-button.test.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ describe('ToolbarButton', () => {
4141
)
4242

4343
const button = host.querySelector('button[aria-label="Add to Chat"]')
44-
expect(button?.className).toContain('size-[28px]')
44+
expect(button?.classList.contains('size-10')).toBe(true)
45+
expect(button?.classList.contains('sm:size-7')).toBe(true)
4546
expect(button?.querySelector('svg')?.className.baseVal).toContain('size-[12px]')
4647
})
4748

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/toolbar-button.tsx‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ComponentType, SVGProps } from 'react'
2-
import { Button, cn, Tooltip } from '@sim/emcn'
2+
import { Button, Tooltip } from '@sim/emcn'
33

44
interface ToolbarButtonProps {
55
/** Any SVG icon component, e.g. from `@sim/emcn/icons`. */
@@ -28,17 +28,15 @@ export function ToolbarButton({
2828
<Tooltip.Trigger asChild>
2929
<Button
3030
type='button'
31-
variant={isActive ? 'active' : 'ghost'}
31+
variant={isActive ? 'active' : 'quiet'}
3232
size='icon'
33+
iconSize={{ base: 'touch', sm: 'regular' }}
3334
aria-label={label}
3435
aria-pressed={isActive}
3536
disabled={disabled}
3637
onPointerDown={(event) => event.preventDefault()}
3738
onClick={onClick}
38-
className={cn(
39-
'size-10 focus-visible:bg-[var(--surface-hover)] sm:size-[28px]',
40-
!isActive && 'hover-hover:bg-[var(--surface-hover)]'
41-
)}
39+
className='focus-visible:bg-[var(--surface-hover)]'
4240
>
4341
<Icon className={iconSize === 'compact' ? 'size-[12px]' : 'size-[14px]'} />
4442
</Button>

‎apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/mic-button/mic-button.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('MicButton', () => {
7272
const waveform = container.querySelector('svg[viewBox="0 0 18 18"]')
7373
const bars = waveform?.querySelectorAll('line')
7474

75-
expect(button?.className).toContain('size-[28px]')
75+
expect(button?.classList.contains('size-7')).toBe(true)
7676
expect(button?.className).toContain('overflow-hidden')
7777
expect(button?.className).toContain('rounded-full')
7878
expect(waveform?.classList.contains('size-[18px]')).toBe(true)

‎apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/mic-button/mic-button.tsx‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,13 @@ export const MicButton = memo(function MicButton({
8989
<Tooltip.Trigger asChild>
9090
<Button
9191
type='button'
92-
variant={isListening ? 'active' : 'ghost'}
92+
variant={isListening ? 'active' : 'quiet'}
93+
iconSize='regular'
94+
shape='round'
9395
onClick={onToggle}
9496
aria-label={isListening ? 'Stop listening' : 'Voice input'}
9597
aria-pressed={isListening}
96-
className={cn(
97-
'relative size-[28px] overflow-hidden rounded-full p-0 transition-[background-color,color,scale] duration-150 ease-out active:scale-[0.96] motion-reduce:transition-none motion-reduce:active:scale-100',
98-
!isListening &&
99-
'text-[var(--text-icon)] hover-hover:bg-[var(--surface-hover)] hover-hover:text-[var(--text-icon)]'
100-
)}
98+
className='relative overflow-hidden transition-[background-color,color,scale] duration-150 ease-out active:scale-[0.96] motion-reduce:transition-none motion-reduce:active:scale-100'
10199
>
102100
<span
103101
className={cn(

0 commit comments

Comments
 (0)