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
feat: notifications stack toggle list on bottom (#2434)
gbirman9d591a2770d0
diff --git a/js/app/packages/entity/src/components/CollapsibleList.tsx b/js/app/packages/entity/src/components/CollapsibleList.tsxindex a13af6a4f7..ffd2210ec6 100644--- a/js/app/packages/entity/src/components/CollapsibleList.tsx+++ b/js/app/packages/entity/src/components/CollapsibleList.tsx@@ -1,12 +1,57 @@import ChevronDownIcon from '@icon/regular/caret-down.svg?component-solid';import { cn } from '@ui/utils/classname';-import { createSignal, For, type JSX, onCleanup, Show } from 'solid-js';+import { createSignal, For, type JSX, Show } from 'solid-js';++interface ToggleButtonProps {+ hasMore: boolean;+ toggleRef: (el: HTMLDivElement) => void;+ showAll: boolean;+ collapse: (e: MouseEvent) => void;+ setShowAll: (value: boolean) => void;+ getExpandTextFn: (count: number) => string;+ visibleCount: number;+ itemsLength: number;+}++function ToggleButton(props: ToggleButtonProps) {+ return (+ <Show when={props.hasMore}>+ <div ref={props.toggleRef} class="w-full flex items-center gap-2 my-2">+ <button+ type="button"+ class="flex items-center gap-1 text-xs bracket-never hover:text-accent"+ data-collapsible-toggle+ data-collapsible-state={props.showAll ? 'expanded' : 'collapsed'}+ onClick={(e) => {+ if (props.showAll) {+ props.collapse(e);+ } else {+ e.stopPropagation();+ props.setShowAll(true);+ }+ }}+ >+ <ChevronDownIcon+ class={cn('w-3 h-3 transition-transform duration-100', {+ 'rotate-180': props.showAll,+ })}+ />+ <Show when={!props.showAll} fallback="Collapse">+ {props.getExpandTextFn(props.itemsLength - props.visibleCount)}+ </Show>+ </button>+ <div class="border-t border-edge-muted/50 grow" />+ </div>+ </Show>+ );+}interface CollapsibleListProps<T> {items: T[];visibleCount?: number;children: (item: T, index?: number, count?: number) => JSX.Element;expandText?: (count: number) => string;+ togglePosition?: 'top' | 'bottom';}/**@@ -22,9 +67,7 @@ interface CollapsibleListProps<T> {*/export function CollapsibleList<T>(props: CollapsibleListProps<T>) {const [showAll, setShowAll] = createSignal(false);- const [isCollapseInView, setIsCollapseInView] = createSignal(true);- let collapseButtonRef: HTMLDivElement | undefined;- let observer: IntersectionObserver | undefined;+ let toggleRef: HTMLDivElement | undefined;const visibleCount = () => props.visibleCount ?? 3;@@ -37,6 +80,7 @@ export function CollapsibleList<T>(props: CollapsibleListProps<T>) {const count = () => props.items.length;const hasMore = () => props.items.length > visibleCount();+ const position = () => props.togglePosition ?? 'top';const getExpandTextFn = () =>props.expandText ?? ((count: number) => `Show ${count} More`);@@ -54,7 +98,7 @@ export function CollapsibleList<T>(props: CollapsibleListProps<T>) {const collapse = (e: MouseEvent) => {e.stopPropagation();- const entity = collapseButtonRef?.closest('[data-entity]');+ const entity = toggleRef?.closest('[data-entity]');const scrollContainer = entity ? getScrollParent(entity) : null;const heightBefore = entity?.getBoundingClientRect().height ?? 0;@@ -66,62 +110,29 @@ export function CollapsibleList<T>(props: CollapsibleListProps<T>) {}};- const observeCollapseButton = (el: HTMLDivElement) => {- collapseButtonRef = el;- observer?.disconnect();- observer = new IntersectionObserver(- ([entry]) => setIsCollapseInView(entry.isIntersecting),- { threshold: 0 }- );- observer.observe(el);- };-- onCleanup(() => observer?.disconnect());+ const toggleButtonProps = () => ({+ hasMore: hasMore(),+ toggleRef: (el: HTMLDivElement) => {+ toggleRef = el;+ },+ showAll: showAll(),+ collapse,+ setShowAll,+ getExpandTextFn: getExpandTextFn(),+ visibleCount: visibleCount(),+ itemsLength: props.items.length,+ });return (<>- <Show when={hasMore()}>- <div- ref={observeCollapseButton}- class="w-full flex items-center gap-2 my-2"- >- <button- type="button"- class="flex items-center gap-1 text-xs bracket-never hover:text-accent"- data-collapsible-toggle- data-collapsible-state={showAll() ? 'expanded' : 'collapsed'}- onClick={(e) => {- e.stopPropagation();- setShowAll((prev) => !prev);- }}- >- <ChevronDownIcon- class={cn('w-3 h-3 transition-transform duration-100', {- 'rotate-180': showAll(),- })}- />- <Show when={!showAll()} fallback="Collapse">- {getExpandTextFn()(props.items.length - visibleCount())}- </Show>- </button>- <div class="border-t border-edge-muted/50 grow" />- </div>+ <Show when={position() === 'top'}>+ <ToggleButton {...toggleButtonProps()} /></Show><For each={visibleItems()}>{(child, index) => props.children(child, index(), count())}</For>- <Show when={showAll() && hasMore() && !isCollapseInView()}>- <div class="w-full flex items-center gap-2 my-2">- <button- type="button"- class="flex items-center gap-1 text-xs bracket-never hover:text-accent"- onClick={collapse}- >- <ChevronDownIcon class="w-3 h-3 rotate-180 transition-transform duration-100" />- Collapse- </button>- <div class="border-t border-edge-muted/50 grow" />- </div>+ <Show when={position() === 'bottom'}>+ <ToggleButton {...toggleButtonProps()} /></Show></>);diff --git a/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx b/js/app/packages/entity/src/extractors-notification/notification-stacks.tsxindex 932f76e073..1d6c90d490 100644--- a/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx+++ b/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx@@ -137,6 +137,7 @@ export function NotificationStacks(props: NotificationStacksProps) {<CollapsibleListitems={stacks}visibleCount={props.visibleCount ?? DEFAULT_VISIBLE_COUNT}+ togglePosition="bottom">{(stack) => (<NotificationStackRow stack={stack} onClick={props.onClick} />