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
cool scrollbar animation and fix padding in unified list (#147)
Jacob Beckerman332397d0ffa1
diff --git a/js/app/packages/app/component/Soup.tsx b/js/app/packages/app/component/Soup.tsxindex 8d72e38743..698f879062 100644--- a/js/app/packages/app/component/Soup.tsx+++ b/js/app/packages/app/component/Soup.tsx@@ -399,7 +399,7 @@ export function Soup() {><Tabsref={tabsRef}- class="@container/soup flex flex-col gap-1 size-full p-2 overflow-x-clip"+ class="@container/soup flex flex-col gap-1 size-full overflow-x-clip"classList={{'border-r border-edge-muted': preview(),'pt-2 pb-0': showHelpDrawer().has(selectedView()),diff --git a/js/app/packages/macro-entity/src/components/CustomScrollbar.tsx b/js/app/packages/macro-entity/src/components/CustomScrollbar.tsxnew file mode 100644index 0000000000..99dab494b8--- /dev/null+++ b/js/app/packages/macro-entity/src/components/CustomScrollbar.tsx@@ -0,0 +1,220 @@+import { createEffect, createSignal, onCleanup, Show } from 'solid-js';++interface CustomScrollbarProps {+ scrollContainer: () => HTMLElement | undefined;+ class?: string;+}++export function CustomScrollbar(props: CustomScrollbarProps) {+ const [scrollTop, setScrollTop] = createSignal(0);+ const [scrollHeight, setScrollHeight] = createSignal(0);+ const [clientHeight, setClientHeight] = createSignal(0);+ const [isDragging, setIsDragging] = createSignal(false);+ const [scrollStartTop, setScrollStartTop] = createSignal(0);+ const [scrollVelocity, setScrollVelocity] = createSignal(0);+ const [isHovering, setIsHovering] = createSignal(false);+ let lastScrollTop = 0;+ let lastScrollTime = Date.now();+ let velocityTimeoutId: ReturnType<typeof setTimeout> | undefined;++ const updateScrollMetrics = () => {+ const container = props.scrollContainer();+ if (!container) return;++ setScrollTop(container.scrollTop);+ setScrollHeight(container.scrollHeight);+ setClientHeight(container.clientHeight);+ };++ // Calculate scrollbar metrics+ const thumbHeight = () => {+ const containerHeight = clientHeight();+ const contentHeight = scrollHeight();+ if (contentHeight <= containerHeight) return 0;+ return Math.max(20, (containerHeight / contentHeight) * containerHeight);+ };+ const thumbTop = () => {+ const containerHeight = clientHeight();+ const contentHeight = scrollHeight();+ const maxScroll = contentHeight - containerHeight;+ if (maxScroll <= 0) return 0;+ const thumbH = thumbHeight();+ return (scrollTop() / maxScroll) * (containerHeight - thumbH);+ };+ const isVisible = () => scrollHeight() > clientHeight();++ // Handle scroll events+ createEffect(() => {+ const container = props.scrollContainer();+ if (!container) return;++ updateScrollMetrics();++ const handleScroll = () => {+ if (!isDragging()) {+ updateScrollMetrics();+ }++ // Calculate scroll velocity+ const now = Date.now();+ const timeDelta = now - lastScrollTime;+ const scrollDelta = Math.abs(container.scrollTop - lastScrollTop);+ const velocity = timeDelta > 0 ? scrollDelta / timeDelta : 0;++ lastScrollTop = container.scrollTop;+ lastScrollTime = now;++ setScrollVelocity(velocity);++ // Gradually reduce velocity - slower fade out+ if (velocityTimeoutId) clearTimeout(velocityTimeoutId);+ velocityTimeoutId = setTimeout(() => {+ setScrollVelocity((prev) => {+ const newVel = prev * 0.85;+ if (newVel < 0.05) return 0;+ setTimeout(() => setScrollVelocity(0), 100);+ return newVel;+ });+ }, 200);+ };++ const handleResize = () => {+ updateScrollMetrics();+ };++ container.addEventListener('scroll', handleScroll, { passive: true });+ const resizeObserver = new ResizeObserver(handleResize);+ resizeObserver.observe(container);++ onCleanup(() => {+ container.removeEventListener('scroll', handleScroll);+ resizeObserver.disconnect();+ if (velocityTimeoutId) clearTimeout(velocityTimeoutId);+ });+ });++ // Handle mouse drag+ const handleMouseDown = (e: MouseEvent) => {+ e.preventDefault();+ e.stopPropagation();++ const container = props.scrollContainer();+ if (!container) return;++ setIsDragging(true);+ setScrollStartTop(container.scrollTop);++ let isDraggingLocal = true;+ const handleMouseMove = (moveEvent: MouseEvent) => {+ if (!isDraggingLocal) return;++ const deltaY = moveEvent.clientY - e.clientY;+ const trackH = clientHeight();+ const contentHeight = scrollHeight();+ const maxScroll = contentHeight - trackH;+ const thumbH = thumbHeight();++ const scrollRatio = deltaY / (trackH - thumbH);+ const newScrollTop = Math.max(+ 0,+ Math.min(maxScroll, scrollStartTop() + scrollRatio * maxScroll)+ );++ container.scrollTop = newScrollTop;+ setScrollTop(newScrollTop);+ };++ const handleMouseUp = () => {+ isDraggingLocal = false;+ setIsDragging(false);+ document.removeEventListener('mousemove', handleMouseMove);+ document.removeEventListener('mouseup', handleMouseUp);+ };++ document.addEventListener('mousemove', handleMouseMove);+ document.addEventListener('mouseup', handleMouseUp);+ };++ // Handle track click+ const handleTrackClick = (e: MouseEvent) => {+ const container = props.scrollContainer();+ if (!container) return;++ const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();+ const clickY = e.clientY - rect.top;+ const trackH = clientHeight();+ const contentHeight = scrollHeight();+ const maxScroll = contentHeight - trackH;++ const scrollRatio = clickY / trackH;+ const newScrollTop = Math.max(+ 0,+ Math.min(maxScroll, scrollRatio * maxScroll)+ );++ container.scrollTop = newScrollTop;+ setScrollTop(newScrollTop);+ };++ return (+ <Show when={isVisible()}>+ <div+ class={`absolute right-0 top-0 bottom-0 w-[2px] pointer-events-auto ${props.class || ''}`}+ style={{+ 'background-color': 'transparent',+ }}+ onMouseEnter={() => setIsHovering(true)}+ onMouseLeave={() => setIsHovering(false)}+ >+ {/* Track */}+ <div+ class="absolute inset-0 cursor-pointer"+ onClick={handleTrackClick}+ style={{+ 'background-color': 'transparent',+ }}+ />+ {/* Thumb */}+ <div+ class="absolute right-0 cursor-grab active:cursor-grabbing transition-all duration-200 ease-out"+ style={{+ top: `${thumbTop()}px`,+ height: `${thumbHeight()}px`,+ width: '2px',+ 'background-color': 'var(--color-accent)',+ opacity: (() => {+ if (isDragging()) return 1;+ if (isHovering()) return 0.8;+ const vel = scrollVelocity();+ if (vel === 0) return 0;+ // Normalize velocity (0-5px/ms is typical fast scroll)+ const normalizedVel = Math.min(vel / 5, 1);+ return normalizedVel;+ })(),+ 'box-shadow': (() => {+ if (isDragging()) {+ return '0 0 8px oklch(from var(--color-accent) l c h / 0.6), 0 0 4px oklch(from var(--color-accent) l c h / 0.4)';+ }+ const vel = scrollVelocity();+ if (vel === 0) return 'none';+ const normalizedVel = Math.min(vel / 5, 1);+ const glowOpacity = normalizedVel * 0.6;+ const glowOpacity2 = normalizedVel * 0.4;+ return `0 0 ${8 * normalizedVel}px oklch(from var(--color-accent) l c h / ${glowOpacity}), 0 0 ${4 * normalizedVel}px oklch(from var(--color-accent) l c h / ${glowOpacity2})`;+ })(),+ transform: (() => {+ if (isDragging()) return 'scaleX(1.6)';+ const vel = scrollVelocity();+ if (vel === 0) return 'scaleX(1)';+ // Scale more aggressively with velocity - up to 2x width at high speeds+ const normalizedVel = Math.min(vel / 5, 1);+ return `scaleX(${1 + normalizedVel * 1.0})`;+ })(),+ 'transition-property': 'opacity, box-shadow, transform',+ }}+ onMouseDown={handleMouseDown}+ />+ </div>+ </Show>+ );+}diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsxindex 6f49275136..704ec94e31 100644--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx@@ -345,7 +345,7 @@ export function EntityWithEverything(use:droppableclass={`relative group py-[5px] px-2 ${ITEM_WRAPPER_CLASS()}`}classList={{- 'bg-hover ring-1 ring-inset ring-edge-muted/50': props.highlighted,+ 'bg-hover ring-1 ring-edge-muted/50': props.highlighted,bracket: props.selected,}}onMouseOver={(e) => {diff --git a/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx b/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsxindex 1182035fbe..f8371d8857 100644--- a/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx+++ b/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx@@ -35,6 +35,7 @@ import type {EntityRenderer,} from '../types/entity';import type { WithSearch } from '../types/search';+import { CustomScrollbar } from './CustomScrollbar';import { Entity } from './Entity';const isSearchEntity = (entity: EntityData): entity is WithSearch<EntityData> =>@@ -481,7 +482,7 @@ export function createUnifiedInfiniteList<T extends EntityData>({{/* TODO: Filtered Empty State */}</Match><Match when={true}>- <div class="flex size-full" ref={setListRef}>+ <div class="flex size-full relative" ref={setListRef}><StaticMarkdownContext><Fragmentref={(el) => {@@ -493,7 +494,7 @@ export function createUnifiedInfiniteList<T extends EntityData>({<VListref={props.virtualizerHandle}data={sortedEntitiesStore}- class={LIST_WRAPPER}+ class={`${LIST_WRAPPER} scrollbar-hidden`}data-unified-entity-listoverscan={computedOverscan()}>@@ -520,6 +521,17 @@ export function createUnifiedInfiniteList<T extends EntityData>({</div> */}</Fragment></StaticMarkdownContext>+ <CustomScrollbar+ scrollContainer={() => {+ // Find the actual scroll container (VList creates its own scroll container)+ const listEl = listRef();+ if (!listEl) return undefined;+ const scrollContainer = listEl.querySelector(+ '[data-unified-entity-list]'+ ) as HTMLElement;+ return scrollContainer || undefined;+ }}+ /></div></Match></Switch>