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.

chore(new-channels): remove render icon helper (#1933)

teof61c4bdf8b0f
diff --git a/js/app/packages/channel/Channel/InlineMessageEditor.tsx b/js/app/packages/channel/Channel/InlineMessageEditor.tsx
index 926f99e8a5..f9d2d3d020 100644
--- a/js/app/packages/channel/Channel/InlineMessageEditor.tsx
+++ b/js/app/packages/channel/Channel/InlineMessageEditor.tsx
@@ -6,7 +6,6 @@ import {
useInput,
useInputCommands,
} from '../Input';
-import { renderIcon } from '../Input/utils/render-icon';
import { InputActionButton } from '@channel/Input/PrimaryActions';
import type { MessageEditor } from './create-message-editor';
import { useMessage } from '../Message';
@@ -22,10 +21,10 @@ function EditPrimaryActions() {
active={input().showFormatRibbon}
onClick={() => commands.toggleFormatRibbon()}
>
- {renderIcon(FormatIcon, 'size-5')}
+ <FormatIcon class="size-5" />
</InputActionButton>
<InputActionButton label="Discard Edit" onClick={() => commands.close()}>
- {renderIcon(TrashIcon, 'size-5')}
+ <TrashIcon class="size-5" />
</InputActionButton>
</>
);
diff --git a/js/app/packages/channel/Input/Attachments.tsx b/js/app/packages/channel/Input/Attachments.tsx
index fe8bf69b57..ea5bdff2b0 100644
--- a/js/app/packages/channel/Input/Attachments.tsx
+++ b/js/app/packages/channel/Input/Attachments.tsx
@@ -15,7 +15,6 @@ import { useInput, useInputCommands } from './context';
import type { InputAttachmentData, InputAttachmentKind } from './types';
import XIcon from '@icon/regular/x.svg';
import SpinnerIcon from '@icon/bold/spinner-gap-bold.svg';
-import { renderIcon } from './utils/render-icon';
type AttachmentsProps = JSX.HTMLAttributes<HTMLDivElement> & {
kind?: InputAttachmentKind | 'media';
@@ -39,7 +38,7 @@ function RemoveButton(props: {
}}
aria-label={`Remove ${props.attachment.name}`}
>
- {renderIcon(XIcon, 'text-ink-muted group-hover:text-failure size-3')}
+ <XIcon class="text-ink-muted group-hover:text-failure size-3" />
</button>
);
}
@@ -64,7 +63,7 @@ function MediaAttachmentItem(props: {
}
fallback={
<div class="flex flex-col items-center justify-center gap-2 w-[60px] h-[60px] border border-edge-muted rounded-md bg-menu">
- {renderIcon(SpinnerIcon, 'w-4 h-4 animate-spin')}
+ <SpinnerIcon class="w-4 h-4 animate-spin" />
</div>
}
>
@@ -86,7 +85,7 @@ function DocumentAttachmentItem(props: {
<div class="group flex items-center px-2 py-1.5 space-x-1.5 hover:bg-hover hover-transition-bg cursor-default text-sm border border-edge-muted rounded-xs">
<Show
when={!props.attachment.pending}
- fallback={renderIcon(SpinnerIcon, 'w-4 h-4 animate-spin')}
+ fallback={<SpinnerIcon class="w-4 h-4 animate-spin" />}
>
<EntityIcon
targetType={props.attachment.iconType ?? 'unknown'}
diff --git a/js/app/packages/channel/Input/FormatButtons.tsx b/js/app/packages/channel/Input/FormatButtons.tsx
index 6168865ff5..440acc0ef0 100644
--- a/js/app/packages/channel/Input/FormatButtons.tsx
+++ b/js/app/packages/channel/Input/FormatButtons.tsx
@@ -11,7 +11,6 @@ import type {
SelectionData,
} from '@core/component/LexicalMarkdown/plugins';
import type { TextFormatType } from 'lexical';
-import { renderIcon } from './utils/render-icon';
import { RibbonButton } from './RibbonButton';
type FormatButtonsProps = {
@@ -28,28 +27,28 @@ export function FormatButtons(props: FormatButtonsProps) {
active={props.selectionState()?.bold}
onClick={() => props.onInlineFormat('bold')}
>
- {renderIcon(TextBoldIcon, 'size-5')}
+ <TextBoldIcon class="size-5" />
</RibbonButton>
<RibbonButton
label="Italic"
active={props.selectionState()?.italic}
onClick={() => props.onInlineFormat('italic')}
>
- {renderIcon(TextItalicIcon, 'size-5')}
+ <TextItalicIcon class="size-5" />
</RibbonButton>
<RibbonButton
label="Strikethrough"
active={props.selectionState()?.strikethrough}
onClick={() => props.onInlineFormat('strikethrough')}
>
- {renderIcon(TextStrikethroughIcon, 'size-5')}
+ <TextStrikethroughIcon class="size-5" />
</RibbonButton>
<RibbonButton
label="Code"
active={props.selectionState()?.code}
onClick={() => props.onInlineFormat('code')}
>
- {renderIcon(TextCodeIcon, 'size-5')}
+ <TextCodeIcon class="size-5" />
</RibbonButton>
<div class="w-px h-5 bg-edge-muted" />
<RibbonButton
@@ -57,21 +56,21 @@ export function FormatButtons(props: FormatButtonsProps) {
active={props.selectionState()?.elementsInRange.has('list-bullet')}
onClick={() => props.onNodeFormat('list-bullet')}
>
- {renderIcon(ListBulletsIcon, 'size-5')}
+ <ListBulletsIcon class="size-5" />
</RibbonButton>
<RibbonButton
label="Numbered list"
active={props.selectionState()?.elementsInRange.has('list-number')}
onClick={() => props.onNodeFormat('list-number')}
>
- {renderIcon(ListNumbersIcon, 'size-5')}
+ <ListNumbersIcon class="size-5" />
</RibbonButton>
<RibbonButton
label="Checklist"
active={props.selectionState()?.elementsInRange.has('list-check')}
onClick={() => props.onNodeFormat('list-check')}
>
- {renderIcon(ListChecksIcon, 'size-5')}
+ <ListChecksIcon class="size-5" />
</RibbonButton>
</>
);
diff --git a/js/app/packages/channel/Input/PrimaryActions.tsx b/js/app/packages/channel/Input/PrimaryActions.tsx
index 6a19d05dd7..fcb8ea435c 100644
--- a/js/app/packages/channel/Input/PrimaryActions.tsx
+++ b/js/app/packages/channel/Input/PrimaryActions.tsx
@@ -5,7 +5,6 @@ import { isReplyInput } from './types';
import FormatIcon from '@icon/regular/text-aa.svg';
import TrashIcon from '@icon/regular/trash.svg';
import PaperclipIcon from '@phosphor-icons/core/regular/paperclip.svg?component-solid';
-import { renderIcon } from './utils/render-icon';
import { Button } from '@ui/components/Button';
import { LabelAndHotKey } from '@core/component/Tooltip';
import { CHANNEL_FILE_PICKER_ACCEPT } from './accepted-file-types';
@@ -74,21 +73,21 @@ export function PrimaryActions(props: JSX.HTMLAttributes<HTMLDivElement>) {
label="Attach files"
onClick={() => openAttachPicker()}
>
- {renderIcon(PaperclipIcon, 'size-5')}
+ <PaperclipIcon class="size-5" />
</InputActionButton>
<InputActionButton
label="Format"
active={input().showFormatRibbon}
onClick={() => commands.toggleFormatRibbon()}
>
- {renderIcon(FormatIcon, 'size-5')}
+ <FormatIcon class="size-5" />
</InputActionButton>
<Show when={isReplyInput(input())}>
<InputActionButton
label="Delete reply"
onClick={() => commands.close()}
>
- {renderIcon(TrashIcon, 'size-5')}
+ <TrashIcon class="size-5" />
</InputActionButton>
</Show>
</>
diff --git a/js/app/packages/channel/Input/SendAction.tsx b/js/app/packages/channel/Input/SendAction.tsx
index c11b6ef300..1366396ea5 100644
--- a/js/app/packages/channel/Input/SendAction.tsx
+++ b/js/app/packages/channel/Input/SendAction.tsx
@@ -3,7 +3,6 @@ import { cn } from '@ui/utils/classname';
import { useInput, useInputCommands } from './context';
import ArrowUpIcon from '@icon/bold/arrow-up-bold.svg';
import SpinnerIcon from '@icon/bold/spinner-gap-bold.svg';
-import { renderIcon } from './utils/render-icon';
import { Button } from '@ui/components/Button';
import { LabelAndHotKey } from '@core/component/Tooltip';
@@ -33,17 +32,11 @@ export function SendAction(props: JSX.ButtonHTMLAttributes<HTMLButtonElement>) {
>
<Show
when={!isBlockedByPending()}
- fallback={renderIcon(
- SpinnerIcon,
- 'size-6 animate-spin cursor-disabled'
- )}
+ fallback={<SpinnerIcon class="size-6 animate-spin cursor-disabled" />}
>
{resolved() ?? (
<div class="group-hover:scale-115 group-hover:bg-accent transition ease-in-out size-6 touch:size-8 border border-accent rounded-full flex items-center justify-center">
- {renderIcon(
- ArrowUpIcon,
- 'group-hover:!text-input group-hover:!fill-input !text-accent-ink !fill-accent size-4 transition ease-in-out'
- )}
+ <ArrowUpIcon class="group-hover:!text-input group-hover:!fill-input !text-accent-ink !fill-accent size-4 transition ease-in-out" />
</div>
)}
</Show>
diff --git a/js/app/packages/channel/Input/tests/input-slots.test.tsx b/js/app/packages/channel/Input/tests/input-slots.test.tsx
index c226aae33a..7322160be1 100644
--- a/js/app/packages/channel/Input/tests/input-slots.test.tsx
+++ b/js/app/packages/channel/Input/tests/input-slots.test.tsx
@@ -31,8 +31,24 @@ vi.mock('@core/constant/allBlocks', () => ({
fileTypeToBlockName: (type?: string | null) => type ?? 'unknown',
}));
-vi.mock('../utils/render-icon', () => ({
- renderIcon: () => null,
+vi.mock('@phosphor-icons/core/regular/paperclip.svg?component-solid', () => ({
+ default: () => <span data-testid="paperclip-icon" />,
+}));
+
+vi.mock('@icon/regular/text-aa.svg', () => ({
+ default: () => <span data-testid="format-icon" />,
+}));
+
+vi.mock('@icon/regular/trash.svg', () => ({
+ default: () => <span data-testid="trash-icon" />,
+}));
+
+vi.mock('@icon/bold/arrow-up-bold.svg', () => ({
+ default: () => <span data-testid="send-icon" />,
+}));
+
+vi.mock('@icon/bold/spinner-gap-bold.svg', () => ({
+ default: () => <span data-testid="spinner-icon" />,
}));
vi.mock('@core/component/EntityIcon', () => ({
@@ -110,6 +126,10 @@ vi.mock(
})
);
+vi.mock('../FormatButtons', () => ({
+ FormatButtons: () => <div data-testid="format-buttons" />,
+}));
+
import { ChannelInput } from '../ChannelInput';
import { Root } from '../Root';
import { DropOverlay } from '../DropOverlay';
diff --git a/js/app/packages/channel/Input/utils/index.ts b/js/app/packages/channel/Input/utils/index.ts
index 23e58d3fe9..ec8418e4c7 100644
--- a/js/app/packages/channel/Input/utils/index.ts
+++ b/js/app/packages/channel/Input/utils/index.ts
@@ -10,4 +10,3 @@ export {
type UploadDocumentSuccessResult,
} from './file-helpers';
export { applyInlineFormat, applyNodeFormat } from './formatting';
-export { renderIcon } from './render-icon';
diff --git a/js/app/packages/channel/Input/utils/render-icon.tsx b/js/app/packages/channel/Input/utils/render-icon.tsx
deleted file mode 100644
index 52c086b151..0000000000
--- a/js/app/packages/channel/Input/utils/render-icon.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { cn } from '@ui/utils/classname';
-import type { Component, JSX } from 'solid-js';
-
-export function renderIcon(
- icon: Component<JSX.SvgSVGAttributes<SVGSVGElement>> | string,
- className?: string
-): JSX.Element {
- if (typeof icon === 'string') {
- return <img src={icon} alt="" class={cn('size-4', className)} />;
- }
-
- const Icon = icon;
- return <Icon class={cn('size-4', className)} />;
-}