Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
style(chat/channel): unifiy/cleanup attachment styling (#1454)
Seamusbbb896f63847
diff --git a/js/app/packages/block-channel/component/Attachment.tsx b/js/app/packages/block-channel/component/Attachment.tsxindex 9a7466870b..4b9782cbd8 100644--- a/js/app/packages/block-channel/component/Attachment.tsx+++ b/js/app/packages/block-channel/component/Attachment.tsx@@ -1,24 +1,13 @@-import { useSplitLayout } from '@app/component/split-layout/layout';-import { DeprecatedTextButton } from '@core/component/DeprecatedTextButton';-import { EntityIcon } from '@core/component/EntityIcon';-import { ImagePreview } from '@core/component/ImagePreview';-import { VideoPreview } from '@core/component/VideoPreview';-import {- blockNameToDefaultFile,- fileTypeToBlockName,-} from '@core/constant/allBlocks';+import { ItemPreview } from '@core/component/ItemPreview';import {type InputAttachment,isStaticAttachmentType,- STATIC_IMAGE,- STATIC_VIDEO,} from '@core/store/cacheChannelInput';import { matches } from '@core/util/match';-import { openInNewSplitForMention } from '@core/util/openInNewSplit';-import { truncateString } from '@core/util/string';-import XIcon from '@icon/regular/x.svg';+import Close from '@phosphor-icons/core/regular/x.svg?component-solid';import Spinner from '@phosphor-icons/core/bold/spinner-gap-bold.svg?component-solid';-import { createSignal, Match, Show, Switch } from 'solid-js';+import { blockNameToItemType } from '@service-storage/client';+import { Match, Show, Switch } from 'solid-js';type AttachmentProps = {attachment: InputAttachment;@@ -27,94 +16,47 @@ type AttachmentProps = {};export function Attachment(props: AttachmentProps) {- const { openWithSplit } = useSplitLayout();- const [hover, setHover] = createSignal(false);-- const attachmentName = () => {- const baseName =- props.attachment.name ??- blockNameToDefaultFile(props.attachment.blockName as any);-- return baseName;- };-return (- <div- class="relative flex flex-row items-center"- onMouseEnter={() => setHover(true)}- onMouseLeave={() => setHover(false)}- >- <Show when={hover() && props.remove}>- <XIcon- class="w-6 h-6 text-ink absolute -top-2 -right-2 rounded-full bg-menu p-1 border border-edge-muted z-[10]"- onClick={() => props.remove?.(props.attachment)}- />- </Show>- <Switch>- <Match- when={- props.attachment.pending &&- props.attachment.blockName === STATIC_VIDEO- }- >- <div class="flex flex-col items-center justify-center gap-2 w-[60px] h-[60px] border border-edge-muted rounded-md bg-menu">- <Spinner class="w-4 h-4 animate-spin" />- </div>- </Match>- <Match- when={- props.attachment.pending &&- props.attachment.blockName === STATIC_IMAGE- }- >- <div class="flex flex-col items-center justify-center gap-2 w-[60px] h-[60px] border border-edge-muted rounded-md bg-menu">- <Spinner class="w-4 h-4 animate-spin" />+ <Switch>+ <Match+ when={matches(+ props.attachment.blockName,+ (bn) => !isStaticAttachmentType(bn)+ )}+ >+ {(blockName) => (+ <div class="flex items-center px-1 space-x-1 hover:bg-hover hover-transition-bg cursor-default text-sm border border-edge-muted rounded-xs">+ <Show when={props.attachment.pending}>+ <Spinner class="w-4 h-4 animate-spin" />+ </Show>+ <Show when={!props.attachment.pending}>+ <ItemPreview+ id={props.attachment.id}+ type={blockNameToItemType(blockName())}+ class="flex items-center gap-1 text-sm ring-0"+ textClass="truncate"+ iconSize="xs"+ disableHoverCard+ />+ </Show>+ <Show when={props.remove}>+ <div+ class="hover:bg-hover hover-transition-bg rounded-md p-1 items-center flex"+ onClick={(e) => {+ e.stopPropagation();+ props.remove?.(props.attachment);+ }}+ >+ <Close+ width={12}+ height={12}+ class="text-ink-muted group-hover:text-failure"+ />+ </div>+ </Show></div>- </Match>- <Match when={props.attachment.blockName === STATIC_IMAGE}>- <ImagePreview- image={{- id: props.attachment.id,- }}- variant="small"- />- </Match>- <Match when={props.attachment.blockName === STATIC_VIDEO}>- <VideoPreview id={props.attachment.id} variant="small" />- </Match>- <Match- when={matches(- props.attachment.blockName,- (bn) => !isStaticAttachmentType(bn)- )}- >- {(blockName) => (- <DeprecatedTextButton- theme="base"- disabled={props.attachment.pending}- icon={() =>- props.attachment.pending ? (- <Spinner class="w-4 h-4 animate-spin" />- ) : (- <EntityIcon targetType={blockName()} size="xs" />- )- }- text={truncateString(attachmentName(), 30)}- onClick={(e) => {- if (props.attachment.pending) return;- const inNewSplit = openInNewSplitForMention(e.shiftKey, true);- openWithSplit(- {- type: fileTypeToBlockName(blockName()),- id: props.attachment.id,- },- { preferNewSplit: inNewSplit }- );- }}- />- )}- </Match>- </Switch>- </div>+ )}+ </Match>+ </Switch>);}diff --git a/js/app/packages/core/component/AI/component/input/Attachment.tsx b/js/app/packages/core/component/AI/component/input/Attachment.tsxindex f2b065acda..ae9affba36 100644--- a/js/app/packages/core/component/AI/component/input/Attachment.tsx+++ b/js/app/packages/core/component/AI/component/input/Attachment.tsx@@ -110,12 +110,11 @@ function ChatAttachment(props: {}>{(metadata) => (- <div class="flex items-center p-1 space-x-2 hover:bg-hover hover-transition-bg cursor-default text-sm">+ <div class="flex items-center px-1 space-x-1 hover:bg-hover hover-transition-bg cursor-default text-sm border border-edge-muted rounded-xs"><ItemPreviewid={props.attachment.attachmentId}type={metadata().type}- class="flex items-center gap-1 text-sm"- iconClass=""+ class="flex items-center gap-1 text-sm ring-0"textClass="truncate"iconSize="xs"disableHoverCarddiff --git a/js/app/packages/core/component/ItemPreview.tsx b/js/app/packages/core/component/ItemPreview.tsxindex 858d579b2e..7fdd1450ed 100644--- a/js/app/packages/core/component/ItemPreview.tsx+++ b/js/app/packages/core/component/ItemPreview.tsx@@ -26,12 +26,12 @@ import {import { PopupPreview } from './DocumentPreview';import { HoverCard } from './HoverCard';import { useSplitLayout } from '../../app/component/split-layout/layout';-import { DeprecatedTextButton } from './DeprecatedTextButton';import {EntityIcon,type EntityIconProps,getPreviewItemIconType,} from './EntityIcon';+import { cn } from '@ui/utils/classname';export function useItemPreviewData(entity: Accessor<ItemEntity>) {const [item] = useItemPreview(entity);@@ -104,14 +104,31 @@ export function useItemPreviewData(entity: Accessor<ItemEntity>) {};}-function ButtonNoAccess() {+const DEFAULT_BUTTON_CLASS =+ 'text-ink-base text-sm ring-1 ring-edge-muted rounded-xs hover:bg-panel-hover flex flex-row h-6 px-2 justify-center items-center';+const DEFAULT_ICON_CLASS = 'flex justify-start items-center h-3.5 mr-2';+const DEFAULT_TEXT_CLASS = 'flex-1 text-left leading-5 min-w-0 truncate';++interface StatusDisplayProps {+ class?: string;+ iconClass?: string;+ textClass?: string;+}++function ButtonNoAccess(props: StatusDisplayProps) {return (- <DeprecatedTextButton- theme="base"- icon={() => <EyeSlash class="text-ink-muted w-4 h-4" />}- disabled- text="No Access"- />+ <div+ class={cn(+ DEFAULT_BUTTON_CLASS,+ 'opacity-50 cursor-not-allowed',+ props.class+ )}+ >+ <div class={cn(DEFAULT_ICON_CLASS, props.iconClass)}>+ <EyeSlash class="text-ink-muted w-3.5 h-3.5" />+ </div>+ <div class={cn(DEFAULT_TEXT_CLASS, props.textClass)}>No Access</div>+ </div>);}@@ -126,14 +143,20 @@ function InlineNoAccess() {);}-function ButtonDeleted() {+function ButtonDeleted(props: StatusDisplayProps) {return (- <DeprecatedTextButton- theme="base"- icon={() => <TrashSimple class="text-ink-muted w-4 h-4" />}- disabled- text="Deleted"- />+ <div+ class={cn(+ DEFAULT_BUTTON_CLASS,+ 'opacity-50 cursor-not-allowed',+ props.class+ )}+ >+ <div class={cn(DEFAULT_ICON_CLASS, props.iconClass)}>+ <TrashSimple class="text-ink-muted w-3.5 h-3.5" />+ </div>+ <div class={cn(DEFAULT_TEXT_CLASS, props.textClass)}>Deleted</div>+ </div>);}@@ -148,18 +171,22 @@ function InlineDeleted() {);}-function ButtonLoading() {+function ButtonLoading(props: StatusDisplayProps) {return (- <DeprecatedTextButton- theme="base"- icon={() => (- <div class="w-4 h-4 animate-spin">+ <div+ class={cn(+ DEFAULT_BUTTON_CLASS,+ 'opacity-50 cursor-not-allowed',+ props.class+ )}+ >+ <div class={cn(DEFAULT_ICON_CLASS, props.iconClass)}>+ <div class="w-3.5 h-3.5 animate-spin"><LoadingSpinner /></div>- )}- text="Loading..."- disabled- />+ </div>+ <div class={cn(DEFAULT_TEXT_CLASS, props.textClass)}>Loading...</div>+ </div>);}@@ -203,18 +230,18 @@ function ItemPreviewInner(props: ItemPreviewProps) {const maxLength = () => props.maxLength ?? 80;const iconSize = () => props.iconSize ?? 'fill';- const buttonClass = () =>- props.class ??- 'text-ink-base text-sm ring-1 ring-edge-muted rounded-xs hover:bg-panel-hover flex flex-row h-6 px-2 justify-center items-center';- const iconClass = () =>- props.iconClass ?? 'flex justify-start items-center h-3.5 mr-2';- const textClass = () =>- props.textClass ?? 'flex-1 text-left leading-5 min-w-0 truncate';+ const buttonClass = () => cn(DEFAULT_BUTTON_CLASS, props.class);+ const iconClass = () => cn(DEFAULT_ICON_CLASS, props.iconClass);+ const textClass = () => cn(DEFAULT_TEXT_CLASS, props.textClass);return (<Switch><Match when={item().loading}>- <ButtonLoading />+ <ButtonLoading+ class={props.class}+ iconClass={props.iconClass}+ textClass={props.textClass}+ /></Match><Match when={matches(item(), (i) => !i.loading)}>{(loadedItem) => (@@ -271,10 +298,18 @@ function ItemPreviewInner(props: ItemPreviewProps) {}}</Match><Match when={loadedItem().access === 'no_access'}>- <ButtonNoAccess />+ <ButtonNoAccess+ class={props.class}+ iconClass={props.iconClass}+ textClass={props.textClass}+ /></Match><Match when={loadedItem().access === 'does_not_exist'}>- <ButtonDeleted />+ <ButtonDeleted+ class={props.class}+ iconClass={props.iconClass}+ textClass={props.textClass}+ /></Match></Switch>)}