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(sidebar): unread channel widget for slim mode (#2595)
dev-rbe3bc3df03b21
diff --git a/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx b/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsxindex cd193ffd2d..a144b54f31 100644--- a/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx+++ b/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx@@ -13,13 +13,16 @@ import {import ChannelIcon from '@macro-icons/wide/channel.svg?component-solid';import { UserIcon } from '@core/component/UserIcon';import { useSenderName } from '@app/component/app-sidebar/utils';-import { Button } from '@app/component/next-soup/soup-view/filters-bar/button';import { globalSplitManager } from '@app/signal/splitLayout';import { compareDateDesc } from '@core/util/date';import { ContextMenuContent, MenuItem } from '@core/component/Menu';import { ContextMenu } from '@kobalte/core/context-menu';+import { Tooltip } from '@core/component/Tooltip';import { getChannelNotificationParams } from '@notifications/notification-navigation';import { isChannelNotification } from '@notifications/notification-helpers';+import type { SidebarState } from '@app/component/app-sidebar/sidebar';+import { cn } from '@ui/utils/classname';+import { Button } from '@ui/components/Button';function getChannelInfo(notification: UnifiedNotification): {channelName: string | null;@@ -81,7 +84,11 @@ function groupByChannel(return groups;}-function ChannelGroupItem(props: { group: ChannelGroup; animate?: boolean }) {+function ChannelGroupItem(props: {+ group: ChannelGroup;+ animate?: boolean;+ isSlim?: boolean;+}) {const [isVisible, setIsVisible] = createSignal(!props.animate);onMount(() => {@@ -136,55 +143,81 @@ function ChannelGroupItem(props: { group: ChannelGroup; animate?: boolean }) {});};+ const isSlim = () => props.isSlim ?? false;++ const ButtonContent = () => (+ <Button+ as={'a'}+ href={`/channel/${props.group.entityId}`}+ class={cn(+ 'flex items-center cursor-default rounded-xs',+ isSlim() ? 'justify-center size-8' : 'justify-start gap-3 size-full'+ )}+ draggable={false}+ variant="ghost"+ size="sm"+ classList={{+ 'opacity-0 -translate-y-2': !isVisible(),+ 'opacity-100 translate-y-0': isVisible(),+ }}+ onClick={(e) => {+ if (e.button === 1) return;++ e.preventDefault();+ navigateToLatestNotification(e.shiftKey);+ }}+ >+ <div class="size-5 relative flex items-center justify-center flex-shrink-0">+ <Show+ when={props.group.isDM && props.group.latestSenderId}+ fallback={+ <div class="text-ink-muted size-4">+ <ChannelIcon />+ </div>+ }+ >+ <UserIcon+ id={props.group.latestSenderId!}+ size="fill"+ suppressClick+ showTooltip={false}+ />+ </Show>+ <Show when={isSlim()}>+ <div class="absolute -top-0.5 -right-0.5 size-1.5 bg-accent rounded-full" />+ </Show>+ </div>++ <Show when={!isSlim()}>+ <span class="text-sm font-medium text-ink truncate">+ {displayName()}+ </span>++ <Show when={count() > 0}>+ <span class="flex-shrink-0 min-w-5 h-5 px-1.5 flex items-center justify-center text-xs font-medium bg-accent/10 text-accent rounded ml-auto">+ {count()}+ </span>+ </Show>+ </Show>+ </Button>+ );+return (<ContextMenu><ContextMenu.Trigger class="w-full">- <Button- as={'a'}- href={`/channel/${props.group.entityId}`}- class="flex items-center justify-start gap-3 w-full cursor-default rounded-xs"- draggable={false}- variant="ghost"- size="sm"- classList={{- 'opacity-0 -translate-y-2': !isVisible(),- 'opacity-100 translate-y-0': isVisible(),- }}- onClick={(e) => {- if (e.button === 1) return;-- e.preventDefault();- navigateToLatestNotification(e.shiftKey);- }}- >- <div class="flex-shrink-0">- <Show- when={props.group.isDM && props.group.latestSenderId}- fallback={- <div class="size-4 text-ink-muted">- <ChannelIcon />- </div>- }+ <Show+ when={!isSlim()}+ fallback={+ <Tooltip+ tooltip={<span class="text-xs">{displayName()}</span>}+ placement="right">- <UserIcon- id={props.group.latestSenderId!}- size="xs"- suppressClick- showTooltip={false}- />- </Show>- </div>-- <span class="text-sm font-medium text-ink truncate">- {displayName()}- </span>-- <Show when={count() > 0}>- <span class="flex-shrink-0 min-w-5 h-5 px-1.5 flex items-center justify-center text-xs font-medium bg-accent/10 text-accent rounded ml-auto">- {count()}- </span>- </Show>- </Button>+ <ButtonContent />+ </Tooltip>+ }+ >+ <ButtonContent />+ </Show></ContextMenu.Trigger><ContextMenu.Portal>@@ -207,7 +240,7 @@ function filterUnreadNotDone(notifications: UnifiedNotification[]) {return notifications.filter((n) => !n.viewed_at && !n.done);}-export const ChannelsUnreadWidget = () => {+export const ChannelsUnreadWidget = (props: { sidebarState: SidebarState }) => {const notificationSource = useGlobalNotificationSource();const allNotifications = () => [...notificationSource.notifications()];@@ -246,19 +279,42 @@ export const ChannelsUnreadWidget = () => {.filter((g): g is ChannelGroup => g != null);});+ const isSlim = () => props.sidebarState === 'slim';+ const SLIM_MAX = 4;+ const slimVisible = () => channelGroups().slice(0, SLIM_MAX);+ const slimOverflow = () => Math.max(0, channelGroups().length - SLIM_MAX);+return (<Show when={channelGroups().length > 0}>- <section class="w-full h-full px-2 py-1.5 flex flex-col justify-center">- <header class="text-xs font-medium text-ink-muted ml-3">- <h1>Unread</h1>- </header>-- <div class="flex-1 overflow-hidden">- <For each={channelGroups()}>- {(group) => <ChannelGroupItem group={group} animate={false} />}- </For>- </div>- </section>+ <Show+ when={!isSlim()}+ fallback={+ <section class="w-full py-2 px-2 flex flex-col items-center">+ <For each={slimVisible()}>+ {(group) => (+ <ChannelGroupItem group={group} animate={false} isSlim />+ )}+ </For>+ <Show when={slimOverflow() > 0}>+ <span class="text-[10px] text-ink-muted mt-1">+ +{slimOverflow()}+ </span>+ </Show>+ </section>+ }+ >+ <section class="w-full h-full flex flex-col justify-center px-2 py-1.5">+ <header class="text-xs font-medium text-ink-muted ml-2 mb-1">+ <h1>Unread</h1>+ </header>++ <div class="flex-1">+ <For each={channelGroups()}>+ {(group) => <ChannelGroupItem group={group} animate={false} />}+ </For>+ </div>+ </section>+ </Show></Show>);};diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsxindex d24d5e1bc2..6074b48baa 100644--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx@@ -507,11 +507,9 @@ export const AppSidebar = (props: AppSidebarProps) => {<hr class="border-ink/5 my-[8px]" /></div>- <Show when={isExpanded()}>- <div class="block max-h-[clamp(10%,60%,20rem)]">- <ChannelsUnreadWidget />- </div>- </Show>+ <div class="block max-h-[clamp(10%,60%,20rem)]">+ <ChannelsUnreadWidget sidebarState={props.sidebarState ?? 'expanded'} />+ </div><div class="px-2 mt-auto w-full"><hr class="border-edge-muted mb-[8px]" />