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(core): new tabs component and use in top bar and command (#3306)
Seamusf5d799b98702
diff --git a/js/app/packages/app/component/command/CommandMenu.tsx b/js/app/packages/app/component/command/CommandMenu.tsxindex d734ab2212..1355e8852b 100644--- a/js/app/packages/app/component/command/CommandMenu.tsx+++ b/js/app/packages/app/component/command/CommandMenu.tsx@@ -2,7 +2,7 @@ import { useAnalytics } from '@app/component/analytics-context';import { getSearchSplit } from '@app/component/next-soup/soup-view/search-controllers';import { isListViewID } from '@app/constants/list-views';import { globalSplitManager } from '@app/signal/splitLayout';-import { Tabs } from '@core/component/Tabs';+import { TabsInset } from '@core/component/TabsInset';import { itemToBlockName } from '@core/constant/allBlocks';import { getActiveCommandsFromScope } from '@core/hotkey/getCommands';import type { RegisterHotkeyReturn } from '@core/hotkey/types';@@ -491,14 +491,15 @@ export function CommandMenuInner(props: {<Show when={isEntityActionMode() || !isInCommandScope()}><Panel.Toolbarclass={cn(- 'bg-surface',+ 'bg-surface border-0',isEntityActionMode() ? 'px-3 gap-2' : 'px-1.5')}><Showwhen={isEntityActionMode()}fallback={- <Tabs+ <TabsInset+ depth={1}list={categoryTabs}value={CommandState.categoryFilter()}onChange={(value) => {diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsxindex b45fb9eb9f..244e14f7d5 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx@@ -154,7 +154,7 @@ export const SoupSearchbar = (props: SoupSearchbarProps) => {><divclass={cn(- 'group w-full relative flex items-center gap-1 rounded-sm h-7 mobile:h-9 pl-2 pr-1 mobile:min-w-35 border text-xs',+ 'group w-full relative flex items-center gap-1 rounded-md h-7 mobile:h-9 pl-2 pr-1 mobile:min-w-35 border text-xs',variantStyles[props.variant ?? 'secondary'])}>diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsxindex 7a01a63934..51384a67c7 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx@@ -8,6 +8,7 @@ import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-conteximport { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';import { isListViewID, type ListView } from '@app/constants/list-views';import { type TabItem, Tabs } from '@core/component/Tabs';+import { TabsInset } from '@core/component/TabsInset';import { useUserContext } from '@core/context/user';import ChevronDownIcon from '@icon/regular/caret-down.svg';import { Dropdown, Layer } from '@ui';@@ -133,7 +134,7 @@ const ViewTabs = (props: { view: TabbedListView }) => {const list = () => VIEW_TAB_LISTS[props.view];return (- <Tabs+ <TabsInsetlist={list()}value={activeTab()}defaultValue={VIEW_TAB_PRESETS[props.view].default}diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsxindex 025f4a326f..aa790c5377 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx@@ -341,6 +341,9 @@ export const SoupView = (props: SoupViewProps) => {'flex-1 min-w-0': narrowSearchExpanded(),})}>+ <Show when={!isMobile() && !narrowSearchExpanded()}>+ <span class="text-base font-bold">{props.viewName}</span>+ </Show><Showwhen={!narrowSearchExpanded() && !isComponentListView('search')diff --git a/js/app/packages/app/component/side-panel/SidePanel.tsx b/js/app/packages/app/component/side-panel/SidePanel.tsxindex a2857a8a79..fc4a4eaad5 100644--- a/js/app/packages/app/component/side-panel/SidePanel.tsx+++ b/js/app/packages/app/component/side-panel/SidePanel.tsx@@ -1,8 +1,9 @@import { Resize, ResizeZoneContext } from '@core/component/Resize/Resize';+import { TabsInset } from '@core/component/TabsInset';import { isMobile } from '@core/mobile/isMobile';import CaretRight from '@icon/fill/caret-right-fill.svg';import { Accordion } from '@kobalte/core/accordion';-import { cn, Layer, Panel, Scroll } from '@ui';+import { Panel, Scroll } from '@ui';import {type Accessor,children,@@ -286,48 +287,23 @@ function useSidePanel() {function NarrowTabs(props: { contentLabel?: string; infoLabel?: string }) {const ctx = useContext(SidePanelContext);if (!ctx) return null;++ const value = () => (ctx.isOpen() ? 'info' : 'content');+return (<Show when={ctx.isNarrow() && ctx.hasSections()}>- <Layer depth={0}>- <div class="flex items-center shrink-0 bg-edge-muted p-0.5 rounded-sm">- <Layer depth={3}>- <NarrowTab- active={!ctx.isOpen()}- label={props.contentLabel ?? 'Content'}- onClick={() => ctx.setIsOpen(false)}- />- <NarrowTab- active={ctx.isOpen()}- label={props.infoLabel ?? 'Info'}- onClick={() => ctx.setIsOpen(true)}- />- </Layer>- </div>- </Layer>+ <TabsInset+ list={[+ { value: 'content', label: props.contentLabel ?? 'Content' },+ { value: 'info', label: props.infoLabel ?? 'Info' },+ ]}+ value={value()}+ onChange={(v) => ctx.setIsOpen(v === 'info')}+ /></Show>);}-function NarrowTab(props: {- active: boolean;- label: string;- onClick: () => void;-}) {- return (- <button- type="button"- aria-pressed={props.active}- onClick={props.onClick}- class={cn(- 'text-xs px-2.5 py-0.5 rounded-xs transition-colors',- props.active ? 'bg-surface text-ink' : 'text-ink-muted hover:text-ink'- )}- >- {props.label}- </button>- );-}-/** Indicates whether the current subtree has a SidePanel.Layout ancestor. */function useHasSidePanel(): boolean {return useContext(SidePanelContext) !== undefined;diff --git a/js/app/packages/block-channel/component/Top.tsx b/js/app/packages/block-channel/component/Top.tsxindex a3eb585cb6..ae7302073a 100644--- a/js/app/packages/block-channel/component/Top.tsx+++ b/js/app/packages/block-channel/component/Top.tsx@@ -3,7 +3,8 @@ import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeaimport { SplitLabel } from '@app/component/split-layout/components/SplitLabel';import type { ChannelTabId } from '@channel/Channel/channel-tabs';import { useBlockId } from '@core/block';-import { type TabItem, Tabs } from '@core/component/Tabs';+import type { TabItem } from '@core/component/Tabs';+import { TabsInset } from '@core/component/TabsInset';import { UserIcon } from '@core/component/UserIcon';import { useChannelName } from '@core/context/channels';import { useUserId } from '@core/context/user';@@ -101,8 +102,8 @@ export function ChannelTopLeft(props: ChannelTopLeftProps) {<Showwhen={!isMobile()}fallback={- <div class="ph-no-capture flex items-center min-w-0 shrink-0 h-full">- <Tabs+ <div class="ph-no-capture flex items-center min-w-0 shrink-0 h-full mx-2">+ <TabsInsetlist={iconTabList()}value={props.activeTab}onChange={(value) => props.onTabChange?.(value as ChannelTabId)}@@ -113,16 +114,16 @@ export function ChannelTopLeft(props: ChannelTopLeftProps) {<CollapsibleHeaderItemid="channel-tabs"priority={1}- containerClass="ph-no-capture min-w-0 shrink-0 h-full"+ containerClass="ph-no-capture min-w-0 shrink-0 h-full mx-2"expanded={() => (- <Tabs+ <TabsInsetlist={[...(props.tabs ?? [])]}value={props.activeTab}onChange={(value) => props.onTabChange?.(value as ChannelTabId)}/>)}collapsed={() => (- <Tabs+ <TabsInsetlist={iconTabList()}value={props.activeTab}onChange={(value) => props.onTabChange?.(value as ChannelTabId)}diff --git a/js/app/packages/core/component/TabsInset.tsx b/js/app/packages/core/component/TabsInset.tsxnew file mode 100644index 0000000000..91d027acc6--- /dev/null+++ b/js/app/packages/core/component/TabsInset.tsx@@ -0,0 +1,67 @@+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import {+ SegmentedControl as KSegmentedControl,+ type SegmentedControlRootProps,+} from '@kobalte/core/segmented-control';+import { cn, Layer } from '@ui';+import { For, type JSX, splitProps } from 'solid-js';++export type TabItem = {+ value: string;+ label: string | JSX.Element;+};++export type TabsInsetProps = {+ list: TabItem[];+ value?: string;+ defaultValue?: string;+ class?: string;+ depth?: 0 | 1 | 2 | 3 | 4 | 5;+} & Omit<SegmentedControlRootProps, 'defaultValue'>;++export const TabsInset = (props: TabsInsetProps) => {+ const [local, rootProps] = splitProps(props, [+ 'list',+ 'value',+ 'defaultValue',+ 'disabled',+ 'class',+ 'depth',+ ]);++ return (+ <KSegmentedControl+ value={local.value}+ defaultValue={local.defaultValue ?? local.list[0]?.value}+ disabled={local.disabled}+ {...rootProps}+ class={cn('h-full flex items-center', local.class)}+ >+ <Layer depth={local.depth ?? 0}>+ <div class="relative flex items-center bg-surface rounded-lg p-0.5 ring ring-edge-muted">+ <For each={local.list}>+ {(item) => (+ <Layer depth={2}>+ <KSegmentedControl.Item+ value={item.value}+ disabled={local.disabled}+ >+ <KSegmentedControl.ItemInput class="absolute inset-0 pointer-events-none" />+ <KSegmentedControl.ItemLabel+ class="flex items-center px-2.5 py-1 text-xs font-medium data-checked:ring data-checked:ring-edge-muted ring-inset rounded-md text-ink-extra-muted hover:text-ink data-checked:bg-surface data-checked:text-ink data-checked:shadow-sm"+ onPointerDown={(e) => {+ if (isTouchDevice()) e.preventDefault();+ }}+ onClick={() => rootProps.onChange?.(item.value)}+ >+ {item.label}+ </KSegmentedControl.ItemLabel>+ </KSegmentedControl.Item>+ </Layer>+ )}+ </For>+ </div>+ </Layer>+ </KSegmentedControl>+ );+};