Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(sidebar): Move create and search buttons (#1816)

dev-rbc647103c3235
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.tsx
index 54ada1c7ff..7efe6ad779 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
@@ -112,7 +112,7 @@ function ChannelGroupItem(props: { group: ChannelGroup; animate?: boolean }) {
<Button
as={'a'}
href={`/channel/${props.group.entityId}`}
- class="flex items-center justify-start gap-3 w-full"
+ class="flex items-center justify-start gap-3 w-full cursor-default"
variant="ghost"
classList={{
'opacity-0 -translate-y-2': !isVisible(),
diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsx
index 8c5586db4c..9432e5f7c4 100644
--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx
+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx
@@ -12,7 +12,7 @@ import { AnimatedFolderIcon } from '@macro-icons/wide/animating/folder';
import { useLocation } from '@solidjs/router';
import LogoIcon from '@macro-icons/macro-logo.svg';
import PlusIcon from '@macro-icons/wide/plus.svg';
-import SearchIcon from '@phosphor-icons/core/regular/magnifying-glass.svg?component-solid';
+import SearchIcon from '@phosphor-icons/core/bold/magnifying-glass-bold.svg?component-solid';
import CommandIcon from '@phosphor-icons/core/assets/regular/command.svg';
import { LIST_VIEW_PATHS, type ListView } from '@app/constants/list-views';
import { LabelAndHotKey, Tooltip } from '@core/component/Tooltip';
@@ -38,6 +38,7 @@ interface SidebarItem {
JSX.SvgSVGAttributes<SVGSVGElement> | { triggerAnimation?: boolean }
>;
hotkey: ValidHotkey;
+ standaloneHotkey?: boolean;
}
export const SIDEBAR_LINKS = [
@@ -48,6 +49,14 @@ export const SIDEBAR_LINKS = [
icon: TrayIcon,
hotkey: 'i',
},
+ {
+ id: 'search',
+ label: 'Search',
+ href: LIST_VIEW_PATHS.search,
+ icon: SearchIcon,
+ hotkey: '/',
+ standaloneHotkey: true,
+ },
{
id: 'agents',
label: 'Agents',
@@ -90,7 +99,7 @@ export const SIDEBAR_LINKS = [
icon: AnimatedFolderIcon,
hotkey: 'f',
},
-] as const satisfies SidebarItem[];
+] satisfies SidebarItem[];
export type SidebarState = 'hidden' | 'expanded' | 'slim';
@@ -127,7 +136,7 @@ export const AppSidebar = (props: AppSidebarProps) => {
for (const link of SIDEBAR_LINKS) {
registerHotkey({
hotkey: link.hotkey,
- scopeId: GO_TO_COMMAND_SCOPE,
+ scopeId: link.standaloneHotkey ? 'global' : GO_TO_COMMAND_SCOPE,
description: `Go to ${link.label}`,
keyDownHandler: (e) => {
e?.preventDefault();
@@ -163,53 +172,27 @@ export const AppSidebar = (props: AppSidebarProps) => {
</Show>
<div
class={cn(
- 'h-full bg-page pt-2 flex flex-col gap-4 mobile:absolute mobile:z-modal-content transition-[width_transform_opacity] duration-200 ease-in-out',
+ 'group/sidebar h-full bg-page pt-2 flex flex-col gap-4 mobile:absolute mobile:z-modal-content transition-[width_transform_opacity] duration-150 ease-in-out',
isExpanded() &&
'max-w-56 w-full mobile:max-w-2/3 translate-x-0 opacity-100',
props.sidebarState === 'hidden' &&
'-translate-x-full overflow-hidden opacity-0',
isSlim() &&
- 'max-w-10 w-full mobile:max-w-2/3 translate-x-0 opacity-100'
+ 'max-w-12 w-full mobile:max-w-2/3 translate-x-0 opacity-100'
)}
+ data-expanded={isExpanded()}
+ data-slim={isSlim()}
>
<div
class={cn(
'flex items-center justify-between py-2 pl-3 pr-2',
- isSlim() && 'flex-col gap-2 px-2 justify-center'
+ isSlim() && 'flex-col px-2 pb-0 justify-center'
)}
>
- <LogoIcon class="size-6 text-accent" />
+ <LogoIcon class="size-6 text-accent opacity-100 group-data-[slim=true]/sidebar:opacity-0 group-data-[slim=true]/sidebar:size-0" />
<div class="flex items-center gap-1">
<Show when={isExpanded()}>
- <Tooltip tooltip={<LabelAndHotKey label="Search" shortcut="/" />}>
- <Button
- as="a"
- class="cursor-default"
- variant="tertiary"
- size="icon-sm"
- href={`/component/search`}
- onClick={(e) => {
- // Middle mouse handling
- if (e.button === 1) return;
-
- e.preventDefault();
- layout.openWithSplit(
- {
- type: 'component',
- id: 'search',
- },
- {
- preferNewSplit: e.shiftKey,
- mergeHistory: true,
- allowDuplicate: true,
- }
- );
- }}
- >
- <SearchIcon />
- </Button>
- </Tooltip>
<Tooltip
tooltip={
<LabelAndHotKey label="Command palette" shortcut="⌘K" />
@@ -223,17 +206,6 @@ export const AppSidebar = (props: AppSidebarProps) => {
<CommandIcon />
</Button>
</Tooltip>
- <Tooltip
- tooltip={<LabelAndHotKey label="Create new" shortcut="c" />}
- >
- <Button
- variant="tertiary"
- size="icon-sm"
- onClick={handleCreateClick}
- >
- <PlusIcon />
- </Button>
- </Tooltip>
<Tooltip
tooltip={
<LabelAndHotKey
@@ -265,6 +237,26 @@ export const AppSidebar = (props: AppSidebarProps) => {
</div>
</div>
+ <Tooltip
+ class={
+ 'group-data-[slim=true]/sidebar:px-0.5 px-2 flex items-center justify-center'
+ }
+ tooltip={<LabelAndHotKey label="Create new" shortcut="c" />}
+ >
+ <Button
+ class={
+ 'justify-center group-data-[slim=true]/sidebar:aspect-square group-data-[expanded=true]/sidebar:justify-start group-data-[expanded=true]/sidebar:w-full'
+ }
+ variant="tertiary"
+ onClick={handleCreateClick}
+ >
+ <PlusIcon class="size-4 shrink-0" />
+ <span class="opacity-100 group-data-[slim=true]/sidebar:sr-only group-data-[slim=true]/sidebar:opacity-0">
+ Create
+ </span>
+ </Button>
+ </Tooltip>
+
<nav>
<ul class="w-full h-full px-2 flex flex-col gap-1">
<For each={SIDEBAR_LINKS}>
@@ -279,6 +271,7 @@ export const AppSidebar = (props: AppSidebarProps) => {
</For>
</ul>
</nav>
+
<Show when={isExpanded()}>
<div class="block max-h-[clamp(10%,60%,20rem)]">
<ChannelsUnreadWidget />
@@ -326,7 +319,7 @@ const SidebarLink = (props: SidebarLinkProps) => {
class={cn(
'flex items-center justify-start text-sm gap-2 cursor-default',
isActive() && 'bg-ink/15 not-disabled:hover:bg-ink/15 text-ink',
- props.sidebarState === 'slim' && 'justify-center aspect-square',
+ props.sidebarState === 'slim' && 'size-8 justify-center aspect-square',
props.sidebarState !== 'slim' && 'w-full'
)}
href={`${ROUTER_BASE}/component${props.href}`}
@@ -355,7 +348,9 @@ const SidebarLink = (props: SidebarLinkProps) => {
<Dynamic component={props.icon} triggerAnimation={isHovering()} />
</div>
</Show>
- <Show when={props.sidebarState === 'expanded'}>{props.label}</Show>
+ <span class="opacity-100 group-data-[slim=true]/sidebar:sr-only group-data-[slim=true]/sidebar:opacity-0">
+ {props.label}
+ </span>
</Button>
);
};