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.

feat: mobile topbar redesign (#1731)

Peter Chinmanb91652ae844f
diff --git a/js/app/packages/app/component/ResponsiveBlockToolbar.tsx b/js/app/packages/app/component/ResponsiveBlockToolbar.tsx
new file mode 100644
index 0000000000..363e42625d
--- /dev/null
+++ b/js/app/packages/app/component/ResponsiveBlockToolbar.tsx
@@ -0,0 +1,132 @@
+import { cn } from '@ui/utils/classname';
+import { isMobile } from '@core/mobile/isMobile';
+import type { ItemType } from '@service-storage/client';
+import { type Component, For, type JSX, Show } from 'solid-js';
+import {
+ type FileOperation,
+ SplitFileMenu,
+} from './split-layout/components/SplitFileMenu';
+import {
+ SplitHeaderLeft,
+ SplitHeaderRight,
+} from './split-layout/components/SplitHeader';
+import {
+ SplitToolbarLeft,
+ SplitToolbarRight,
+} from './split-layout/components/SplitToolbar';
+import { Button } from '@ui/components/Button';
+import { Dynamic } from 'solid-js/web';
+import { SplitPermissionsBadge } from './split-layout/components/SplitLabel';
+
+export type BlockTool = {
+ label: string | (() => string);
+ icon: Component;
+ action: () => void;
+ condition?: () => boolean;
+ isActive?: () => boolean;
+ buttonComponent?: () => JSX.Element;
+ divideAbove?: boolean;
+};
+
+export function ToolButton(props: { tool: BlockTool }) {
+ return (
+ <Button
+ onClick={props.tool.action}
+ tooltip={
+ typeof props.tool.label === 'function'
+ ? props.tool.label()
+ : props.tool.label
+ }
+ class={cn(
+ 'px-1',
+ props.tool.isActive?.() &&
+ 'bg-accent/20 hover:bg-accent/30 text-accent-ink'
+ )}
+ >
+ <Dynamic
+ component={
+ props.tool.icon as Component<JSX.SvgSVGAttributes<SVGSVGElement>>
+ }
+ class="size-4 shrink-0"
+ />
+ </Button>
+ );
+}
+
+export function ResponsivePermissionsBadge() {
+ return (
+ <Show
+ when={isMobile()}
+ fallback={
+ <SplitHeaderRight>
+ <SplitPermissionsBadge />
+ </SplitHeaderRight>
+ }
+ >
+ <SplitHeaderLeft>
+ <SplitPermissionsBadge />
+ </SplitHeaderLeft>
+ </Show>
+ );
+}
+
+interface BlockToolbarProps {
+ tools: BlockTool[];
+ ops: FileOperation[];
+ id: string;
+ itemType: ItemType;
+ name: string;
+ formattedName?: string;
+}
+
+/**
+ * Handles the standard arrangement of file ops and block tools on desktop and mobile. On mobile, they are condensed together into a dropdown menu in the SplitHeader.
+ */
+export function ResponsiveBlockToolbar(props: BlockToolbarProps) {
+ return (
+ <Show
+ when={isMobile()}
+ fallback={
+ <>
+ <Show when={props.ops.length > 0}>
+ <SplitToolbarLeft>
+ <SplitFileMenu
+ id={props.id}
+ itemType={props.itemType}
+ name={props.name}
+ formattedName={props.formattedName}
+ ops={props.ops}
+ buttonClass="order-first"
+ />
+ </SplitToolbarLeft>
+ </Show>
+ <SplitToolbarRight>
+ <For each={props.tools}>
+ {(tool) => (
+ <Show when={!tool.condition || tool.condition()}>
+ {tool.buttonComponent ? (
+ <tool.buttonComponent />
+ ) : (
+ <ToolButton tool={tool} />
+ )}
+ </Show>
+ )}
+ </For>
+ </SplitToolbarRight>
+ </>
+ }
+ >
+ <SplitHeaderRight>
+ <SplitFileMenu
+ id={props.id}
+ itemType={props.itemType}
+ name={props.name}
+ formattedName={props.formattedName}
+ ops={props.ops}
+ tools={props.tools}
+ buttonClass="order-last"
+ />
+ </SplitHeaderRight>
+ </Show>
+ );
+}
diff --git a/js/app/packages/app/component/split-layout/components/SplitFileMenu.tsx b/js/app/packages/app/component/split-layout/components/SplitFileMenu.tsx
index cc91a14a64..d550c1f5e5 100644
--- a/js/app/packages/app/component/split-layout/components/SplitFileMenu.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitFileMenu.tsx
@@ -1,5 +1,4 @@
import { useBlockName } from '@core/block';
-import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';
import { useItemOperations } from '@core/component/FileList/useItemOperations';
import { MenuItem } from '@core/component/Menu';
import { useIsDocumentOwner } from '@core/signal/permissions';
@@ -10,6 +9,8 @@ import Rename from '@icon/regular/pencil-line.svg';
import Trash from '@icon/regular/trash-simple.svg';
import { DropdownMenu } from '@kobalte/core/dropdown-menu';
import { blockNameToItemType, type ItemType } from '@service-storage/client';
+import { Button } from '@ui/components/Button';
+import { cn } from '@ui/utils/classname';
import {
type Component,
createMemo,
@@ -18,6 +19,7 @@ import {
Show,
useContext,
} from 'solid-js';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
import { SplitPanelContext } from '../context';
import { useSplitLayout } from '../layout';
import { useSplitModal } from './SplitModalContext';
@@ -50,6 +52,8 @@ export function SplitFileMenu(props: {
name: string;
formattedName?: string;
ops: Array<FileOperation>;
+ tools?: BlockTool[];
+ buttonClass?: string;
}) {
const ctx = useContext(SplitPanelContext);
if (!ctx)
@@ -160,16 +164,22 @@ export function SplitFileMenu(props: {
.filter((op) => !!op);
});
+ const filteredTools = createMemo(() =>
+ (props.tools ?? []).filter((t) => !t.condition || t.condition())
+ );
+
return (
<DropdownMenu open={open()} onOpenChange={setOpen} boundary={ctx.panelRef}>
<DropdownMenu.Trigger
- as={DeprecatedIconButton}
- theme={open() ? 'accent' : 'clear'}
- size="sm"
- icon={ThreeDots}
- onclick={() => setOpen((p) => !p)}
- onClick={() => setOpen((p) => !p)}
- />
+ as={Button}
+ class={cn(
+ 'px-1',
+ open() && 'bg-accent/20 hover:bg-accent/30 text-accent-ink',
+ props.buttonClass
+ )}
+ >
+ <ThreeDots class="size-4 shrink-0" />
+ </DropdownMenu.Trigger>
<DropdownMenu.Portal>
<DropdownMenu.Content class="bg-menu w-44 p-1 border border-edge mt-2">
<For each={ops()}>
@@ -182,6 +192,25 @@ export function SplitFileMenu(props: {
</>
)}
</For>
+ <Show when={filteredTools().length > 0 && ops().length > 0}>
+ <div class="my-1 h-[1px] bg-edge" />
+ </Show>
+ <For each={filteredTools()}>
+ {(tool, i) => (
+ <>
+ <Show when={tool.divideAbove && i() > 0}>
+ <div class="my-1 h-[1px] bg-edge" />
+ </Show>
+ <MenuItem
+ text={
+ typeof tool.label === 'function' ? tool.label() : tool.label
+ }
+ onClick={tool.action}
+ icon={tool.icon}
+ />
+ </>
+ )}
+ </For>
</DropdownMenu.Content>
</DropdownMenu.Portal>
</DropdownMenu>
diff --git a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
index 2f270e6776..529b8a763e 100644
--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
@@ -191,7 +191,7 @@ export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {
<SplitForwardButton />
</div>
<div
- class="relative min-w-0 h-full grow shrink pl-2"
+ class="relative min-w-0 h-full grow shrink pl-2 flex items-center gap-0.5"
ref={(ref) => {
ctx.layoutRefs.headerLeft = ref;
}}
diff --git a/js/app/packages/app/component/split-layout/components/SplitToolbar.tsx b/js/app/packages/app/component/split-layout/components/SplitToolbar.tsx
index 95c98f7052..072fb70014 100644
--- a/js/app/packages/app/component/split-layout/components/SplitToolbar.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitToolbar.tsx
@@ -47,7 +47,6 @@ export function SplitToolbar(props: { ref: Setter<HTMLDivElement | null> }) {
class={cn(
'relative w-full flex items-center justify-between shrink-0',
hasContent() && 'h-10 px-1 border-b border-edge-muted/50',
- !hasContent() && 'bg-[red]',
preview() && 'hidden'
)}
data-split-toolbar
diff --git a/js/app/packages/block-canvas/component/TopBar.tsx b/js/app/packages/block-canvas/component/TopBar.tsx
index 4d98cb409f..3894dfc666 100644
--- a/js/app/packages/block-canvas/component/TopBar.tsx
+++ b/js/app/packages/block-canvas/component/TopBar.tsx
@@ -1,25 +1,31 @@
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
import {
- type FileOperation,
- SplitFileMenu,
-} from '@app/component/split-layout/components/SplitFileMenu';
+ ResponsiveBlockToolbar,
+ ResponsivePermissionsBadge,
+} from '@app/component/ResponsiveBlockToolbar';
+import type { FileOperation } from '@app/component/split-layout/components/SplitFileMenu';
import {
SplitHeaderLeft,
SplitHeaderRight,
} from '@app/component/split-layout/components/SplitHeader';
-import {
- BlockItemSplitLabel,
- SplitPermissionsBadge,
-} from '@app/component/split-layout/components/SplitLabel';
-import {
- SplitToolbarLeft,
- SplitToolbarRight,
-} from '@app/component/split-layout/components/SplitToolbar';
+import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+
import { withAnalytics } from '@coparse/analytics';
import { createBlockSignal, useBlockId } from '@core/block';
-import { DocumentPropertiesButton } from '@core/component/DocumentPropertiesModal';
+import {
+ DocumentPropertiesButton,
+ PROPERTIES_DRAWER_ID,
+} from '@core/component/DocumentPropertiesModal';
import { BlockLiveIndicators } from '@core/component/LiveIndicators';
-import { ReferencesButton } from '@core/component/ReferencesModal';
-import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+import {
+ ReferencesButton,
+ REFERENCES_DRAWER_ID,
+} from '@core/component/ReferencesModal';
+import {
+ ShareTrigger,
+ useShareDialogContext,
+} from '@core/component/TopBar/ShareButton';
import { ENABLE_REFERENCES_MODAL } from '@core/constant/featureFlags';
import { blockFileSignal } from '@core/signal/load';
import {
@@ -29,9 +35,12 @@ import {
import { buildSimpleEntityUrl } from '@core/util/url';
import { downloadFile } from '@filesystem/download';
import DownloadSimple from '@icon/regular/download-simple.svg';
+import Quotes from '@icon/regular/quotes.svg';
+import IconShared from '@icon/regular/share.svg';
+import TagIcon from '@icon/regular/tag.svg';
import { createCallback } from '@solid-primitives/rootless';
import { toast } from 'core/component/Toast/Toast';
-import { onMount, Show } from 'solid-js';
+import { onMount } from 'solid-js';
import { URL_PARAMS } from '../constants';
import { useToolManager } from '../signal/toolManager';
import { currentSavedFile } from '../store/canvasData';
@@ -50,6 +59,10 @@ export function TopBar() {
const downloadName = useBlockDocumentDownloadName('Unknown Filename');
const canvasFile = blockFileSignal.get;
+ const referencesControl = useDrawerControl(REFERENCES_DRAWER_ID);
+ const propertiesControl = useDrawerControl(PROPERTIES_DRAWER_ID);
+ const shareCtx = useShareDialogContext();
+
let ref!: HTMLDivElement;
onMount(() => {
toolManager.ignoreMouseEvents(ref);
@@ -99,6 +112,36 @@ export function TopBar() {
{ op: 'delete', divideAbove: true },
];
+ const tools: BlockTool[] = [
+ {
+ label: 'References',
+ icon: Quotes,
+ action: referencesControl.toggle,
+ condition: () => ENABLE_REFERENCES_MODAL,
+ buttonComponent: () => (
+ <ReferencesButton
+ documentId={documentId}
+ documentName={fileName()}
+ buttonSize="sm"
+ />
+ ),
+ },
+ {
+ label: 'Properties',
+ icon: TagIcon,
+ action: propertiesControl.toggle,
+ buttonComponent: () => <DocumentPropertiesButton buttonSize="sm" />,
+ },
+ {
+ label: 'Share',
+ icon: IconShared,
+ action: () => shareCtx.open(),
+ divideAbove: true,
+ condition: () => !!canvasFile(),
+ buttonComponent: () => <ShareTrigger copyLink={copyLink} />,
+ },
+ ];
+
return (
<div ref={ref}>
<SplitHeaderLeft>
@@ -107,30 +150,14 @@ export function TopBar() {
<SplitHeaderRight>
<BlockLiveIndicators />
</SplitHeaderRight>
- <SplitToolbarLeft>
- <div class="p-1">
- <SplitFileMenu
- id={documentId}
- itemType="document"
- name={fileName()}
- ops={ops}
- />
- </div>
- </SplitToolbarLeft>
- <SplitToolbarRight>
- <Show when={ENABLE_REFERENCES_MODAL}>
- <ReferencesButton
- documentId={documentId}
- documentName={fileName()}
- buttonSize="sm"
- />
- </Show>
- <DocumentPropertiesButton buttonSize="sm" />
- <SplitPermissionsBadge />
- <Show when={canvasFile()} keyed>
- <ShareTrigger copyLink={copyLink} />
- </Show>
- </SplitToolbarRight>
+ <ResponsivePermissionsBadge />
+ <ResponsiveBlockToolbar
+ tools={tools}
+ ops={ops}
+ id={documentId}
+ itemType="document"
+ name={fileName()}
+ />
</div>
);
}
diff --git a/js/app/packages/block-channel/component/AttachmentsModal.tsx b/js/app/packages/block-channel/component/AttachmentsModal.tsx
index 4377efdb9e..5684bc2c42 100644
--- a/js/app/packages/block-channel/component/AttachmentsModal.tsx
+++ b/js/app/packages/block-channel/component/AttachmentsModal.tsx
@@ -23,15 +23,12 @@ import { useChannelContext } from '@block-channel/hooks/channel';
const DRAWER_ID = 'attachments';
-export function AttachmentsModal() {
- const drawerControl = useDrawerControl(DRAWER_ID);
+export function useAttachments() {
const currentBlockId = useBlockId();
- const { openWithSplit } = useSplitLayout();
const channelContext = useChannelContext();
-
const mentionsQuery = useMentionsQuery(() => currentBlockId);
- const attachments = createMemo(() => {
+ return createMemo(() => {
const mentions: Attachment[] = !mentionsQuery.isSuccess
? []
: (mentionsQuery.data?.mentions ?? []).map((m) =>
@@ -51,6 +48,31 @@ export function AttachmentsModal() {
new Date(a.created_at || 0).getTime()
);
});
+}
+
+export function AttachmentsButton(props: { attachments: () => Attachment[] }) {
+ const drawerControl = useDrawerControl(DRAWER_ID);
+
+ return (
+ <Tooltip tooltip={'View all attachments'}>
+ <div
+ class="flex items-center gap-1 py-1 font-mono text-xs text-ink-disabled hover:bg-hover relative"
+ tabIndex={0}
+ role="button"
+ onClick={drawerControl.toggle}
+ >
+ <BracketLeft class="h-4 w-2 text-edge" />
+ <PaperclipIcon class="size-4 text-ink" />
+ <span class="text-xs">{props.attachments().length}</span>
+ <BracketLeft class="h-4 w-2 rotate-180 text-edge" />
+ </div>
+ </Tooltip>
+ );
+}
+
+export function AttachmentsDrawer(props: { attachments: () => Attachment[] }) {
+ const { openWithSplit } = useSplitLayout();
+ const channelContext = useChannelContext();
const onClickAttachment = (
event: MouseEvent,
@@ -63,57 +85,41 @@ export function AttachmentsModal() {
};
return (
- <>
- <Tooltip tooltip={'View all attachments'}>
- <div
- class="flex items-center gap-1 py-1 font-mono text-xs text-ink-disabled hover:bg-hover relative"
- tabIndex={0}
- role="button"
- onClick={drawerControl.toggle}
- >
- <BracketLeft class="h-4 w-2 text-edge" />
- <PaperclipIcon class="size-4 text-ink" />
- <span class="text-xs">{attachments().length}</span>
- <BracketLeft class="h-4 w-2 rotate-180 text-edge" />
- </div>
- </Tooltip>
-
- <SplitDrawer
- id={DRAWER_ID}
- title="Channel Attachments"
- side="right"
- size={768}
- >
- <div class="flex justify-center items-center max-w-full h-full max-h-full">
- <div class="flex-1 size-full overflow-x-hidden overflow-y-auto">
- <Show
- when={attachments().length > 0}
- fallback={
- <div class="py-8 text-ink-muted text-sm text-center">
- No attachments in this channel
- </div>
- }
- >
- <div class="flex flex-col h-full">
- <VList data={attachments()}>
- {(attachment) => (
- <Suspense>
- <AttachmentItem
- attachment={attachment}
- onNavigate={onClickAttachment}
- senderId={channelContext
- .messageSenderMap()
- .get(attachment.message_id)}
- />
- </Suspense>
- )}
- </VList>
+ <SplitDrawer
+ id={DRAWER_ID}
+ title="Channel Attachments"
+ side="right"
+ size={768}
+ >
+ <div class="flex justify-center items-center max-w-full h-full max-h-full">
+ <div class="flex-1 size-full overflow-x-hidden overflow-y-auto">
+ <Show
+ when={props.attachments().length > 0}
+ fallback={
+ <div class="py-8 text-ink-muted text-sm text-center">
+ No attachments in this channel
</div>
- </Show>
- </div>
+ }
+ >
+ <div class="flex flex-col h-full">
+ <VList data={props.attachments()}>
+ {(attachment) => (
+ <Suspense>
+ <AttachmentItem
+ attachment={attachment}
+ onNavigate={onClickAttachment}
+ senderId={channelContext
+ .messageSenderMap()
+ .get(attachment.message_id)}
+ />
+ </Suspense>
+ )}
+ </VList>
+ </div>
+ </Show>
</div>
- </SplitDrawer>
- </>
+ </div>
+ </SplitDrawer>
);
}
diff --git a/js/app/packages/block-channel/component/Channel.tsx b/js/app/packages/block-channel/component/Channel.tsx
index 7349dad4f1..a703ec3812 100644
--- a/js/app/packages/block-channel/component/Channel.tsx
+++ b/js/app/packages/block-channel/component/Channel.tsx
@@ -52,6 +52,7 @@ import {
type TargetMessageInfo,
} from './MessageList/MessageList';
import { Top } from './Top';
+import { ModalsProvider } from './ModalsProvider';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import { useChannelContext } from '@block-channel/hooks/channel';
import { FloatingInputLoader } from '@core/component/FloatingInputLoader';
@@ -382,84 +383,86 @@ export function Channel(props: {
debounceTime={500}
/>
<StaticMarkdownContext>
- <Suspense>
- <Top
- channelId={props.channelId}
- channelType={channelContext.channelType()}
- participants={channelContext.channel()?.participants ?? []}
- channelName={channelContext.channelName()}
- />
- </Suspense>
- <div
- class="h-full flex flex-col min-h-0 flex-1 relative w-full"
- use:fileFolderDrop={{
- onDrop: (files, folders) => {
- handleFileFolderDrop(files, folders, (uploadEntries) =>
- handleFileUpload(uploadEntries, {
- store: channelInputAttachmentsStore,
- setStore: setChannelInputAttachmentsStore,
- key: props.channelId,
- })
- );
- },
- onDragStart: (valid) => {
- setIsDraggingOverChannel(true);
- setIsValidChannelDrag(valid);
- },
- onDragEnd: () => {
- setIsDraggingOverChannel(false);
- },
- }}
- >
+ <ModalsProvider>
+ <Suspense>
+ <Top
+ channelId={props.channelId}
+ channelType={channelContext.channelType()}
+ participants={channelContext.channel()?.participants ?? []}
+ channelName={channelContext.channelName()}
+ />
+ </Suspense>
<div
- class="absolute pointer-events-none top-1/2 left-1/2 w-[60%] h-full -translate-x-1/2 -translate-y-1/2"
- use:droppable
- ref={containerRef}
- />
- <FloatingInputLoader
- minShowTime={200}
- successDuration={100}
- isLoading={() => channelQuery.isFetching}
- loadingText="Refreshing messages"
- class="top-0 bottom-auto mt-2 mb-0 z-10"
- />
- <MessageList
- channelId={props.channelId}
- messages={channelContext.messages()}
- threads={channelContext.threads()}
- reactions={channelContext.reactions()}
- attachments={channelContext.attachments()}
- participants={channelContext.channel()?.participants ?? []}
- focusedMessageId={selectedMessageId}
- setFocusedMessageId={setSelectedMessageId}
- targetMessage={targetMessage}
- latestActivity={latestActivity()}
- openedChannel={openedChannel()}
- orderedMessages={orderedMessages}
- setOrderedMessages={setOrderedMessages}
- onNavigationReady={setMessageListNav}
- />
- <div class="shrink-0 w-full pb-2 @min-[40rem]:px-4">
- {/* seamus: note this element is below the scroll so we translate it back to account for the scroll above */}
- <div class="mx-auto w-full macro-message-width macro-message-padding">
- <Suspense>
- <ChannelInput
- channelId={props.channelId}
- channelName={channelContext.channelName()}
- participants={channelContext.channel()?.participants ?? []}
- inputAttachmentsStore={channelInputAttachmentsStore}
- setInputAttachmentsStore={setChannelInputAttachmentsStore}
- inputAttachmentsKey={props.channelId}
- onFocusLeaveStart={onChannelInputFocusLeaveStart}
- autoFocusOnMount={autoFocusOnMount()}
- domRef={setChannelInputRef}
- isDraggingOverChannel={isDraggingOverChannel}
- isValidChannelDrag={isValidChannelDrag}
- />
- </Suspense>
+ class="h-full flex flex-col min-h-0 flex-1 relative w-full"
+ use:fileFolderDrop={{
+ onDrop: (files, folders) => {
+ handleFileFolderDrop(files, folders, (uploadEntries) =>
+ handleFileUpload(uploadEntries, {
+ store: channelInputAttachmentsStore,
+ setStore: setChannelInputAttachmentsStore,
+ key: props.channelId,
+ })
+ );
+ },
+ onDragStart: (valid) => {
+ setIsDraggingOverChannel(true);
+ setIsValidChannelDrag(valid);
+ },
+ onDragEnd: () => {
+ setIsDraggingOverChannel(false);
+ },
+ }}
+ >
+ <div
+ class="absolute pointer-events-none top-1/2 left-1/2 w-[60%] h-full -translate-x-1/2 -translate-y-1/2"
+ use:droppable
+ ref={containerRef}
+ />
+ <FloatingInputLoader
+ minShowTime={200}
+ successDuration={100}
+ isLoading={() => channelQuery.isFetching}
+ loadingText="Refreshing messages"
+ class="top-0 bottom-auto mt-2 mb-0 z-10"
+ />
+ <MessageList
+ channelId={props.channelId}
+ messages={channelContext.messages()}
+ threads={channelContext.threads()}
+ reactions={channelContext.reactions()}
+ attachments={channelContext.attachments()}
+ participants={channelContext.channel()?.participants ?? []}
+ focusedMessageId={selectedMessageId}
+ setFocusedMessageId={setSelectedMessageId}
+ targetMessage={targetMessage}
+ latestActivity={latestActivity()}
+ openedChannel={openedChannel()}
+ orderedMessages={orderedMessages}
+ setOrderedMessages={setOrderedMessages}
+ onNavigationReady={setMessageListNav}
+ />
+ <div class="shrink-0 w-full pb-2 @min-[40rem]:px-4">
+ {/* seamus: note this element is below the scroll so we translate it back to account for the scroll above */}
+ <div class="mx-auto w-full macro-message-width macro-message-padding">
+ <Suspense>
+ <ChannelInput
+ channelId={props.channelId}
+ channelName={channelContext.channelName()}
+ participants={channelContext.channel()?.participants ?? []}
+ inputAttachmentsStore={channelInputAttachmentsStore}
+ setInputAttachmentsStore={setChannelInputAttachmentsStore}
+ inputAttachmentsKey={props.channelId}
+ onFocusLeaveStart={onChannelInputFocusLeaveStart}
+ autoFocusOnMount={autoFocusOnMount()}
+ domRef={setChannelInputRef}
+ isDraggingOverChannel={isDraggingOverChannel}
+ isValidChannelDrag={isValidChannelDrag}
+ />
+ </Suspense>
+ </div>
</div>
</div>
- </div>
+ </ModalsProvider>
</StaticMarkdownContext>
</div>
);
diff --git a/js/app/packages/block-channel/component/ModalsProvider.tsx b/js/app/packages/block-channel/component/ModalsProvider.tsx
new file mode 100644
index 0000000000..ee1dca718b
--- /dev/null
+++ b/js/app/packages/block-channel/component/ModalsProvider.tsx
@@ -0,0 +1,53 @@
+import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
+import { useBlockId } from '@core/block';
+import { NotificationsDrawer } from '@core/component/NotificationsModal';
+import { ChannelTypeEnum } from '@service-comms/client';
+import { createContext, createSignal, Show, useContext } from 'solid-js';
+import type { ParentProps } from 'solid-js';
+import { AttachmentsDrawer, useAttachments } from './AttachmentsModal';
+import type { Attachment } from '@queries/channel/types';
+import { ParticipantManagerDialog } from './ParticipantManager';
+import { useChannelContext } from '@block-channel/hooks/channel';
+
+type ChannelModalsContextValue = {
+ openParticipants: () => void;
+ attachments: () => Attachment[];
+};
+
+export const ChannelModalsContext = createContext<ChannelModalsContextValue>();
+
+export function useChannelModals() {
+ const ctx = useContext(ChannelModalsContext);
+ if (!ctx)
+ throw new Error('useChannelModals must be used within ModalsProvider');
+ return ctx;
+}
+
+export function ModalsProvider(props: ParentProps) {
+ const blockId = useBlockId();
+ const notificationSource = useGlobalNotificationSource();
+ const channelContext = useChannelContext();
+ const [participantsOpen, setParticipantsOpen] = createSignal(false);
+ const attachments = useAttachments();
+
+ return (
+ <ChannelModalsContext.Provider
+ value={{ openParticipants: () => setParticipantsOpen(true), attachments }}
+ >
+ {props.children}
+ <NotificationsDrawer
+ entity={{ id: blockId, type: 'channel' }}
+ notificationSource={notificationSource}
+ />
+ <AttachmentsDrawer attachments={attachments} />
+ <Show
+ when={channelContext.channelType() !== ChannelTypeEnum.DirectMessage}
+ >
+ <ParticipantManagerDialog
+ open={participantsOpen()}
+ onOpenChange={setParticipantsOpen}
+ />
+ </Show>
+ </ChannelModalsContext.Provider>
+ );
+}
diff --git a/js/app/packages/block-channel/component/ParticipantManager.tsx b/js/app/packages/block-channel/component/ParticipantManager.tsx
index f31b4cee2c..c5b6a2830c 100644
--- a/js/app/packages/block-channel/component/ParticipantManager.tsx
+++ b/js/app/packages/block-channel/component/ParticipantManager.tsx
@@ -2,6 +2,8 @@ import {
useAddParticipantsToChannel,
useRemoveParticipantsFromChannel,
} from '@block-channel/hooks/participants';
+import { useChannelContext } from '@block-channel/hooks/channel';
+import { useBlockId } from '@core/block';
import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';
import { DeprecatedTextButton } from '@core/component/DeprecatedTextButton';
import { DialogWrapper } from '@core/component/DialogWrapper';
@@ -26,25 +28,51 @@ import { createMemo, createSignal, Show } from 'solid-js';
import { VList } from 'virtua/solid';
import { UserItem } from './UserItem';
-type ParticipantManagerProps = {
- channelId: string;
- channelType?: string;
- participants: ChannelParticipant[];
- participantCount: number;
-};
+export function ParticipantManagerButton(props: { onClick: () => void }) {
+ const channelContext = useChannelContext();
+ const channelType = () => channelContext.channelType();
+ const canManageParticipants = () =>
+ channelType() !== ChannelType.organization;
+ const title = () =>
+ canManageParticipants() ? 'Manage Participants' : 'View Participants';
+ const participantCount = () =>
+ channelContext.channel()?.participants.length ?? 0;
+
+ return (
+ <Tooltip tooltip={title()}>
+ <div
+ class="flex items-center gap-1 py-1 font-mono text-xs text-ink-disabled hover:bg-hover relative"
+ tabIndex={0}
+ role="button"
+ onClick={props.onClick}
+ >
+ <BracketLeft class="h-4 w-2 text-edge" />
+ <UsersIcon class="size-4 text-ink" />
+ <span class="text-xs">{participantCount().toString()}</span>
+ <BracketLeft class="h-4 w-2 rotate-180 text-edge" />
+ </div>
+ </Tooltip>
+ );
+}
-export function ParticipantManager(props: ParticipantManagerProps) {
- const channelType = () => props.channelType ?? 'private';
+export function ParticipantManagerDialog(props: {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+}) {
+ const blockId = useBlockId();
+ const channelContext = useChannelContext();
const users = useContacts();
const userId = useUserId();
+
+ const channelType = () => channelContext.channelType() ?? 'private';
+ const participants = () => channelContext.channel()?.participants ?? [];
+
const [usersToInvite, setUsersToInvite] = createSignal<
WithCustomUserInput<'user'>[]
>([]);
const canManageParticipants = () =>
channelType() !== ChannelType.organization;
- const addParticipantsToChannel = useAddParticipantsToChannel(
- () => props.channelId
- );
+ const addParticipantsToChannel = useAddParticipantsToChannel(() => blockId);
function handleAddParticipants() {
const destination = getDestinationFromOptions(usersToInvite());
@@ -53,37 +81,20 @@ export function ParticipantManager(props: ParticipantManagerProps) {
setUsersToInvite([]);
}
- const editable = () => canManageParticipants();
-
const title = () =>
canManageParticipants() ? 'Manage Participants' : 'View Participants';
const options = () =>
users()
?.filter((user) => {
- return !props.participants.find(
+ return !participants().find(
(participant) => participant.user_id === user.id
);
})
.map(recipientEntityMapper('user')) ?? [];
return (
- <Dialog>
- <Dialog.Trigger>
- <Tooltip tooltip={title()}>
- <div
- class="flex items-center gap-1 py-1 font-mono text-xs text-ink-disabled hover:bg-hover relative"
- tabIndex={0}
- role="button"
- >
- <BracketLeft class="h-4 w-2 text-edge" />
- <UsersIcon class="size-4 text-ink" />
- <span class="text-xs">{props.participantCount.toString()}</span>
- <BracketLeft class="h-4 w-2 rotate-180 text-edge" />
- </div>
- </Tooltip>
- </Dialog.Trigger>
-
+ <Dialog open={props.open} onOpenChange={props.onOpenChange}>
<Dialog.Portal>
<DialogWrapper>
<div class="flex flex-row items-center px-2 h-[40px] gap-2 border-b-1 border-b-edge-muted">
@@ -130,9 +141,9 @@ export function ParticipantManager(props: ParticipantManagerProps) {
<div class="flex flex-col">
<ParticipantList
- channelId={props.channelId}
- editable={editable()}
- participants={props.participants}
+ channelId={blockId}
+ editable={canManageParticipants()}
+ participants={participants()}
userId={userId()!}
/>
</div>
diff --git a/js/app/packages/block-channel/component/Top.tsx b/js/app/packages/block-channel/component/Top.tsx
index 6d20f29cf7..bde6db866f 100644
--- a/js/app/packages/block-channel/component/Top.tsx
+++ b/js/app/packages/block-channel/component/Top.tsx
@@ -1,29 +1,37 @@
import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
+import { ResponsiveBlockToolbar } from '@app/component/ResponsiveBlockToolbar';
import {
SplitHeaderLeft,
SplitHeaderRight,
} from '@app/component/split-layout/components/SplitHeader';
import { SplitLabel } from '@app/component/split-layout/components/SplitLabel';
-import { SplitToolbarRight } from '@app/component/split-layout/components/SplitToolbar';
import { useBlockId } from '@core/block';
import { useChannelName } from '@core/context/channels';
-import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';
import { BlockLiveIndicators } from '@core/component/LiveIndicators';
-import { NotificationsModal } from '@core/component/NotificationsModal';
+import {
+ NotificationsButton,
+ NOTIFICATIONS_DRAWER_ID,
+} from '@core/component/NotificationsModal';
import { toast } from '@core/component/Toast/Toast';
import { UserIcon } from '@core/component/UserIcon';
import { buildSimpleEntityUrl } from '@core/util/url';
+import Bell from '@icon/regular/bell.svg';
import HashIcon from '@icon/regular/hash.svg';
import LinkIcon from '@icon/regular/link.svg';
+import PaperclipIcon from '@phosphor-icons/core/regular/paperclip.svg?component-solid';
+import UsersIcon from '@icon/regular/users.svg';
import type { ChannelParticipant } from '@queries/channel/types';
import type { ChannelType } from '@service-comms/generated/models/channelType';
import { ChannelTypeEnum } from '@service-comms/client';
import { useUserId } from '@core/context/user';
import { createMemo, Show } from 'solid-js';
-import { AttachmentsModal } from './AttachmentsModal';
-import { ParticipantManager } from './ParticipantManager';
+import { AttachmentsButton } from './AttachmentsModal';
import { useChannelContext } from '@block-channel/hooks/channel';
import { isChannelAdminOrOwner } from '@queries/channel/derived';
+import { useChannelModals } from './ModalsProvider';
+import { ParticipantManagerButton } from './ParticipantManager';
type TopIconProps = {
channelType: ChannelType;
@@ -58,11 +66,14 @@ type TopProps = {
};
export function Top(props: TopProps) {
- const participantCount = () => props.participants.length;
const blockId = useBlockId();
const notificationSource = useGlobalNotificationSource();
const channelContext = useChannelContext();
+ const notificationsControl = useDrawerControl(NOTIFICATIONS_DRAWER_ID);
+ const attachmentsControl = useDrawerControl('attachments');
+ const channelModals = useChannelModals();
+
const isAdminOrOwner = createMemo(() => {
const channelData = channelContext.channel();
return isChannelAdminOrOwner(channelData);
@@ -85,6 +96,44 @@ export function Top(props: TopProps) {
props.channelName ?? 'New Channel'
);
+ const tools: BlockTool[] = [
+ {
+ label: 'Copy Link',
+ icon: LinkIcon,
+ action: handleCopyLink,
+ condition: () => props.channelType === ChannelTypeEnum.Public,
+ },
+ {
+ label: 'Notifications',
+ icon: Bell,
+ action: notificationsControl.toggle,
+ buttonComponent: () => (
+ <NotificationsButton
+ entity={{ id: blockId, type: 'channel' }}
+ notificationSource={notificationSource}
+ buttonSize="sm"
+ />
+ ),
+ },
+ {
+ label: 'Attachments',
+ icon: PaperclipIcon,
+ action: attachmentsControl.toggle,
+ buttonComponent: () => (
+ <AttachmentsButton attachments={channelModals.attachments} />
+ ),
+ },
+ {
+ label: 'Participants',
+ icon: UsersIcon,
+ action: () => channelModals.openParticipants(),
+ condition: () => props.channelType !== ChannelTypeEnum.DirectMessage,
+ buttonComponent: () => (
+ <ParticipantManagerButton onClick={channelModals.openParticipants} />
+ ),
+ },
+ ];
+
return (
<>
<SplitHeaderLeft>
@@ -106,34 +155,18 @@ export function Top(props: TopProps) {
</div>
</div>
</SplitHeaderLeft>
+
<SplitHeaderRight>
<BlockLiveIndicators />
</SplitHeaderRight>
- <SplitToolbarRight>
- <Show when={props.channelType === ChannelTypeEnum.Public}>
- <DeprecatedIconButton
- theme="clear"
- size="sm"
- tooltip={{ label: 'Copy Link to Public Channel' }}
- icon={LinkIcon}
- onClick={handleCopyLink}
- />
- </Show>
- <NotificationsModal
- entity={{ id: blockId, type: 'channel' }}
- notificationSource={notificationSource}
- buttonSize="sm"
- />
- <AttachmentsModal />
- <Show when={props.channelType !== ChannelTypeEnum.DirectMessage}>
- <ParticipantManager
- channelId={props.channelId}
- channelType={props.channelType}
- participants={props.participants}
- participantCount={participantCount()}
- />
- </Show>
- </SplitToolbarRight>
+
+ <ResponsiveBlockToolbar
+ tools={tools}
+ ops={[]}
+ id={blockId}
+ itemType="channel"
+ name={channelName() ?? 'New Channel'}
+ />
</>
);
}
diff --git a/js/app/packages/block-chat/component/TopBar.tsx b/js/app/packages/block-chat/component/TopBar.tsx
index c8dcbf5e75..c14fc0ae61 100644
--- a/js/app/packages/block-chat/component/TopBar.tsx
+++ b/js/app/packages/block-chat/component/TopBar.tsx
@@ -1,23 +1,27 @@
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
import {
- type FileOperation,
- SplitFileMenu,
-} from '@app/component/split-layout/components/SplitFileMenu';
+ ResponsiveBlockToolbar,
+ ResponsivePermissionsBadge,
+} from '@app/component/ResponsiveBlockToolbar';
+import type { FileOperation } from '@app/component/split-layout/components/SplitFileMenu';
import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
-import {
- BlockItemSplitLabel,
- SplitPermissionsBadge,
-} from '@app/component/split-layout/components/SplitLabel';
-import {
- SplitToolbarLeft,
- SplitToolbarRight,
-} from '@app/component/split-layout/components/SplitToolbar';
+import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+
import { DEFAULT_CHAT_NAME } from '@block-chat/definition';
import { useBlockId } from '@core/block';
-import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';
-import { ReferencesButton } from '@core/component/ReferencesModal';
-import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+import {
+ ReferencesButton,
+ REFERENCES_DRAWER_ID,
+} from '@core/component/ReferencesModal';
+import {
+ ShareTrigger,
+ useShareDialogContext,
+} from '@core/component/TopBar/ShareButton';
import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';
import Notepad from '@icon/regular/notepad.svg';
+import Quotes from '@icon/regular/quotes.svg';
+import IconShared from '@icon/regular/share.svg';
import { useOpenInstructionsMd } from 'core/component/AI/util/instructions';
export function TopBar() {
@@ -28,6 +32,9 @@ export function TopBar() {
const openInstructions = useOpenInstructionsMd();
+ const referencesControl = useDrawerControl(REFERENCES_DRAWER_ID);
+ const shareCtx = useShareDialogContext();
+
const ops: FileOperation[] = [
{ op: 'rename' },
{ op: 'copy' },
@@ -35,6 +42,34 @@ export function TopBar() {
{ op: 'delete', divideAbove: true },
];
+ const tools: BlockTool[] = [
+ {
+ label: 'Edit AI Instructions',
+ icon: Notepad,
+ action: openInstructions,
+ },
+ {
+ label: 'References',
+ icon: Quotes,
+ action: referencesControl.toggle,
+ buttonComponent: () => (
+ <ReferencesButton
+ documentId={blockId}
+ documentName={chatName()}
+ buttonSize="sm"
+ entityType="chat"
+ />
+ ),
+ },
+ {
+ label: 'Share',
+ icon: IconShared,
+ action: () => shareCtx.open(),
+ divideAbove: true,
+ buttonComponent: () => <ShareTrigger />,
+ },
+ ];
+
return (
<>
<SplitHeaderLeft>
@@ -43,35 +78,14 @@ export function TopBar() {
lockRename={false}
/>
</SplitHeaderLeft>
- <SplitToolbarLeft>
- <div class="p-1">
- <SplitFileMenu
- id={blockId}
- itemType="chat"
- name={chatName()}
- ops={ops}
- />
- </div>
- </SplitToolbarLeft>
- <SplitToolbarRight>
- <DeprecatedIconButton
- icon={Notepad}
- size="sm"
- theme="clear"
- tooltip={{ label: 'Edit AI Instructions' }}
- onClick={openInstructions}
- />
- <ReferencesButton
- documentId={blockId}
- documentName={chatName()}
- buttonSize="sm"
- entityType="chat"
- />
- <div class="flex items-center">
- <SplitPermissionsBadge />
- <ShareTrigger />
- </div>
- </SplitToolbarRight>
+ <ResponsivePermissionsBadge />
+ <ResponsiveBlockToolbar
+ tools={tools}
+ ops={ops}
+ id={blockId}
+ itemType="chat"
+ name={chatName()}
+ />
</>
);
}
diff --git a/js/app/packages/block-code/component/TopBar.tsx b/js/app/packages/block-code/component/TopBar.tsx
index 1e8a5e05f0..7d4a4d2b3d 100644
--- a/js/app/packages/block-code/component/TopBar.tsx
+++ b/js/app/packages/block-code/component/TopBar.tsx
@@ -1,21 +1,27 @@
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
import {
- type FileOperation,
- SplitFileMenu,
-} from '@app/component/split-layout/components/SplitFileMenu';
+ ResponsiveBlockToolbar,
+ ResponsivePermissionsBadge,
+} from '@app/component/ResponsiveBlockToolbar';
+import type { FileOperation } from '@app/component/split-layout/components/SplitFileMenu';
import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
-import {
- BlockItemSplitLabel,
- SplitPermissionsBadge,
-} from '@app/component/split-layout/components/SplitLabel';
-import {
- SplitToolbarLeft,
- SplitToolbarRight,
-} from '@app/component/split-layout/components/SplitToolbar';
+import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+
import { withAnalytics } from '@coparse/analytics';
import { useBlockId } from '@core/block';
-import { DocumentPropertiesButton } from '@core/component/DocumentPropertiesModal';
-import { ReferencesButton } from '@core/component/ReferencesModal';
-import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+import {
+ DocumentPropertiesButton,
+ PROPERTIES_DRAWER_ID,
+} from '@core/component/DocumentPropertiesModal';
+import {
+ ReferencesButton,
+ REFERENCES_DRAWER_ID,
+} from '@core/component/ReferencesModal';
+import {
+ ShareTrigger,
+ useShareDialogContext,
+} from '@core/component/TopBar/ShareButton';
import { blockTextSignal } from '@core/signal/load';
import {
useBlockDocumentDownloadName,
@@ -23,6 +29,9 @@ import {
} from '@core/util/currentBlockDocumentName';
import { downloadFile } from '@filesystem/download';
import Download from '@icon/regular/download-simple.svg';
+import Quotes from '@icon/regular/quotes.svg';
+import IconShared from '@icon/regular/share.svg';
+import TagIcon from '@icon/regular/tag.svg';
import { createCallback } from '@solid-primitives/rootless';
import type { Component } from 'solid-js';
@@ -34,6 +43,10 @@ export const TopBar: Component = () => {
const name = useBlockDocumentName();
const downloadName = useBlockDocumentDownloadName();
+ const referencesControl = useDrawerControl(REFERENCES_DRAWER_ID);
+ const propertiesControl = useDrawerControl(PROPERTIES_DRAWER_ID);
+ const shareCtx = useShareDialogContext();
+
const downloadDocument = createCallback(() => {
const content = text();
if (!text || !name) return;
@@ -55,33 +68,49 @@ export const TopBar: Component = () => {
{ op: 'delete', divideAbove: true },
];
- return (
- <>
- <SplitHeaderLeft>
- <BlockItemSplitLabel />
- </SplitHeaderLeft>
- <SplitToolbarLeft>
- <div class="p-1">
- <SplitFileMenu
- id={blockId}
- itemType="document"
- name={name()}
- ops={ops}
- />
- </div>
- </SplitToolbarLeft>
- <SplitToolbarRight>
+ const tools: BlockTool[] = [
+ {
+ label: 'References',
+ icon: Quotes,
+ action: referencesControl.toggle,
+ buttonComponent: () => (
<ReferencesButton
documentId={blockId}
documentName={name()}
buttonSize="sm"
/>
- <DocumentPropertiesButton buttonSize="sm" />
- <div class="flex items-center">
- <SplitPermissionsBadge />
- <ShareTrigger />
- </div>
- </SplitToolbarRight>
+ ),
+ },
+ {
+ label: 'Properties',
+ icon: TagIcon,
+ action: propertiesControl.toggle,
+ buttonComponent: () => <DocumentPropertiesButton buttonSize="sm" />,
+ },
+ {
+ label: 'Share',
+ icon: IconShared,
+ action: () => shareCtx.open(),
+ divideAbove: true,
+ buttonComponent: () => <ShareTrigger />,
+ },
+ ];
+
+ return (
+ <>
+ <SplitHeaderLeft>
+ <BlockItemSplitLabel />
+ </SplitHeaderLeft>
+
+ <ResponsivePermissionsBadge />
+
+ <ResponsiveBlockToolbar
+ tools={tools}
+ ops={ops}
+ id={blockId}
+ itemType="document"
+ name={name()}
+ />
</>
);
};
diff --git a/js/app/packages/block-email/component/EmailPropertiesModal.tsx b/js/app/packages/block-email/component/EmailPropertiesModal.tsx
index 6a527a98f8..ac9dda9c4f 100644
--- a/js/app/packages/block-email/component/EmailPropertiesModal.tsx
+++ b/js/app/packages/block-email/component/EmailPropertiesModal.tsx
@@ -6,7 +6,8 @@ import TagIcon from '@icon/regular/tag.svg';
import { EntityType } from '@service-properties/generated/schemas/entityType';
import { Suspense } from 'solid-js';
-const DRAWER_ID = 'properties';
+export const PROPERTIES_DRAWER_ID = 'properties';
+const DRAWER_ID = PROPERTIES_DRAWER_ID;
export function EmailPropertiesButton(props: { buttonSize?: 'sm' | 'base' }) {
const drawerControl = useDrawerControl(DRAWER_ID);
diff --git a/js/app/packages/block-email/component/TopBar.tsx b/js/app/packages/block-email/component/TopBar.tsx
index bd4ead6e40..c470b04b56 100644
--- a/js/app/packages/block-email/component/TopBar.tsx
+++ b/js/app/packages/block-email/component/TopBar.tsx
@@ -1,19 +1,48 @@
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
+import { ResponsiveBlockToolbar } from '@app/component/ResponsiveBlockToolbar';
import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
import {
SplitHeaderBadge,
StaticSplitLabel,
} from '@app/component/split-layout/components/SplitLabel';
-import { SplitToolbarRight } from '@app/component/split-layout/components/SplitToolbar';
-import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+import {
+ ShareTrigger,
+ useShareDialogContext,
+} from '@core/component/TopBar/ShareButton';
import { ENABLE_EMAIL_SHARING } from '@core/constant/featureFlags';
-import { Show } from 'solid-js';
-import { EmailPropertiesButton } from './EmailPropertiesModal';
+import IconShared from '@icon/regular/share.svg';
+import TagIcon from '@icon/regular/tag.svg';
+import {
+ EmailPropertiesButton,
+ PROPERTIES_DRAWER_ID,
+} from './EmailPropertiesModal';
export function TopBar(props: {
id: string;
title: string;
isDraft?: boolean;
}) {
+ const propertiesControl = useDrawerControl(PROPERTIES_DRAWER_ID);
+ const shareCtx = useShareDialogContext();
+
+ const tools: BlockTool[] = [
+ {
+ label: 'Properties',
+ icon: TagIcon,
+ action: propertiesControl.toggle,
+ buttonComponent: () => <EmailPropertiesButton buttonSize="sm" />,
+ },
+ {
+ label: 'Share',
+ icon: IconShared,
+ action: () => shareCtx.open(),
+ divideAbove: true,
+ condition: () => ENABLE_EMAIL_SHARING,
+ buttonComponent: () => <ShareTrigger />,
+ },
+ ];
+
return (
<>
<SplitHeaderLeft>
@@ -33,12 +62,13 @@ export function TopBar(props: {
/>
</SplitHeaderLeft>
- <SplitToolbarRight>
- <EmailPropertiesButton buttonSize="sm" />
- <Show when={ENABLE_EMAIL_SHARING}>
- <ShareTrigger />
- </Show>
- </SplitToolbarRight>
+ <ResponsiveBlockToolbar
+ tools={tools}
+ ops={[]}
+ id={props.id}
+ itemType="email"
+ name={props.title}
+ />
</>
);
}
diff --git a/js/app/packages/block-image/component/TopBar.tsx b/js/app/packages/block-image/component/TopBar.tsx
index b88c0f3691..58dde002d4 100644
--- a/js/app/packages/block-image/component/TopBar.tsx
+++ b/js/app/packages/block-image/component/TopBar.tsx
@@ -1,19 +1,22 @@
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
import {
- type FileOperation,
- SplitFileMenu,
-} from '@app/component/split-layout/components/SplitFileMenu';
+ ResponsiveBlockToolbar,
+ ResponsivePermissionsBadge,
+} from '@app/component/ResponsiveBlockToolbar';
+import type { FileOperation } from '@app/component/split-layout/components/SplitFileMenu';
import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
+import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+
+import { useBlockId } from '@core/block';
import {
- BlockItemSplitLabel,
- SplitPermissionsBadge,
-} from '@app/component/split-layout/components/SplitLabel';
+ ReferencesButton,
+ REFERENCES_DRAWER_ID,
+} from '@core/component/ReferencesModal';
import {
- SplitToolbarLeft,
- SplitToolbarRight,
-} from '@app/component/split-layout/components/SplitToolbar';
-import { useBlockId } from '@core/block';
-import { ReferencesButton } from '@core/component/ReferencesModal';
-import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+ ShareTrigger,
+ useShareDialogContext,
+} from '@core/component/TopBar/ShareButton';
import { blockFileSignal } from '@core/signal/load';
import {
useBlockDocumentDownloadName,
@@ -21,6 +24,8 @@ import {
} from '@core/util/currentBlockDocumentName';
import { downloadFile } from '@filesystem/download';
import Download from '@icon/regular/download.svg';
+import Quotes from '@icon/regular/quotes.svg';
+import IconShared from '@icon/regular/share.svg';
import { createCallback } from '@solid-primitives/rootless';
export function TopBar() {
@@ -29,6 +34,9 @@ export function TopBar() {
const name = useBlockDocumentName();
const downloadName = useBlockDocumentDownloadName();
+ const referencesControl = useDrawerControl(REFERENCES_DRAWER_ID);
+ const shareCtx = useShareDialogContext();
+
const downloadDocument = createCallback(async () => {
const file = imageFile();
if (!file) return;
@@ -48,32 +56,43 @@ export function TopBar() {
{ op: 'delete', divideAbove: true },
];
- return (
- <>
- <SplitHeaderLeft>
- <BlockItemSplitLabel />
- </SplitHeaderLeft>
- <SplitToolbarLeft>
- <div class="p-1">
- <SplitFileMenu
- id={blockId}
- itemType="document"
- name={name()}
- ops={ops}
- />
- </div>
- </SplitToolbarLeft>
- <SplitToolbarRight>
+ const tools: BlockTool[] = [
+ {
+ label: 'References',
+ icon: Quotes,
+ action: referencesControl.toggle,
+ buttonComponent: () => (
<ReferencesButton
documentId={blockId}
documentName={name()}
buttonSize="sm"
/>
- <div class="flex items-center">
- <SplitPermissionsBadge />
- <ShareTrigger />
- </div>
- </SplitToolbarRight>
+ ),
+ },
+ {
+ label: 'Share',
+ icon: IconShared,
+ action: () => shareCtx.open(),
+ divideAbove: true,
+ buttonComponent: () => <ShareTrigger />,
+ },
+ ];
+
+ return (
+ <>
+ <SplitHeaderLeft>
+ <BlockItemSplitLabel />
+ </SplitHeaderLeft>
+
+ <ResponsivePermissionsBadge />
+
+ <ResponsiveBlockToolbar
+ tools={tools}
+ ops={ops}
+ id={blockId}
+ itemType="document"
+ name={name()}
+ />
</>
);
}
diff --git a/js/app/packages/block-md/component/History.tsx b/js/app/packages/block-md/component/History.tsx
index f1b6dc6b88..e146ef0b5b 100644
--- a/js/app/packages/block-md/component/History.tsx
+++ b/js/app/packages/block-md/component/History.tsx
@@ -51,7 +51,7 @@ import {
} from 'solid-js';
import { type VirtualizerHandle, VList } from 'virtua/solid';
-const DRAWER_ID = 'history';
+export const HISTORY_DRAWER_ID = 'history';
async function forkDocumentAtVersion(
documentId: string,
@@ -91,7 +91,7 @@ async function getLoroDocFromId(documentId: string) {
}
export function HistoryButton(props: { buttonSize?: 'sm' | 'base' }) {
- const drawerControl = useDrawerControl(DRAWER_ID);
+ const drawerControl = useDrawerControl(HISTORY_DRAWER_ID);
return (
<DeprecatedIconButton
tooltip={{ label: 'History' }}
@@ -104,9 +104,9 @@ export function HistoryButton(props: { buttonSize?: 'sm' | 'base' }) {
}
export function HistoryDrawer(props: { documentId: string }) {
- const drawerControl = useDrawerControl(DRAWER_ID);
+ const drawerControl = useDrawerControl(HISTORY_DRAWER_ID);
return (
- <SplitDrawer id={DRAWER_ID} side="right" size={768} title="History">
+ <SplitDrawer id={HISTORY_DRAWER_ID} side="right" size={768} title="History">
<Suspense fallback={'loading...'}>
<History
documentId={props.documentId}
@@ -119,7 +119,7 @@ export function HistoryDrawer(props: { documentId: string }) {
}
export function HistoryModal(props: { documentId: string }) {
- const drawerControl = useDrawerControl(DRAWER_ID);
+ const drawerControl = useDrawerControl(HISTORY_DRAWER_ID);
return (
<>
@@ -130,7 +130,12 @@ export function HistoryModal(props: { documentId: string }) {
size="sm"
onClick={drawerControl.toggle}
/>
- <SplitDrawer id={DRAWER_ID} side="right" size={768} title="History">
+ <SplitDrawer
+ id={HISTORY_DRAWER_ID}
+ side="right"
+ size={768}
+ title="History"
+ >
<Suspense fallback={'loading...'}>
<History
documentId={props.documentId}
diff --git a/js/app/packages/block-md/component/TopBar.tsx b/js/app/packages/block-md/component/TopBar.tsx
index 6fc0a6a811..5cca17f505 100644
--- a/js/app/packages/block-md/component/TopBar.tsx
+++ b/js/app/packages/block-md/component/TopBar.tsx
@@ -1,46 +1,60 @@
import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import {
- type FileOperation,
- SplitFileMenu,
-} from '@app/component/split-layout/components/SplitFileMenu';
+ type BlockTool,
+ ToolButton,
+} from '@app/component/ResponsiveBlockToolbar';
+import {
+ ResponsiveBlockToolbar,
+ ResponsivePermissionsBadge,
+} from '@app/component/ResponsiveBlockToolbar';
+import type { FileOperation } from '@app/component/split-layout/components/SplitFileMenu';
import {
SplitHeaderLeft,
SplitHeaderRight,
} from '@app/component/split-layout/components/SplitHeader';
import {
BlockItemSplitLabel,
- SplitPermissionsBadge,
StaticSplitLabel,
} from '@app/component/split-layout/components/SplitLabel';
-import {
- SplitToolbarLeft,
- SplitToolbarRight,
-} from '@app/component/split-layout/components/SplitToolbar';
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
import {
setShowCommentsPreference,
showCommentsPreference,
} from '@block-md/comments/commentStore';
import { useDownloadDocumentAsMarkdownText } from '@block-md/signal/save';
-import { useBlockId, useBlockName } from '@core/block';
-import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';
+import { useBlockAliasedName, useBlockId, useBlockName } from '@core/block';
import { BlockLiveIndicators } from '@core/component/LiveIndicators';
import { NotificationsButton } from '@core/component/NotificationsModal';
+import { NOTIFICATIONS_DRAWER_ID } from '@core/component/NotificationsModal';
import { ReferencesButton } from '@core/component/ReferencesModal';
-import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+import { REFERENCES_DRAWER_ID } from '@core/component/ReferencesModal';
+import {
+ ShareTrigger,
+ useShareDialogContext,
+} from '@core/component/TopBar/ShareButton';
import {
ENABLE_HISTORY_COMPONENT,
ENABLE_MARKDOWN_LIVE_COLLABORATION,
} from '@core/constant/featureFlags';
+import { isMobile } from '@core/mobile/isMobile';
import { useCanEdit } from '@core/signal/permissions';
+import { toast } from '@core/component/Toast/Toast';
import type { EntityType } from '@core/types';
import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';
+import { buildSimpleEntityUrl } from '@core/util/url';
import ShowComments from '@icon/regular/chat-circle-dots.svg';
import HideComments from '@icon/regular/chat-circle-slash.svg';
import Download from '@icon/regular/download.svg';
+import Bell from '@icon/regular/bell.svg';
+import Quotes from '@icon/regular/quotes.svg';
+import IconShared from '@icon/regular/share.svg';
+import IconLink from '@icon/regular/link.svg';
+import ClockIcon from '@icon/regular/clock-counter-clockwise.svg';
+import TagIcon from '@icon/regular/tag.svg';
import { blockNameToItemType } from '@service-storage/client';
-import { Show } from 'solid-js';
-import { HistoryButton } from './History';
-import { MarkdownPropertiesButton } from './MarkdownPropertiesModal';
+import { For, Show, type JSX } from 'solid-js';
+import { HISTORY_DRAWER_ID } from './History';
+import { DRAWER_ID as PROPERTIES_DRAWER_ID } from './MarkdownPropertiesModal';
export function TopBar() {
const canEdit = useCanEdit();
@@ -54,6 +68,25 @@ export function TopBar() {
const downloadAsMarkdownText = useDownloadDocumentAsMarkdownText();
+ const historyControl = useDrawerControl(HISTORY_DRAWER_ID);
+ const notificationsControl = useDrawerControl(NOTIFICATIONS_DRAWER_ID);
+ const referencesControl = useDrawerControl(REFERENCES_DRAWER_ID);
+ const propertiesControl = useDrawerControl(PROPERTIES_DRAWER_ID);
+ const shareCtx = useShareDialogContext();
+ const blockAliasedName = useBlockAliasedName();
+
+ const copyLink = () => {
+ const url = buildSimpleEntityUrl(
+ { id: blockId, type: blockAliasedName },
+ {}
+ );
+ navigator.clipboard.writeText(url);
+ toast.success(
+ 'Link copied to clipboard.',
+ 'Sending this link in a Macro message will automatically update permissions to include recipients.'
+ );
+ };
+
const ops: FileOperation[] = [
{ op: 'copy' },
{ op: 'rename' },
@@ -67,79 +100,130 @@ export function TopBar() {
{ op: 'delete', divideAbove: true },
];
- return (
- <>
- <SplitHeaderLeft>
- <BlockItemSplitLabel />
- </SplitHeaderLeft>
- <SplitHeaderRight>
- <BlockLiveIndicators />
- </SplitHeaderRight>
- <SplitToolbarLeft>
- <SplitFileMenu
- id={blockId}
- itemType={itemType}
- name={name()}
- ops={ops}
- />
- </SplitToolbarLeft>
- <SplitToolbarRight>
- <Show
- when={
- ENABLE_MARKDOWN_LIVE_COLLABORATION &&
- ENABLE_HISTORY_COMPONENT &&
- canEdit()
- }
- >
- <HistoryButton buttonSize="sm" />
- </Show>
+ const tools: BlockTool[] = [
+ {
+ label: 'History',
+ icon: ClockIcon,
+ action: historyControl.toggle,
+ isActive: historyControl.isOpen,
+ condition: () =>
+ ENABLE_MARKDOWN_LIVE_COLLABORATION &&
+ ENABLE_HISTORY_COMPONENT &&
+ canEdit(),
+ },
+ {
+ label: 'Notifications',
+ icon: Bell,
+ action: notificationsControl.toggle,
+ buttonComponent: () => (
<NotificationsButton
entity={{ id: blockId, type: itemType as EntityType }}
notificationSource={notificationSource}
buttonSize="sm"
/>
+ ),
+ },
+ {
+ label: 'References',
+ icon: Quotes,
+ action: referencesControl.toggle,
+ buttonComponent: () => (
<ReferencesButton
documentId={blockId}
documentName={name()}
buttonSize="sm"
/>
- <DeprecatedIconButton
- size="sm"
- icon={showCommentsPreference() ? HideComments : ShowComments}
- theme="clear"
- onClick={() => setShowCommentsPreference(!showCommentsPreference())}
- tooltip={{
- label: `${showCommentsPreference() ? 'Hide' : 'Show'} Comments`,
- }}
- />
- <MarkdownPropertiesButton buttonSize="sm" />
- <div class="flex items-center">
- <SplitPermissionsBadge />
- <ShareTrigger />
- </div>
- </SplitToolbarRight>
+ ),
+ },
+ {
+ label: () =>
+ showCommentsPreference() ? 'Hide Comments' : 'Show Comments',
+ icon: (props: JSX.SvgSVGAttributes<SVGSVGElement>) => (
+ <Show
+ when={showCommentsPreference()}
+ fallback={<ShowComments {...props} />}
+ >
+ <HideComments {...props} />
+ </Show>
+ ),
+ action: () => setShowCommentsPreference(!showCommentsPreference()),
+ },
+ {
+ label: 'Properties',
+ icon: TagIcon,
+ action: propertiesControl.toggle,
+ isActive: propertiesControl.isOpen,
+ },
+ {
+ label: 'Share',
+ icon: IconShared,
+ action: () => shareCtx.open(),
+ divideAbove: true,
+ buttonComponent: () => <ShareTrigger />,
+ },
+ {
+ label: 'Copy Link',
+ icon: IconLink,
+ action: copyLink,
+ condition: isMobile,
+ },
+ ];
+
+ return (
+ <>
+ <SplitHeaderLeft>
+ <BlockItemSplitLabel />
+ </SplitHeaderLeft>
+
+ <SplitHeaderRight>
+ <BlockLiveIndicators />
+ </SplitHeaderRight>
+ <ResponsivePermissionsBadge />
+
+ <ResponsiveBlockToolbar
+ tools={tools}
+ ops={ops}
+ id={blockId}
+ itemType={itemType}
+ name={name()}
+ />
</>
);
}
export function InstructionsTopBar() {
const canEdit = useCanEdit();
+ const historyControl = useDrawerControl(HISTORY_DRAWER_ID);
+
+ const tools: BlockTool[] = [
+ {
+ label: 'History',
+ icon: ClockIcon,
+ action: historyControl.toggle,
+ isActive: historyControl.isOpen,
+ condition: () =>
+ ENABLE_MARKDOWN_LIVE_COLLABORATION &&
+ ENABLE_HISTORY_COMPONENT &&
+ canEdit(),
+ },
+ ];
+
return (
<>
<SplitHeaderLeft>
<StaticSplitLabel label="AI Instructions" iconType="md" />
</SplitHeaderLeft>
- <SplitToolbarRight>
- <Show
- when={
- ENABLE_MARKDOWN_LIVE_COLLABORATION &&
- ENABLE_HISTORY_COMPONENT &&
- canEdit()
- }
- >
- <HistoryButton />
- </Show>
- </SplitToolbarRight>
+ <For each={tools}>
+ {(tool) => (
+ <Show when={!tool.condition || tool.condition()}>
+ {tool.buttonComponent ? (
+ <tool.buttonComponent />
+ ) : (
+ <ToolButton tool={tool} />
+ )}
+ </Show>
+ )}
+ </For>
</>
);
}
diff --git a/js/app/packages/block-pdf/component/TopBar.tsx b/js/app/packages/block-pdf/component/TopBar.tsx
index cc4cbca02d..dcd07ba1f3 100644
--- a/js/app/packages/block-pdf/component/TopBar.tsx
+++ b/js/app/packages/block-pdf/component/TopBar.tsx
@@ -1,40 +1,49 @@
-import {
- type FileOperation,
- SplitFileMenu,
-} from '@app/component/split-layout/components/SplitFileMenu';
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
+import type { FileOperation } from '@app/component/split-layout/components/SplitFileMenu';
import {
SplitHeaderLeft,
SplitHeaderRight,
} from '@app/component/split-layout/components/SplitHeader';
-import {
- BlockItemSplitLabel,
- SplitPermissionsBadge,
-} from '@app/component/split-layout/components/SplitLabel';
-import {
- SplitToolbarLeft,
- SplitToolbarRight,
-} from '@app/component/split-layout/components/SplitToolbar';
+import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+import { SplitToolbarLeft } from '@app/component/split-layout/components/SplitToolbar';
import { useHasModificationData } from '@block-pdf/signal/save';
import { useHasComments } from '@block-pdf/store/comments/commentStore';
import { doPrint } from '@block-pdf/util/printUtil';
import { exportPdf } from '@block-pdf/websocket/export';
import { useIsAuthenticated } from '@core/auth';
-import { useBlockId } from '@core/block';
-import { DocumentPropertiesButton } from '@core/component/DocumentPropertiesModal';
+import { useBlockId, useBlockName } from '@core/block';
+import {
+ DocumentPropertiesButton,
+ PROPERTIES_DRAWER_ID,
+} from '@core/component/DocumentPropertiesModal';
import { BlockLiveIndicators } from '@core/component/LiveIndicators';
-import { ReferencesButton } from '@core/component/ReferencesModal';
+import {
+ ReferencesButton,
+ REFERENCES_DRAWER_ID,
+} from '@core/component/ReferencesModal';
import { openLoginModal } from '@core/component/TopBar/LoginButton';
-import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+import {
+ ShareTrigger,
+ useShareDialogContext,
+} from '@core/component/TopBar/ShareButton';
import {
ENABLE_PDF_MARKUP,
ENABLE_REFERENCES_MODAL,
} from '@core/constant/featureFlags';
import { blockMetadataSignal } from '@core/signal/load';
+import { isMobile } from '@core/mobile/isMobile';
import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';
import { downloadFile } from '@filesystem/download';
import DownloadIcon from '@icon/regular/download-simple.svg';
import Printer from '@icon/regular/printer.svg';
-import { storageServiceClient } from '@service-storage/client';
+import Quotes from '@icon/regular/quotes.svg';
+import IconShared from '@icon/regular/share.svg';
+import TagIcon from '@icon/regular/tag.svg';
+import {
+ blockNameToItemType,
+ storageServiceClient,
+} from '@service-storage/client';
import { createCallback } from '@solid-primitives/rootless';
import { toast } from 'core/component/Toast/Toast';
import { platformFetch } from 'core/util/platformFetch';
@@ -43,17 +52,30 @@ import { pdfDocumentProxy } from '../signal/document';
import { LocationType, useCreateShareUrl } from '../signal/location';
import { MarkupToolbar } from './MarkupToolbar';
import { PageNumberInput } from './PageNumberInput';
+import {
+ ResponsiveBlockToolbar,
+ ResponsivePermissionsBadge,
+} from '@app/component/ResponsiveBlockToolbar';
export function TopBar() {
const isAuth = useIsAuthenticated();
const documentId = useBlockId();
+ const blockName = useBlockName();
const hasModificationData = useHasModificationData();
const hasComments = useHasComments();
const fileName = useBlockDocumentName('Unknown Filename');
- const fileType = blockMetadataSignal()?.fileType;
+ const referencesControl = useDrawerControl(REFERENCES_DRAWER_ID);
+ const propertiesControl = useDrawerControl(PROPERTIES_DRAWER_ID);
+ const shareCtx = useShareDialogContext();
const createShareUrl = useCreateShareUrl();
+
+ const itemType = blockNameToItemType(blockName);
+ if (!itemType) return null;
+
+ const fileType = blockMetadataSignal()?.fileType;
+
const copyLink = () => {
createShareUrl(LocationType.General);
toast.success('Link copied to clipboard');
@@ -164,6 +186,35 @@ export function TopBar() {
{ op: 'delete', divideAbove: true },
];
+ const tools: BlockTool[] = [
+ {
+ label: 'References',
+ icon: Quotes,
+ action: referencesControl.toggle,
+ condition: () => ENABLE_REFERENCES_MODAL,
+ buttonComponent: () => (
+ <ReferencesButton
+ documentId={documentId}
+ documentName={fileName()}
+ buttonSize="sm"
+ />
+ ),
+ },
+ {
+ label: 'Properties',
+ icon: TagIcon,
+ action: propertiesControl.toggle,
+ buttonComponent: () => <DocumentPropertiesButton buttonSize="sm" />,
+ },
+ {
+ label: 'Share',
+ icon: IconShared,
+ action: () => shareCtx.open(),
+ divideAbove: true,
+ buttonComponent: () => <ShareTrigger copyLink={copyLink} />,
+ },
+ ];
+
return (
<>
<SplitHeaderLeft>
@@ -172,36 +223,26 @@ export function TopBar() {
<SplitHeaderRight>
<BlockLiveIndicators />
</SplitHeaderRight>
+ <ResponsivePermissionsBadge />
<SplitToolbarLeft>
<Show when={pdfDocumentProxy()}>
<div class="flex items-center p-1">
- <SplitFileMenu
- id={documentId}
- itemType="document"
- name={fileName()}
- ops={ops}
- />
- <div class="w-5" />
+ <Show when={!isMobile()}>
+ <div class="w-5" />
+ </Show>
<PageNumberInput />
<div class="w-5" />
{ENABLE_PDF_MARKUP && <MarkupToolbar />}
</div>
</Show>
</SplitToolbarLeft>
- <SplitToolbarRight>
- <Show when={ENABLE_REFERENCES_MODAL}>
- <ReferencesButton
- documentId={documentId}
- documentName={fileName()}
- buttonSize="sm"
- />
- </Show>
- <DocumentPropertiesButton buttonSize="sm" />
- <div class="flex items-center">
- <SplitPermissionsBadge />
- <ShareTrigger copyLink={copyLink} />
- </div>
- </SplitToolbarRight>
+ <ResponsiveBlockToolbar
+ tools={tools}
+ ops={ops}
+ id={documentId}
+ itemType={itemType}
+ name={fileName()}
+ />
</>
);
}
diff --git a/js/app/packages/block-project/component/ProjectCreateMenu.tsx b/js/app/packages/block-project/component/ProjectCreateMenu.tsx
index 8c8340e2ae..f8cd33fc71 100644
--- a/js/app/packages/block-project/component/ProjectCreateMenu.tsx
+++ b/js/app/packages/block-project/component/ProjectCreateMenu.tsx
@@ -1,4 +1,5 @@
import { useSplitLayout } from '@app/component/split-layout/layout';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
import type { BlockAlias, BlockName } from '@core/block';
import { EntityIcon, getIconConfig } from '@core/component/EntityIcon';
import { DeprecatedButton } from '@core/component/FormControls/DeprecatedButton';
@@ -11,9 +12,12 @@ import {
createMarkdownFile,
createTask,
} from '@core/util/create';
+import { Dialog } from '@kobalte/core/dialog';
import { DropdownMenu } from '@kobalte/core/dropdown-menu';
+import PlusIcon from '@icon/regular/plus.svg';
import { createProject } from '@queries/storage/projects';
import { type Component, createSignal, For } from 'solid-js';
+import { DialogWrapper } from '@core/component/DialogWrapper';
type MenuItemProps = {
label: string;
@@ -24,29 +28,118 @@ type MenuItemProps = {
action: () => void | Promise<void>;
};
-function MenuItem(props: MenuItemProps) {
- const selectedColor = getIconConfig(props.blockName).foreground;
+type CreateBlockSpec = {
+ label: string;
+ blockName: BlockName | BlockAlias;
+ hotkeyToken: HotkeyToken;
+ icon: Component;
+ loading?: boolean;
+ createFn: (projectId: string) => Promise<string>;
+};
- return (
- <DropdownMenu.Item
- class={`flex justify-between items-center gap-12 px-1.5 py-1 text-sm isolate transition-transform ease-click duration-200 text-ink-extra-muted data-highlighted:${selectedColor} data-highlighted:bracket-offset-4`}
- onSelect={props.action}
- >
- <div class="flex items-center gap-1">
- <div class="size-4">
- <props.Icon />
- </div>
- <span>{props.label}</span>
+const BLOCK_CREATE_SPECS: CreateBlockSpec[] = [
+ {
+ label: 'Note',
+ blockName: 'md' as BlockName,
+ hotkeyToken: TOKENS.create.note,
+ icon: () => (
+ <div class="size-4 shrink-0">
+ <EntityIcon targetType="md" size="shrinkFill" theme="monochrome" />
</div>
- </DropdownMenu.Item>
- );
-}
-
-function MenuContent(props: { projectId: string }) {
- const { replaceSplit, insertSplit } = useSplitLayout();
- let ref!: HTMLDivElement;
+ ),
+ loading: true,
+ createFn: async (projectId) => {
+ const result = await createMarkdownFile({
+ title: '',
+ content: '',
+ projectId,
+ });
+ if (!result) throw new Error('Failed to create markdown file');
+ return result;
+ },
+ },
+ {
+ label: 'Task',
+ blockName: 'task' as BlockAlias,
+ hotkeyToken: TOKENS.create.task,
+ icon: () => (
+ <div class="size-4 shrink-0">
+ <EntityIcon targetType="task" size="shrinkFill" theme="monochrome" />
+ </div>
+ ),
+ loading: true,
+ createFn: async (projectId) => {
+ const result = await createTask({ title: '', content: '', projectId });
+ if (!result) throw new Error('Failed to create task');
+ return result;
+ },
+ },
+ {
+ label: 'AI',
+ blockName: 'chat' as BlockName,
+ hotkeyToken: TOKENS.create.chat,
+ icon: () => (
+ <div class="size-4 shrink-0">
+ <EntityIcon targetType="chat" size="shrinkFill" theme="monochrome" />
+ </div>
+ ),
+ createFn: async (projectId) => {
+ const result = await createChat({ projectId });
+ if ('error' in result) {
+ console.error(result.error);
+ throw new Error('Failed to create chat');
+ }
+ return result.chatId;
+ },
+ },
+ {
+ label: 'Canvas',
+ blockName: 'canvas' as BlockName,
+ hotkeyToken: TOKENS.create.canvas,
+ icon: () => (
+ <div class="size-4 shrink-0">
+ <EntityIcon targetType="canvas" size="shrinkFill" theme="monochrome" />
+ </div>
+ ),
+ loading: true,
+ createFn: async (projectId) => {
+ const result = await createCanvasFileFromJsonString({
+ json: JSON.stringify({ nodes: [], edges: [] }),
+ title: 'New Canvas',
+ projectId,
+ });
+ if ('error' in result) {
+ console.error(result.error);
+ throw new Error('Failed to create canvas');
+ }
+ return result.documentId;
+ },
+ },
+ {
+ label: 'Folder',
+ blockName: 'project' as BlockName,
+ hotkeyToken: TOKENS.create.project,
+ icon: () => (
+ <div class="size-4 shrink-0">
+ <EntityIcon targetType="project" size="shrinkFill" theme="monochrome" />
+ </div>
+ ),
+ createFn: async (projectId) => {
+ const result = await createProject({
+ name: 'New Project',
+ parentId: projectId,
+ });
+ if (!result) throw new Error('Failed to create folder');
+ return result;
+ },
+ },
+];
- const createBlock = async (spec: {
+function makeCreateBlock({
+ replaceSplit,
+ insertSplit,
+}: Pick<ReturnType<typeof useSplitLayout>, 'replaceSplit' | 'insertSplit'>) {
+ return async (spec: {
blockName: BlockName | BlockAlias;
createFn: () => Promise<string>;
loading?: boolean;
@@ -99,131 +192,126 @@ function MenuContent(props: { projectId: string }) {
});
}
};
+}
- const CREATABLE_BLOCKS: MenuItemProps[] = [
- {
- label: 'Note',
- blockName: 'md' as BlockName,
- hotkeyToken: TOKENS.create.note,
- Icon: () => (
- <EntityIcon targetType="md" size="shrinkFill" theme="monochrome" />
- ),
- action: () =>
- createBlock({
- blockName: 'md',
- loading: true,
- createFn: async () => {
- const result = await createMarkdownFile({
- title: '',
- content: '',
- projectId: props.projectId,
- });
- if (!result) throw new Error('Failed to create markdown file');
- return result;
- },
- }),
- },
- {
- label: 'Task',
- blockName: 'task' as BlockAlias,
- hotkeyToken: TOKENS.create.task,
- Icon: () => (
- <EntityIcon targetType="task" size="shrinkFill" theme="monochrome" />
- ),
- action: () =>
- createBlock({
- blockName: 'task' as BlockAlias,
- loading: true,
- createFn: async () => {
- const result = await createTask({
- title: '',
- content: '',
- projectId: props.projectId,
- });
- if (!result) throw new Error('Failed to create task');
- return result;
- },
- }),
- },
- {
- label: 'AI',
- blockName: 'chat' as BlockName,
- hotkeyToken: TOKENS.create.chat,
- Icon: () => (
- <EntityIcon targetType="chat" size="shrinkFill" theme="monochrome" />
- ),
- action: () =>
- createBlock({
- blockName: 'chat',
- createFn: async () => {
- const result = await createChat({ projectId: props.projectId });
- if ('error' in result) {
- console.error(result.error);
- throw new Error('Failed to create chat');
- }
- return result.chatId;
- },
- }),
- },
- {
- label: 'Canvas',
- blockName: 'canvas' as BlockName,
- hotkeyToken: TOKENS.create.canvas,
- Icon: () => (
- <EntityIcon targetType="canvas" size="shrinkFill" theme="monochrome" />
- ),
- action: () =>
- createBlock({
- blockName: 'canvas',
- loading: true,
- createFn: async () => {
- const result = await createCanvasFileFromJsonString({
- json: JSON.stringify({ nodes: [], edges: [] }),
- title: 'New Canvas',
- projectId: props.projectId,
- });
- if ('error' in result) {
- console.error(result.error);
- throw new Error('Failed to create canvas');
- }
- return result.documentId;
- },
- }),
- },
- {
- label: 'Folder',
- blockName: 'project' as BlockName,
- hotkeyToken: TOKENS.create.project,
- Icon: () => (
- <EntityIcon targetType="project" size="shrinkFill" theme="monochrome" />
- ),
- action: () =>
- createBlock({
- blockName: 'project',
- createFn: async () => {
- const result = await createProject({
- name: 'New Project',
- parentId: props.projectId,
- });
- if (!result) throw new Error('Failed to create folder');
- return result;
- },
- }),
- },
- ];
+function ProjectCreateDialog(props: {
+ open: boolean;
+ onClose: () => void;
+ projectId: string;
+ name: string;
+}) {
+ const { replaceSplit, insertSplit } = useSplitLayout();
+ const createBlock = makeCreateBlock({ replaceSplit, insertSplit });
return (
- <DropdownMenu.Content
- class="isolate relative flex flex-col gap-2 bg-dialog -mb-1 p-2 border-2 border-accent min-w-max bracket-never"
- ref={ref}
+ <Dialog open={props.open} onOpenChange={(o) => !o && props.onClose()}>
+ <Dialog.Portal>
+ <DialogWrapper width="">
+ <div class="p-2">
+ <Dialog.Title class="text-md font-semibold text-ink pb-3">
+ Create in {props.name}
+ </Dialog.Title>
+ <For each={BLOCK_CREATE_SPECS}>
+ {(spec) => (
+ <button
+ class="flex items-center gap-2 py-1 text-sm hover:bg-hover w-full text-left min-h-11"
+ onClick={() => {
+ props.onClose();
+ createBlock({
+ blockName: spec.blockName,
+ loading: spec.loading,
+ createFn: () => spec.createFn(props.projectId),
+ });
+ }}
+ >
+ <div class="size-4 shrink-0">
+ <spec.icon />
+ </div>
+ {spec.label}
+ </button>
+ )}
+ </For>
+ </div>
+ </DialogWrapper>
+ </Dialog.Portal>
+ </Dialog>
+ );
+}
+
+function MenuItem(props: MenuItemProps) {
+ const selectedColor = getIconConfig(props.blockName).foreground;
+
+ return (
+ <DropdownMenu.Item
+ class={`flex justify-between items-center gap-12 px-1.5 py-1 text-sm isolate transition-transform ease-click duration-200 text-ink-extra-muted data-highlighted:${selectedColor} data-highlighted:bracket-offset-4`}
+ onSelect={props.action}
>
- <For each={CREATABLE_BLOCKS}>
+ <div class="flex items-center gap-1">
+ <div class="size-4">
+ <props.Icon />
+ </div>
+ <span>{props.label}</span>
+ </div>
+ </DropdownMenu.Item>
+ );
+}
+
+function MenuContent(props: { projectId: string }) {
+ const { replaceSplit, insertSplit } = useSplitLayout();
+ const createBlock = makeCreateBlock({ replaceSplit, insertSplit });
+
+ const items: MenuItemProps[] = BLOCK_CREATE_SPECS.map((spec) => ({
+ label: spec.label,
+ blockName: spec.blockName,
+ hotkeyToken: spec.hotkeyToken,
+ Icon: spec.icon,
+ action: () =>
+ createBlock({
+ blockName: spec.blockName,
+ loading: spec.loading,
+ createFn: () => spec.createFn(props.projectId),
+ }),
+ }));
+
+ return (
+ <DropdownMenu.Content class="isolate relative flex flex-col gap-2 bg-dialog -mb-1 p-2 border-2 border-accent min-w-max bracket-never">
+ <For each={items}>
{(item, index) => <MenuItem {...item} index={index() + 1} />}
</For>
</DropdownMenu.Content>
);
}
+export function useProjectCreateTools(
+ projectId: string,
+ name: () => string,
+ condition?: () => boolean
+): { tools: BlockTool[]; CreateDialog: Component } {
+ const [open, setOpen] = createSignal(false);
+
+ const tools: BlockTool[] = [
+ {
+ label: 'Create',
+ icon: PlusIcon,
+ // Using a setTimeout here so that the synthetic click event after the touch doesn't instantly select an item
+ action: () => setTimeout(() => setOpen(true), 0),
+ divideAbove: true,
+ condition,
+ },
+ ];
+
+ const CreateDialog: Component = () => (
+ <ProjectCreateDialog
+ open={open()}
+ onClose={() => setOpen(false)}
+ projectId={projectId}
+ name={name()}
+ />
+ );
+
+ return { tools, CreateDialog };
+}
+
export function ProjectCreateMenu(props: { id: string }) {
const [open, setOpen] = createSignal(false);
return (
diff --git a/js/app/packages/block-project/component/ProjectPropertiesModal.tsx b/js/app/packages/block-project/component/ProjectPropertiesModal.tsx
index 6ec50a3d11..59328593f0 100644
--- a/js/app/packages/block-project/component/ProjectPropertiesModal.tsx
+++ b/js/app/packages/block-project/component/ProjectPropertiesModal.tsx
@@ -7,7 +7,8 @@ import TagIcon from '@icon/regular/tag.svg';
import { EntityType } from '@service-properties/generated/schemas/entityType';
import { Suspense } from 'solid-js';
-const DRAWER_ID = 'properties';
+export const PROPERTIES_DRAWER_ID = 'properties';
+const DRAWER_ID = PROPERTIES_DRAWER_ID;
export function ProjectPropertiesButton(props: { buttonSize?: 'sm' | 'base' }) {
const drawerControl = useDrawerControl(DRAWER_ID);
diff --git a/js/app/packages/block-project/component/TopBar.tsx b/js/app/packages/block-project/component/TopBar.tsx
index 507e479205..66f3a54e70 100644
--- a/js/app/packages/block-project/component/TopBar.tsx
+++ b/js/app/packages/block-project/component/TopBar.tsx
@@ -1,12 +1,18 @@
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
+import {
+ type BlockTool,
+ ResponsivePermissionsBadge,
+ ToolButton,
+} from '@app/component/ResponsiveBlockToolbar';
import {
type FileOperation,
SplitFileMenu,
} from '@app/component/split-layout/components/SplitFileMenu';
-import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
import {
- BlockItemSplitLabel,
- SplitPermissionsBadge,
-} from '@app/component/split-layout/components/SplitLabel';
+ SplitHeaderLeft,
+ SplitHeaderRight,
+} from '@app/component/split-layout/components/SplitHeader';
+import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
import {
SplitToolbarLeft,
SplitToolbarRight,
@@ -15,7 +21,10 @@ import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import { getIsSpecialProject } from '@block-project/isSpecial';
import { projectBlockDataSignal } from '@block-project/signal/projectBlockData';
import { useBlockId } from '@core/block';
-import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+import {
+ ShareTrigger,
+ useShareDialogContext,
+} from '@core/component/TopBar/ShareButton';
import {
ENABLE_PROJECT_SHARING,
ENABLE_PROJECT_VIEW_PREVIEW,
@@ -23,9 +32,15 @@ import {
import { useCanEdit, useIsDocumentOwner } from '@core/signal/permissions';
import { buildSimpleEntityUrl } from '@core/util/url';
import { toast } from 'core/component/Toast/Toast';
-import { createMemo, Show } from 'solid-js';
-import { ProjectCreateMenu } from './ProjectCreateMenu';
-import { ProjectPropertiesButton } from './ProjectPropertiesModal';
+import { isMobile } from '@core/mobile/isMobile';
+import IconShared from '@icon/regular/share.svg';
+import TagIcon from '@icon/regular/tag.svg';
+import { createMemo, For, Show } from 'solid-js';
+import { ProjectCreateMenu, useProjectCreateTools } from './ProjectCreateMenu';
+import {
+ ProjectPropertiesButton,
+ PROPERTIES_DRAWER_ID,
+} from './ProjectPropertiesModal';
// TODO (SEAMUS) : Revisit this file when we figure out what we wanna do
// with folder block.
@@ -41,6 +56,9 @@ export function TopBar() {
() => projectBlockDataSignal()?.projectMetadata.name ?? ''
);
+ const propertiesControl = useDrawerControl(PROPERTIES_DRAWER_ID);
+ const shareCtx = useShareDialogContext();
+
function handleCopyLink() {
navigator.clipboard.writeText(
buildSimpleEntityUrl(
@@ -69,39 +87,87 @@ export function TopBar() {
return !preview();
};
+ const { tools: createTools, CreateDialog } = useProjectCreateTools(
+ id,
+ name,
+ canEdit
+ );
+
+ const tools: BlockTool[] = [
+ {
+ label: 'Properties',
+ icon: TagIcon,
+ action: propertiesControl.toggle,
+ condition: () => !isSpecialProject,
+ buttonComponent: () => <ProjectPropertiesButton buttonSize="sm" />,
+ },
+ {
+ label: 'Share',
+ icon: IconShared,
+ action: () => shareCtx.open(),
+ divideAbove: true,
+ condition: () => ENABLE_PROJECT_SHARING && !isSpecialProject,
+ buttonComponent: () => <ShareTrigger copyLink={handleCopyLink} />,
+ },
+ ];
+
return (
<>
<SplitHeaderLeft>
<BlockItemSplitLabel fallbackName={name()} />
</SplitHeaderLeft>
- <SplitToolbarLeft class="flex-0">
- <div class="flex gap-2 p-1">
- <Show when={ops().length > 0}>
+ <ResponsivePermissionsBadge />
+ <Show
+ when={isMobile()}
+ fallback={
+ <>
+ <SplitToolbarLeft class="flex-0">
+ <div class="flex gap-2 p-1">
+ <Show when={ops().length > 0}>
+ <SplitFileMenu
+ id={id}
+ itemType="project"
+ name={name()}
+ ops={ops()}
+ />
+ <Show when={canEdit()}>
+ <ProjectCreateMenu id={id} />
+ </Show>
+ </Show>
+ </div>
+ </SplitToolbarLeft>
+ <Show when={showToolbarRight()}>
+ <SplitToolbarRight>
+ <For each={tools}>
+ {(tool) => (
+ <Show when={!tool.condition || tool.condition()}>
+ {tool.buttonComponent ? (
+ <tool.buttonComponent />
+ ) : (
+ <ToolButton tool={tool} />
+ )}
+ </Show>
+ )}
+ </For>
+ </SplitToolbarRight>
+ </Show>
+ </>
+ }
+ >
+ {/* Mobile layout */}
+ <SplitHeaderRight>
+ <Show when={ops().length > 0 || !isSpecialProject}>
<SplitFileMenu
id={id}
itemType="project"
name={name()}
ops={ops()}
+ tools={[...tools, ...createTools]}
/>
- <Show when={canEdit()}>
- <ProjectCreateMenu id={id} />
- </Show>
</Show>
- </div>
- </SplitToolbarLeft>
- <Show when={showToolbarRight()}>
- <SplitToolbarRight>
- <div class="flex items-center">
- <Show when={!isSpecialProject}>
- <ProjectPropertiesButton buttonSize="sm" />
- </Show>
- <SplitPermissionsBadge />
- <Show when={ENABLE_PROJECT_SHARING && !isSpecialProject}>
- <ShareTrigger copyLink={handleCopyLink} />
- </Show>
- </div>
- </SplitToolbarRight>
+ </SplitHeaderRight>
</Show>
+ <CreateDialog />
</>
);
}
diff --git a/js/app/packages/block-unknown/component/TopBar.tsx b/js/app/packages/block-unknown/component/TopBar.tsx
index 43a60773ff..ff4e734c83 100644
--- a/js/app/packages/block-unknown/component/TopBar.tsx
+++ b/js/app/packages/block-unknown/component/TopBar.tsx
@@ -1,25 +1,30 @@
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
import {
- type FileOperation,
- SplitFileMenu,
-} from '@app/component/split-layout/components/SplitFileMenu';
+ ResponsiveBlockToolbar,
+ ResponsivePermissionsBadge,
+} from '@app/component/ResponsiveBlockToolbar';
+import type { FileOperation } from '@app/component/split-layout/components/SplitFileMenu';
import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
+import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+
+import { useBlockId } from '@core/block';
import {
- BlockItemSplitLabel,
- SplitPermissionsBadge,
-} from '@app/component/split-layout/components/SplitLabel';
+ ReferencesButton,
+ REFERENCES_DRAWER_ID,
+} from '@core/component/ReferencesModal';
import {
- SplitToolbarLeft,
- SplitToolbarRight,
-} from '@app/component/split-layout/components/SplitToolbar';
-import { useBlockId } from '@core/block';
-import { ReferencesButton } from '@core/component/ReferencesModal';
-import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+ ShareTrigger,
+ useShareDialogContext,
+} from '@core/component/TopBar/ShareButton';
import {
useBlockDocumentDownloadName,
useBlockDocumentName,
} from '@core/util/currentBlockDocumentName';
import { downloadFile } from '@filesystem/download';
import DownloadSimple from '@icon/regular/download-simple.svg';
+import Quotes from '@icon/regular/quotes.svg';
+import IconShared from '@icon/regular/share.svg';
import { createCallback } from '@solid-primitives/rootless';
import { toast } from 'core/component/Toast/Toast';
import { useGetFileBlob } from '../signal/blockData';
@@ -30,6 +35,9 @@ export function TopBar() {
const downloadName = useBlockDocumentDownloadName();
const getBlob = useGetFileBlob();
+ const referencesControl = useDrawerControl(REFERENCES_DRAWER_ID);
+ const shareCtx = useShareDialogContext();
+
const downloadDocument = createCallback(async () => {
try {
const blob = await getBlob();
@@ -53,32 +61,43 @@ export function TopBar() {
{ op: 'delete', divideAbove: true },
];
- return (
- <>
- <SplitHeaderLeft>
- <BlockItemSplitLabel />
- </SplitHeaderLeft>
- <SplitToolbarLeft>
- <div class="p-1">
- <SplitFileMenu
- id={blockId}
- itemType="document"
- name={fileName()}
- ops={ops}
- />
- </div>
- </SplitToolbarLeft>
- <SplitToolbarRight>
+ const tools: BlockTool[] = [
+ {
+ label: 'References',
+ icon: Quotes,
+ action: referencesControl.toggle,
+ buttonComponent: () => (
<ReferencesButton
documentId={blockId}
documentName={fileName()}
buttonSize="sm"
/>
- <div class="flex items-center">
- <SplitPermissionsBadge />
- <ShareTrigger />
- </div>
- </SplitToolbarRight>
+ ),
+ },
+ {
+ label: 'Share',
+ icon: IconShared,
+ action: () => shareCtx.open(),
+ divideAbove: true,
+ buttonComponent: () => <ShareTrigger />,
+ },
+ ];
+
+ return (
+ <>
+ <SplitHeaderLeft>
+ <BlockItemSplitLabel />
+ </SplitHeaderLeft>
+
+ <ResponsivePermissionsBadge />
+
+ <ResponsiveBlockToolbar
+ tools={tools}
+ ops={ops}
+ id={blockId}
+ itemType="document"
+ name={fileName()}
+ />
</>
);
}
diff --git a/js/app/packages/block-video/component/TopBar.tsx b/js/app/packages/block-video/component/TopBar.tsx
index f8e71dd9ef..af1cfe49ea 100644
--- a/js/app/packages/block-video/component/TopBar.tsx
+++ b/js/app/packages/block-video/component/TopBar.tsx
@@ -1,25 +1,30 @@
+import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';
+import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';
import {
- type FileOperation,
- SplitFileMenu,
-} from '@app/component/split-layout/components/SplitFileMenu';
+ ResponsiveBlockToolbar,
+ ResponsivePermissionsBadge,
+} from '@app/component/ResponsiveBlockToolbar';
+import type { FileOperation } from '@app/component/split-layout/components/SplitFileMenu';
import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
+import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+
+import { useBlockId } from '@core/block';
import {
- BlockItemSplitLabel,
- SplitPermissionsBadge,
-} from '@app/component/split-layout/components/SplitLabel';
+ ReferencesButton,
+ REFERENCES_DRAWER_ID,
+} from '@core/component/ReferencesModal';
import {
- SplitToolbarLeft,
- SplitToolbarRight,
-} from '@app/component/split-layout/components/SplitToolbar';
-import { useBlockId } from '@core/block';
-import { ReferencesButton } from '@core/component/ReferencesModal';
-import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+ ShareTrigger,
+ useShareDialogContext,
+} from '@core/component/TopBar/ShareButton';
import {
useBlockDocumentDownloadName,
useBlockDocumentName,
} from '@core/util/currentBlockDocumentName';
import { downloadFile } from '@filesystem/download';
import Download from '@icon/regular/download.svg';
+import Quotes from '@icon/regular/quotes.svg';
+import IconShared from '@icon/regular/share.svg';
import { createCallback } from '@solid-primitives/rootless';
import { toast } from 'core/component/Toast/Toast';
import { useGetFileBlob } from '../signal/blockData';
@@ -30,6 +35,9 @@ export function TopBar() {
const downloadName = useBlockDocumentDownloadName();
const getBlob = useGetFileBlob();
+ const referencesControl = useDrawerControl(REFERENCES_DRAWER_ID);
+ const shareCtx = useShareDialogContext();
+
const downloadDocument = createCallback(async () => {
try {
const blob = await getBlob();
@@ -53,32 +61,43 @@ export function TopBar() {
{ op: 'delete', divideAbove: true },
];
- return (
- <>
- <SplitHeaderLeft>
- <BlockItemSplitLabel />
- </SplitHeaderLeft>
- <SplitToolbarLeft>
- <div class="p-1">
- <SplitFileMenu
- id={blockId}
- itemType="document"
- name={name()}
- ops={ops}
- />
- </div>
- </SplitToolbarLeft>
- <SplitToolbarRight>
+ const tools: BlockTool[] = [
+ {
+ label: 'References',
+ icon: Quotes,
+ action: referencesControl.toggle,
+ buttonComponent: () => (
<ReferencesButton
documentId={blockId}
documentName={name()}
buttonSize="sm"
/>
- <div class="flex items-center">
- <SplitPermissionsBadge />
- <ShareTrigger />
- </div>
- </SplitToolbarRight>
+ ),
+ },
+ {
+ label: 'Share',
+ icon: IconShared,
+ action: () => shareCtx.open(),
+ divideAbove: true,
+ buttonComponent: () => <ShareTrigger />,
+ },
+ ];
+
+ return (
+ <>
+ <SplitHeaderLeft>
+ <BlockItemSplitLabel />
+ </SplitHeaderLeft>
+
+ <ResponsivePermissionsBadge />
+
+ <ResponsiveBlockToolbar
+ tools={tools}
+ ops={ops}
+ id={blockId}
+ itemType="document"
+ name={name()}
+ />
</>
);
}
diff --git a/js/app/packages/core/component/DocumentPropertiesModal.tsx b/js/app/packages/core/component/DocumentPropertiesModal.tsx
index 6c0b575a62..f3c8f01c85 100644
--- a/js/app/packages/core/component/DocumentPropertiesModal.tsx
+++ b/js/app/packages/core/component/DocumentPropertiesModal.tsx
@@ -9,7 +9,8 @@ import TagIcon from '@icon/regular/tag.svg';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
import { Suspense } from 'solid-js';
-const DRAWER_ID = 'properties';
+export const PROPERTIES_DRAWER_ID = 'properties';
+const DRAWER_ID = PROPERTIES_DRAWER_ID;
function DocumentPropertiesContent(props: {
blockType: BlockName;
diff --git a/js/app/packages/core/component/NotificationsModal.tsx b/js/app/packages/core/component/NotificationsModal.tsx
index 6245c91377..d71bda5811 100644
--- a/js/app/packages/core/component/NotificationsModal.tsx
+++ b/js/app/packages/core/component/NotificationsModal.tsx
@@ -7,19 +7,20 @@ import {
type NotificationSource,
useNotificationsForEntity,
} from '@notifications';
+import { Button } from '@ui/components/Button';
+import { cn } from '@ui/utils/classname';
import { createMemo, Show, Suspense } from 'solid-js';
-import { DeprecatedIconButton } from './DeprecatedIconButton';
import { Notifications } from './Notifications';
false && clickOutside;
-const DRAWER_ID = 'notifications';
+export const NOTIFICATIONS_DRAWER_ID = 'notifications';
export function NotificationsButton(props: {
entity: Entity;
notificationSource: NotificationSource;
buttonSize?: 'sm';
}) {
- const drawerControl = useDrawerControl(DRAWER_ID);
+ const drawerControl = useDrawerControl(NOTIFICATIONS_DRAWER_ID);
const notifications = useNotificationsForEntity(
props.notificationSource,
props.entity
@@ -29,13 +30,21 @@ export function NotificationsButton(props: {
);
return (
<div class="relative" tabIndex={-1}>
- <DeprecatedIconButton
- icon={Bell}
- theme={drawerControl.isOpen() ? 'accent' : 'clear'}
- size={props.buttonSize ?? 'base'}
- tooltip={{ label: 'View notifications' }}
+ <Button
+ class={cn(
+ 'px-1',
+ drawerControl.isOpen() &&
+ 'bg-accent/20 hover:bg-accent/30 text-accent-ink'
+ )}
+ tooltip="View notifications"
onClick={() => drawerControl.toggle()}
- />
+ >
+ <Bell
+ class={
+ props.buttonSize === 'sm' ? 'size-4 shrink-0' : 'size-5 shrink-0'
+ }
+ />
+ </Button>
<Suspense fallback={null}>
<Show when={unreadCount() > 0}>
<div class="text-[6pt] bg-accent text-page font-semibold rounded-full absolute top-0 right-0 px-[4px] pointer-events-none">
@@ -67,7 +76,12 @@ export function NotificationsDrawer(props: {
</>
);
return (
- <SplitDrawer id={DRAWER_ID} side="right" size={768} title={title()}>
+ <SplitDrawer
+ id={NOTIFICATIONS_DRAWER_ID}
+ side="right"
+ size={768}
+ title={title()}
+ >
<Suspense
fallback={
<div class="flex justify-center py-8">
@@ -91,7 +105,7 @@ export type NotificationsModalProps = {
};
export function NotificationsModal(props: NotificationsModalProps) {
- const drawerControl = useDrawerControl(DRAWER_ID);
+ const drawerControl = useDrawerControl(NOTIFICATIONS_DRAWER_ID);
const notifications = useNotificationsForEntity(
props.notificationSource,
props.entity
@@ -115,15 +129,24 @@ export function NotificationsModal(props: NotificationsModalProps) {
return (
<>
<div class="relative" tabIndex={-1}>
- <DeprecatedIconButton
- icon={Bell}
- theme={drawerControl.isOpen() ? 'accent' : 'clear'}
- size={props.buttonSize ?? 'base'}
- tooltip={{ label: 'View notifications' }}
- onClick={() => {
- drawerControl.toggle();
- }}
- />
+ <Button
+ suppressInteractionStyling
+ class={cn(
+ 'aspect-square',
+ props.buttonSize === 'sm' ? 'size-6' : 'size-8',
+ drawerControl.isOpen()
+ ? 'bg-accent/10 text-accent-ink hover:bg-accent/20'
+ : 'text-ink hover:bg-hover'
+ )}
+ tooltip="View notifications"
+ onClick={() => drawerControl.toggle()}
+ >
+ <Bell
+ class={
+ props.buttonSize === 'sm' ? 'size-4 shrink-0' : 'size-5 shrink-0'
+ }
+ />
+ </Button>
<Suspense fallback={null}>
<Show when={unreadCount() > 0}>
<div class="text-[6pt] bg-accent text-page font-semibold rounded-full absolute top-0 right-0 px-[4px] pointer-events-none">
@@ -132,7 +155,12 @@ export function NotificationsModal(props: NotificationsModalProps) {
</Show>
</Suspense>
</div>
- <SplitDrawer id={DRAWER_ID} side="right" size={768} title={title()}>
+ <SplitDrawer
+ id={NOTIFICATIONS_DRAWER_ID}
+ side="right"
+ size={768}
+ title={title()}
+ >
<Suspense
fallback={
<div class="flex justify-center py-8">
diff --git a/js/app/packages/core/component/ReferencesModal.tsx b/js/app/packages/core/component/ReferencesModal.tsx
index dd90be2001..9975ccbe87 100644
--- a/js/app/packages/core/component/ReferencesModal.tsx
+++ b/js/app/packages/core/component/ReferencesModal.tsx
@@ -11,7 +11,7 @@ import { References } from './References';
import { Tooltip } from './Tooltip';
false && clickOutside;
-const DRAWER_ID = 'references';
+export const REFERENCES_DRAWER_ID = 'references';
export function ReferencesButton(props: {
documentId: string;
@@ -19,7 +19,7 @@ export function ReferencesButton(props: {
entityType?: ItemType;
buttonSize?: 'sm';
}) {
- const drawerControl = useDrawerControl(DRAWER_ID);
+ const drawerControl = useDrawerControl(REFERENCES_DRAWER_ID);
const [referenceCount] = createResource(
() => props.documentId,
async (id) => {
@@ -72,7 +72,12 @@ export function ReferencesDrawer(props: {
);
};
return (
- <SplitDrawer id={DRAWER_ID} side="right" size={768} title={title()}>
+ <SplitDrawer
+ id={REFERENCES_DRAWER_ID}
+ side="right"
+ size={768}
+ title={title()}
+ >
<Suspense
fallback={
<div class="flex justify-center py-8">
@@ -97,7 +102,7 @@ export type ReferencesModalProps = {
};
export function ReferencesModal(props: ReferencesModalProps) {
- const drawerControl = useDrawerControl(DRAWER_ID);
+ const drawerControl = useDrawerControl(REFERENCES_DRAWER_ID);
const [referenceCount] = createResource(
() => props.documentId,
async (id) => {
@@ -145,7 +150,12 @@ export function ReferencesModal(props: ReferencesModalProps) {
<BracketLeft class="h-4 w-2 rotate-180 text-edge" />
</div>
</Tooltip>
- <SplitDrawer id={DRAWER_ID} side="right" size={768} title={title()}>
+ <SplitDrawer
+ id={REFERENCES_DRAWER_ID}
+ side="right"
+ size={768}
+ title={title()}
+ >
<Suspense
fallback={
<div class="flex justify-center py-8">
diff --git a/js/app/packages/ui/components/Button.tsx b/js/app/packages/ui/components/Button.tsx
index 3e245a6c77..087fd8dc6b 100644
--- a/js/app/packages/ui/components/Button.tsx
+++ b/js/app/packages/ui/components/Button.tsx
@@ -61,7 +61,7 @@ export const Button: ParentComponent<ButtonProps> = (props) => {
'relative flex items-center justify-center gap-[1ch] px-[1ch] py-[0.25lh] border border-transparent',
'font-mono font-medium uppercase leading-none',
!local.suppressInteractionStyling &&
- 'hover:bg-surface-4 focus:[--focus-border-inset:-4px] active:border-accent active:bg-accent active:text-panel disabled:opacity-50 disabled:hover:bg-inherit',
+ 'hover:bg-hover focus:[--focus-border-inset:-4px] active:border-accent active:bg-accent active:text-panel disabled:opacity-50 disabled:hover:bg-inherit',
'touch:min-h-11 touch:min-w-11 touch:[&_svg]:size-6',
{