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
chore(new-channels): restyle attachments tab (#2312)
teoc6952a314feb
diff --git a/js/app/packages/channel/Attachments/AttachmentEntityList.tsx b/js/app/packages/channel/Attachments/AttachmentEntityList.tsxindex c22ed75b62..58fa58b6e8 100644--- a/js/app/packages/channel/Attachments/AttachmentEntityList.tsx+++ b/js/app/packages/channel/Attachments/AttachmentEntityList.tsx@@ -1,7 +1,7 @@import { For, Show } from 'solid-js';import type { EntityData } from '@entity';import type { DateValue } from '@core/util/date';-import { SectionHeader, LoadMoreButton } from './SectionHeader';+import { AttachmentSection, LoadMoreButton } from './SectionHeader';import { AttachmentEntityRow } from './AttachmentEntityRow';export type AttachmentEntityListRow = {@@ -20,34 +20,40 @@ export function AttachmentEntityList(props: {const hasDocuments = () => props.rows.length > 0;return (- <div class="flex flex-col">- <SectionHeader label="Documents" />+ <AttachmentSection+ label="Documents"+ class="flex flex-1 min-h-0 flex-col md:flex-none"+ contentClass="flex flex-1 min-h-0 flex-col"+ >+ <div class="flex flex-1 min-h-0 flex-col">+ <Show when={!hasDocuments()}>+ <div class="py-3 text-sm text-ink-faint">+ No documents in this channel yet.+ </div>+ </Show>- <Show when={!hasDocuments()}>- <div class="text-sm text-ink-faint px-2 py-3">- No documents in this channel yet.- </div>- </Show>+ <Show when={hasDocuments()}>+ <div class="min-h-0 h-full overflow-y-auto md:h-[420px]">+ <For each={props.rows}>+ {(row) => (+ <AttachmentEntityRow+ entity={row.entity}+ timestamp={row.timestamp}+ senderId={row.senderId}+ onClick={row.onClick}+ />+ )}+ </For>- <Show when={hasDocuments()}>- <For each={props.rows}>- {(row) => (- <AttachmentEntityRow- entity={row.entity}- timestamp={row.timestamp}- senderId={row.senderId}- onClick={row.onClick}- />- )}- </For>- </Show>-- <Show when={hasDocuments() && props.hasNextPage}>- <LoadMoreButton- onLoadMore={props.onLoadMore}- isFetching={() => props.isFetchingNextPage}- />- </Show>- </div>+ <Show when={props.hasNextPage}>+ <LoadMoreButton+ onLoadMore={props.onLoadMore}+ isFetching={() => props.isFetchingNextPage}+ />+ </Show>+ </div>+ </Show>+ </div>+ </AttachmentSection>);}diff --git a/js/app/packages/channel/Attachments/ChannelAttachmentsTab.tsx b/js/app/packages/channel/Attachments/ChannelAttachmentsTab.tsxindex 5b50640d39..810d402ce9 100644--- a/js/app/packages/channel/Attachments/ChannelAttachmentsTab.tsx+++ b/js/app/packages/channel/Attachments/ChannelAttachmentsTab.tsx@@ -9,7 +9,7 @@ import { ChannelAttachmentEntitySection } from './ChannelAttachmentEntitySectionexport function ChannelAttachmentsTab(props: { channelId: string }) {return (<div class="relative flex-1 min-h-0 overflow-y-auto">- <div class="macro-message-width macro-message-padding mx-auto w-full py-4 flex flex-col gap-6">+ <div class="macro-message-width macro-message-padding mx-auto flex h-full min-h-0 w-full flex-col gap-6 py-4"><Suspense fallback={<MediaGallerySkeleton />}><ChannelAttachmentMediaSection channelId={props.channelId} /></Suspense>diff --git a/js/app/packages/channel/Attachments/MediaGallery.tsx b/js/app/packages/channel/Attachments/MediaGallery.tsxindex 38695a0674..ea2d7491d1 100644--- a/js/app/packages/channel/Attachments/MediaGallery.tsx+++ b/js/app/packages/channel/Attachments/MediaGallery.tsx@@ -1,10 +1,10 @@-import { createSignal, onCleanup, Show } from 'solid-js';+import { createSignal, createUniqueId, onCleanup, Show } from 'solid-js';import ChevronDownIcon from '@icon/regular/caret-down.svg';import { MediaGrid } from '@channel/Media/MediaGrid';import { MediaViewerDialog } from '@channel/Media/MediaViewerDialog';import type { MediaItem } from '@channel/Media/media-items';import { THUMB_SIZE, itemsPerRow } from './attachment-utils';-import { SectionHeader, LoadMoreButton } from './SectionHeader';+import { AttachmentSection, LoadMoreButton } from './SectionHeader';export function MediaGallery(props: {items: MediaItem[];@@ -12,6 +12,7 @@ export function MediaGallery(props: {isFetchingNextPage: boolean;onLoadMore: () => void;}) {+ const galleryId = createUniqueId();const [expanded, setExpanded] = createSignal(false);const [containerWidth, setContainerWidth] = createSignal(0);const [lightboxIndex, setLightboxIndex] = createSignal(0);@@ -32,68 +33,72 @@ export function MediaGallery(props: {const collapsedMaxHeight = () => THUMB_SIZE;return (- <div class="flex flex-col">- <SectionHeader- label="Photos and videos"- action={- <Show when={hiddenCount() > 0}>- <button- type="button"- class="flex items-center gap-1 text-xs font-medium text-ink-muted/70 hover:text-ink-muted transition-colors"- onClick={() => setExpanded((prev) => !prev)}- >- {expanded() ? 'Show less' : 'See all'}- <ChevronDownIcon- class="w-3 h-3 transition-transform"- classList={{ 'rotate-180': expanded() }}- />- </button>- </Show>- }- />-- <Show when={!hasMedia()}>- <div class="text-sm text-ink-faint px-2 py-3">- No photos or videos in this channel yet.- </div>- </Show>-- <Show when={hasMedia()}>- <div>- <div- class="flex flex-row flex-wrap gap-1.5 pt-3 overflow-hidden transition-[max-height] duration-200"- style={{- 'max-height': expanded()- ? 'none'- : `${collapsedMaxHeight() + 12}px`,- }}- ref={observeGrid}+ <AttachmentSection+ label="Photos and videos"+ action={+ <Show when={hiddenCount() > 0}>+ <button+ type="button"+ class="flex items-center gap-1 text-xs font-medium text-ink-muted/70 hover:text-ink-muted transition-colors"+ aria-controls={galleryId}+ aria-expanded={expanded()}+ onClick={() => setExpanded((prev) => !prev)}>- <MediaGrid- items={props.items}- variant="attachments"- onOpen={(index) => {- setLightboxIndex(index);- setViewerOpen(true);+ {expanded() ? 'Show less' : 'See all'}+ <ChevronDownIcon+ aria-hidden="true"+ class="w-3 h-3 transition-transform"+ classList={{ 'rotate-180': expanded() }}+ />+ </button>+ </Show>+ }+ >+ <div class="flex flex-col">+ <Show when={!hasMedia()}>+ <div class="py-3 text-sm text-ink-faint">+ No photos or videos in this channel yet.+ </div>+ </Show>++ <Show when={hasMedia()}>+ <div>+ <div+ id={galleryId}+ aria-label="Photos and videos gallery"+ data-expanded={expanded() ? 'true' : 'false'}+ class="flex flex-row flex-wrap gap-1.5 overflow-hidden transition-[max-height] duration-200"+ style={{+ 'max-height': expanded() ? 'none' : `${collapsedMaxHeight()}px`,}}+ ref={observeGrid}+ >+ <MediaGrid+ items={props.items}+ variant="attachments"+ onOpen={(index) => {+ setLightboxIndex(index);+ setViewerOpen(true);+ }}+ />+ </div>+ <MediaViewerDialog+ items={() => props.items}+ open={viewerOpen()}+ onOpenChange={setViewerOpen}+ currentIndex={lightboxIndex}+ onCurrentIndexChange={setLightboxIndex}/></div>- <MediaViewerDialog- items={() => props.items}- open={viewerOpen()}- onOpenChange={setViewerOpen}- currentIndex={lightboxIndex}- onCurrentIndexChange={setLightboxIndex}- />- </div>- </Show>+ </Show>- <Show when={expanded() && props.hasNextPage}>- <LoadMoreButton- onLoadMore={props.onLoadMore}- isFetching={() => props.isFetchingNextPage}- />- </Show>- </div>+ <Show when={expanded() && props.hasNextPage}>+ <LoadMoreButton+ onLoadMore={props.onLoadMore}+ isFetching={() => props.isFetchingNextPage}+ />+ </Show>+ </div>+ </AttachmentSection>);}diff --git a/js/app/packages/channel/Attachments/SectionHeader.tsx b/js/app/packages/channel/Attachments/SectionHeader.tsxindex 9a75cedf76..6bfa5fefc5 100644--- a/js/app/packages/channel/Attachments/SectionHeader.tsx+++ b/js/app/packages/channel/Attachments/SectionHeader.tsx@@ -2,15 +2,26 @@ import { type Accessor, Show, type JSX } from 'solid-js';import { Button } from '@ui/components/Button';import Spinner from '@phosphor-icons/core/bold/spinner-gap-bold.svg?component-solid';-export function SectionHeader(props: { label: string; action?: JSX.Element }) {+export function AttachmentSection(props: {+ label: string;+ action?: JSX.Element;+ children: JSX.Element;+ class?: string;+ contentClass?: string;+}) {return (- <>- <div class="flex items-center justify-between px-2 py-1.5">- <h3 class="text-xs font-medium text-ink-muted/70">{props.label}</h3>- {props.action}+ <div+ class={`rounded-sm border border-edge-muted bg-menu py-3 ${props.class ?? ''}`}+ >+ <div class="flex items-center justify-between px-3 pb-3">+ <h3 class="text-sm font-medium text-ink">{props.label}</h3>+ <div class="shrink-0">{props.action}</div>+ </div>+ <div class="border-b border-edge-muted" />+ <div class={`px-3 pt-3 ${props.contentClass ?? ''}`}>+ {props.children}</div>- <div class="border-b border-edge-muted/50" />- </>+ </div>);}diff --git a/js/app/packages/channel/Attachments/Skeletons.tsx b/js/app/packages/channel/Attachments/Skeletons.tsxindex ff7ca522da..2d59f7e4ef 100644--- a/js/app/packages/channel/Attachments/Skeletons.tsx+++ b/js/app/packages/channel/Attachments/Skeletons.tsx@@ -1,5 +1,5 @@import { For } from 'solid-js';-import { SectionHeader } from './SectionHeader';+import { AttachmentSection } from './SectionHeader';export function ThumbnailSkeleton() {return (@@ -24,24 +24,22 @@ const DOCUMENT_SKELETON_COUNT = 6;export function MediaGallerySkeleton() {return (- <div class="flex flex-col">- <SectionHeader label="Photos and videos" />- <div class="flex flex-row flex-wrap gap-1.5 pt-3">+ <AttachmentSection label="Photos and videos">+ <div class="flex flex-row flex-wrap gap-1.5"><For each={Array.from({ length: MEDIA_SKELETON_COUNT })}>{() => <ThumbnailSkeleton />}</For></div>- </div>+ </AttachmentSection>);}export function AttachmentEntityListSkeleton() {return (- <div class="flex flex-col">- <SectionHeader label="Documents" />+ <AttachmentSection label="Documents"><For each={Array.from({ length: DOCUMENT_SKELETON_COUNT })}>{() => <DocumentRowSkeleton />}</For>- </div>+ </AttachmentSection>);}