fix(web): keep narrow chat headers readable and aligned (#12453)
This commit is contained in:
1 parent
0ff87f251d
commit
c14f6015bf
7 files changed
+563
-229
No files matched your search
@@ -79,7 +79,16 @@ import {
|
||||
} from "~/components/ui/dialog";
|
||||
import { Group, GroupSeparator } from "~/components/ui/group";
|
||||
import { Input } from "~/components/ui/input";
|
||||
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "~/components/ui/menu";
|
||||
import {
|
||||
Menu,
|
||||
MenuItem,
|
||||
MenuItemLabel,
|
||||
MenuPopup,
|
||||
MenuSub,
|
||||
MenuSubTrigger,
|
||||
MenuSubPopup,
|
||||
MenuTrigger,
|
||||
} from "~/components/ui/menu";
|
||||
import { Popover, PopoverPopup, PopoverTrigger } from "~/components/ui/popover";
|
||||
import { ScrollArea } from "~/components/ui/scroll-area";
|
||||
import { Textarea } from "~/components/ui/textarea";
|
||||
@@ -108,6 +117,7 @@ import { useOpenLink } from "~/browser/useOpenLink";
|
||||
import { useOpenPrLink } from "~/lib/openPullRequestLink";
|
||||
|
||||
interface GitActionsControlProps {
|
||||
presentation?: "toolbar" | "menu";
|
||||
gitCwd: string | null;
|
||||
activeThreadRef: ScopedThreadRef | null;
|
||||
draftId?: DraftId;
|
||||
@@ -374,24 +384,25 @@ function GitActionItemIcon({
|
||||
function GitQuickActionIcon({
|
||||
quickAction,
|
||||
SourceControlIcon,
|
||||
className = "size-3.5",
|
||||
}: {
|
||||
quickAction: GitQuickAction;
|
||||
className?: string;
|
||||
SourceControlIcon: ReturnType<typeof getSourceControlPresentation>["Icon"];
|
||||
}) {
|
||||
const iconClassName = "size-3.5";
|
||||
if (quickAction.kind === "open_pr") return <SourceControlIcon className={iconClassName} />;
|
||||
if (quickAction.kind === "open_publish") return <CloudUploadIcon className={iconClassName} />;
|
||||
if (quickAction.kind === "run_pull") return <CloudDownloadIcon className={iconClassName} />;
|
||||
if (quickAction.kind === "open_pr") return <SourceControlIcon className={className} />;
|
||||
if (quickAction.kind === "open_publish") return <CloudUploadIcon className={className} />;
|
||||
if (quickAction.kind === "run_pull") return <CloudDownloadIcon className={className} />;
|
||||
if (quickAction.kind === "run_action") {
|
||||
if (quickAction.action === "commit") return <GitCommitIcon className={iconClassName} />;
|
||||
if (quickAction.action === "commit") return <GitCommitIcon className={className} />;
|
||||
if (quickAction.action === "push" || quickAction.action === "commit_push") {
|
||||
return <CloudUploadIcon className={iconClassName} />;
|
||||
return <CloudUploadIcon className={className} />;
|
||||
}
|
||||
return <SourceControlIcon className={iconClassName} />;
|
||||
return <SourceControlIcon className={className} />;
|
||||
}
|
||||
if (quickAction.label === "Commit") return <GitCommitIcon className={iconClassName} />;
|
||||
if (quickAction.label === "Push") return <CloudUploadIcon className={iconClassName} />;
|
||||
return <InfoIcon className={iconClassName} />;
|
||||
if (quickAction.label === "Commit") return <GitCommitIcon className={className} />;
|
||||
if (quickAction.label === "Push") return <CloudUploadIcon className={className} />;
|
||||
return <InfoIcon className={className} />;
|
||||
}
|
||||
|
||||
interface PublishRepositoryDialogProps {
|
||||
@@ -944,6 +955,7 @@ function PublishRepositoryDialog(props: PublishRepositoryDialogProps) {
|
||||
}
|
||||
|
||||
export default function GitActionsControl({
|
||||
presentation = "toolbar",
|
||||
gitCwd,
|
||||
activeThreadRef,
|
||||
draftId,
|
||||
@@ -1632,33 +1644,161 @@ export default function GitActionsControl({
|
||||
|
||||
const canPublishRepository = isRepo && gitStatusForActions !== null && !hasPrimaryRemote;
|
||||
|
||||
const initializeGit = () => {
|
||||
void (async () => {
|
||||
const result = await initAction.run();
|
||||
if (result._tag === "Success" || isAtomCommandInterrupted(result)) {
|
||||
return;
|
||||
}
|
||||
const error = squashAtomCommandFailure(result);
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Git initialization failed",
|
||||
description: error instanceof Error ? error.message : "An error occurred.",
|
||||
...(threadToastData !== undefined ? { data: threadToastData } : {}),
|
||||
}),
|
||||
);
|
||||
})();
|
||||
};
|
||||
const gitItems = (
|
||||
<>
|
||||
{gitActionMenuItems.map((item) => {
|
||||
const disabledReason = getMenuActionDisabledReason({
|
||||
item,
|
||||
gitStatus: gitStatusForActions,
|
||||
isBusy: isGitActionRunning,
|
||||
hasPrimaryRemote,
|
||||
});
|
||||
if (item.disabled && disabledReason && presentation === "menu") {
|
||||
return (
|
||||
<div key={`${item.id}-${item.label}`}>
|
||||
<MenuItem density={presentation === "menu" ? "touch" : "default"} disabled>
|
||||
<GitActionItemIcon icon={item.icon} SourceControlIcon={SourceControlIcon} />
|
||||
<MenuItemLabel>{item.label}</MenuItemLabel>
|
||||
</MenuItem>
|
||||
<p className="max-w-64 px-2 pb-2 text-xs text-muted-foreground">{disabledReason}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (item.disabled && disabledReason) {
|
||||
return (
|
||||
<Popover key={`${item.id}-${item.label}`}>
|
||||
<PopoverTrigger
|
||||
openOnHover
|
||||
nativeButton={false}
|
||||
render={<span className="block w-max cursor-not-allowed" />}
|
||||
>
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
className="w-full"
|
||||
disabled
|
||||
>
|
||||
<GitActionItemIcon icon={item.icon} SourceControlIcon={SourceControlIcon} />
|
||||
<MenuItemLabel>{item.label}</MenuItemLabel>
|
||||
</MenuItem>
|
||||
</PopoverTrigger>
|
||||
<PopoverPopup tooltipStyle side="left" align="center">
|
||||
{disabledReason}
|
||||
</PopoverPopup>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
key={`${item.id}-${item.label}`}
|
||||
disabled={item.disabled}
|
||||
onClick={() => {
|
||||
openDialogForMenuItem(item);
|
||||
}}
|
||||
>
|
||||
<GitActionItemIcon icon={item.icon} SourceControlIcon={SourceControlIcon} />
|
||||
<MenuItemLabel>{item.label}</MenuItemLabel>
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
{canPublishRepository ? (
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
disabled={isGitActionRunning}
|
||||
onClick={() => {
|
||||
setIsPublishDialogOpen(true);
|
||||
}}
|
||||
>
|
||||
<CloudUploadIcon />
|
||||
<MenuItemLabel>Publish repository...</MenuItemLabel>
|
||||
</MenuItem>
|
||||
) : null}
|
||||
{gitStatusForActions?.refName === null && (
|
||||
<p className="px-2 py-1.5 text-xs text-warning">
|
||||
Detached HEAD: create and check out a branch to enable push and pull request actions.
|
||||
</p>
|
||||
)}
|
||||
{gitStatusForActions &&
|
||||
gitStatusForActions.refName !== null &&
|
||||
!gitStatusForActions.hasWorkingTreeChanges &&
|
||||
gitStatusForActions.behindCount > 0 &&
|
||||
gitStatusForActions.aheadCount === 0 && (
|
||||
<p className="px-2 py-1.5 text-xs text-warning">Behind upstream. Pull/rebase first.</p>
|
||||
)}
|
||||
{gitStatusError && <p className="px-2 py-1.5 text-xs text-destructive">{gitStatusError}</p>}
|
||||
</>
|
||||
);
|
||||
|
||||
if (!gitCwd) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
{!isRepo ? (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="xs"
|
||||
disabled={initAction.isPending}
|
||||
onClick={() => {
|
||||
void (async () => {
|
||||
const result = await initAction.run();
|
||||
if (result._tag === "Success" || isAtomCommandInterrupted(result)) {
|
||||
return;
|
||||
}
|
||||
const error = squashAtomCommandFailure(result);
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Git initialization failed",
|
||||
description: error instanceof Error ? error.message : "An error occurred.",
|
||||
...(threadToastData !== undefined ? { data: threadToastData } : {}),
|
||||
}),
|
||||
);
|
||||
})();
|
||||
}}
|
||||
>
|
||||
{presentation === "menu" ? (
|
||||
!isRepo ? (
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
|
||||
disabled={initAction.isPending}
|
||||
onClick={initializeGit}
|
||||
>
|
||||
<GitBranchPlusIcon className="size-4" />
|
||||
<MenuItemLabel>
|
||||
{initAction.isPending ? "Initializing..." : "Initialize Git"}
|
||||
</MenuItemLabel>
|
||||
</MenuItem>
|
||||
) : (
|
||||
<>
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
|
||||
disabled={isGitActionRunning || quickAction.disabled || !!quickActionDisabledReason}
|
||||
onClick={runQuickAction}
|
||||
>
|
||||
<GitQuickActionIcon
|
||||
className="size-4"
|
||||
quickAction={quickAction}
|
||||
SourceControlIcon={SourceControlIcon}
|
||||
/>
|
||||
<MenuItemLabel>{quickAction.label}</MenuItemLabel>
|
||||
</MenuItem>
|
||||
{quickActionDisabledReason && (
|
||||
<p className="max-w-64 px-2 py-1.5 text-xs text-warning">
|
||||
{quickActionDisabledReason}
|
||||
</p>
|
||||
)}
|
||||
<MenuSub
|
||||
onOpenChange={(open) => {
|
||||
if (open) requestVcsStatusRefresh(refreshVcsStatus, activeEnvironmentId, gitCwd);
|
||||
}}
|
||||
>
|
||||
<MenuSubTrigger density="touch" disabled={isGitActionRunning}>
|
||||
<SourceControlIcon className="size-4" />
|
||||
<MenuItemLabel>Git actions</MenuItemLabel>
|
||||
</MenuSubTrigger>
|
||||
<MenuSubPopup className="min-w-32 max-w-[calc(100vw-2rem)]">{gitItems}</MenuSubPopup>
|
||||
</MenuSub>
|
||||
</>
|
||||
)
|
||||
) : !isRepo ? (
|
||||
<Button variant="outline" size="xs" disabled={initAction.isPending} onClick={initializeGit}>
|
||||
<GitBranchPlusIcon className="size-3.5" aria-hidden />
|
||||
<span className="ml-0.5">
|
||||
{initAction.isPending ? "Initializing..." : "Initialize Git"}
|
||||
@@ -1720,78 +1860,7 @@ export default function GitActionsControl({
|
||||
<ChevronDownIcon aria-hidden="true" className="size-4" />
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="end" className="w-full">
|
||||
{gitActionMenuItems.map((item) => {
|
||||
const disabledReason = getMenuActionDisabledReason({
|
||||
item,
|
||||
gitStatus: gitStatusForActions,
|
||||
isBusy: isGitActionRunning,
|
||||
hasPrimaryRemote,
|
||||
});
|
||||
if (item.disabled && disabledReason) {
|
||||
return (
|
||||
<Popover key={`${item.id}-${item.label}`}>
|
||||
<PopoverTrigger
|
||||
openOnHover
|
||||
nativeButton={false}
|
||||
render={<span className="block w-max cursor-not-allowed" />}
|
||||
>
|
||||
<MenuItem className="w-full" disabled>
|
||||
<GitActionItemIcon
|
||||
icon={item.icon}
|
||||
SourceControlIcon={SourceControlIcon}
|
||||
/>
|
||||
{item.label}
|
||||
</MenuItem>
|
||||
</PopoverTrigger>
|
||||
<PopoverPopup tooltipStyle side="left" align="center">
|
||||
{disabledReason}
|
||||
</PopoverPopup>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<MenuItem
|
||||
key={`${item.id}-${item.label}`}
|
||||
disabled={item.disabled}
|
||||
onClick={() => {
|
||||
openDialogForMenuItem(item);
|
||||
}}
|
||||
>
|
||||
<GitActionItemIcon icon={item.icon} SourceControlIcon={SourceControlIcon} />
|
||||
{item.label}
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
{canPublishRepository ? (
|
||||
<MenuItem
|
||||
disabled={isGitActionRunning}
|
||||
onClick={() => {
|
||||
setIsPublishDialogOpen(true);
|
||||
}}
|
||||
>
|
||||
<CloudUploadIcon />
|
||||
Publish repository...
|
||||
</MenuItem>
|
||||
) : null}
|
||||
{gitStatusForActions?.refName === null && (
|
||||
<p className="px-2 py-1.5 text-xs text-warning">
|
||||
Detached HEAD: create and check out a branch to enable push and pull request
|
||||
actions.
|
||||
</p>
|
||||
)}
|
||||
{gitStatusForActions &&
|
||||
gitStatusForActions.refName !== null &&
|
||||
!gitStatusForActions.hasWorkingTreeChanges &&
|
||||
gitStatusForActions.behindCount > 0 &&
|
||||
gitStatusForActions.aheadCount === 0 && (
|
||||
<p className="px-2 py-1.5 text-xs text-warning">
|
||||
Behind upstream. Pull/rebase first.
|
||||
</p>
|
||||
)}
|
||||
{gitStatusError && (
|
||||
<p className="px-2 py-1.5 text-xs text-destructive">{gitStatusError}</p>
|
||||
)}
|
||||
{gitItems}
|
||||
</MenuPopup>
|
||||
</Menu>
|
||||
</Group>
|
||||
|
||||
@@ -28,10 +28,14 @@ import {
|
||||
MenuGroup,
|
||||
MenuGroupLabel,
|
||||
MenuItem,
|
||||
MenuItemLabel,
|
||||
MenuPopup,
|
||||
MenuSeparator,
|
||||
MenuShortcut,
|
||||
MenuTrigger,
|
||||
MenuSub,
|
||||
MenuSubTrigger,
|
||||
MenuSubPopup,
|
||||
} from "./ui/menu";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
|
||||
|
||||
@@ -40,6 +44,8 @@ export type { NewProjectScriptInput, ProjectScriptActionResult };
|
||||
const NO_FILE_SCRIPTS: ReadonlyArray<T3ProjectFileScript> = [];
|
||||
|
||||
interface ProjectScriptsControlProps {
|
||||
presentation?: "toolbar" | "menu";
|
||||
onRequestMenuClose?: () => void;
|
||||
scripts: ReadonlyArray<ProjectScript>;
|
||||
/** Scripts declared in the project's checked-in t3.json, offered for import. */
|
||||
fileScripts?: ReadonlyArray<T3ProjectFileScript>;
|
||||
@@ -55,6 +61,8 @@ interface ProjectScriptsControlProps {
|
||||
}
|
||||
|
||||
export default function ProjectScriptsControl({
|
||||
presentation = "toolbar",
|
||||
onRequestMenuClose,
|
||||
scripts,
|
||||
fileScripts = NO_FILE_SCRIPTS,
|
||||
keybindings,
|
||||
@@ -65,9 +73,13 @@ export default function ProjectScriptsControl({
|
||||
onDeleteScript,
|
||||
}: ProjectScriptsControlProps) {
|
||||
const [actionsMenuOpen, setActionsMenuOpen] = useState({
|
||||
presentation,
|
||||
scripts: false,
|
||||
imports: false,
|
||||
});
|
||||
if (actionsMenuOpen.presentation !== presentation) {
|
||||
setActionsMenuOpen({ presentation, scripts: false, imports: false });
|
||||
}
|
||||
const [editorRequest, setEditorRequest] = useState<ProjectScriptEditorRequest | null>(null);
|
||||
|
||||
const primaryScript = useMemo(() => {
|
||||
@@ -97,7 +109,8 @@ export default function ProjectScriptsControl({
|
||||
};
|
||||
|
||||
const openEditDialog = (script: ProjectScript) => {
|
||||
setActionsMenuOpen({ scripts: false, imports: false });
|
||||
onRequestMenuClose?.();
|
||||
setActionsMenuOpen({ presentation, scripts: false, imports: false });
|
||||
setEditorRequest(editorRequestForScript(script, keybindings));
|
||||
};
|
||||
|
||||
@@ -138,12 +151,13 @@ export default function ProjectScriptsControl({
|
||||
<MenuGroupLabel>From t3.json</MenuGroupLabel>
|
||||
{importableScripts.map((fileScript) => (
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
key={`${fileScript.name} ${fileScript.command}`}
|
||||
className={dropdownItemClassName}
|
||||
onClick={() => void importFileScript(fileScript)}
|
||||
>
|
||||
<ScriptIcon icon={fileScript.icon ?? "play"} className="size-4" />
|
||||
<span className="truncate">{fileScript.name}</span>
|
||||
<MenuItemLabel className="truncate">{fileScript.name}</MenuItemLabel>
|
||||
<MenuShortcut className="ms-auto">
|
||||
<DownloadIcon className="size-3.5" aria-label="Import" />
|
||||
</MenuShortcut>
|
||||
@@ -153,9 +167,112 @@ export default function ProjectScriptsControl({
|
||||
</>
|
||||
);
|
||||
|
||||
const scriptItems = (
|
||||
<>
|
||||
{scripts.map((script) => {
|
||||
const shortcutLabel = shortcutLabelForCommand(
|
||||
keybindings,
|
||||
commandForProjectScript(script.id),
|
||||
);
|
||||
return (
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
key={script.id}
|
||||
className={`group ${dropdownItemClassName}`}
|
||||
onClick={() => onRunScript(script)}
|
||||
>
|
||||
<ScriptIcon icon={script.icon} className="size-4" />
|
||||
<MenuItemLabel className="truncate">
|
||||
{script.runOnWorktreeCreate ? `${script.name} (setup)` : script.name}
|
||||
</MenuItemLabel>
|
||||
<span className="relative ms-auto flex h-6 min-w-6 items-center justify-end">
|
||||
{shortcutLabel && (
|
||||
<MenuShortcut
|
||||
className={
|
||||
presentation === "menu"
|
||||
? "ms-0 mr-7"
|
||||
: "ms-0 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0"
|
||||
}
|
||||
>
|
||||
{shortcutLabel}
|
||||
</MenuShortcut>
|
||||
)}
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
className={`absolute right-0 top-1/2 size-6 -translate-y-1/2 ${presentation === "menu" ? "" : "opacity-0 pointer-events-none transition-opacity group-hover:opacity-100 group-hover:pointer-events-auto group-focus-visible:opacity-100 group-focus-visible:pointer-events-auto"}`}
|
||||
aria-label={`Edit ${script.name}`}
|
||||
onPointerDown={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
openEditDialog(script);
|
||||
}}
|
||||
>
|
||||
<SettingsIcon className="size-3.5" />
|
||||
</Button>
|
||||
</span>
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
{importMenuItems}
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
className={dropdownItemClassName}
|
||||
onClick={openAddDialog}
|
||||
>
|
||||
<PlusIcon className="size-4" />
|
||||
<MenuItemLabel>Add action</MenuItemLabel>
|
||||
</MenuItem>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{primaryScript ? (
|
||||
{presentation === "menu" ? (
|
||||
<>
|
||||
{primaryScript && (
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
onClick={() => onRunScript(primaryScript)}
|
||||
>
|
||||
<ScriptIcon icon={primaryScript.icon} className="size-4" />
|
||||
<MenuItemLabel className="truncate">Run {primaryScript.name}</MenuItemLabel>
|
||||
<MenuShortcut>
|
||||
{shortcutLabelForCommand(keybindings, commandForProjectScript(primaryScript.id))}
|
||||
</MenuShortcut>
|
||||
</MenuItem>
|
||||
)}
|
||||
{primaryScript || importableScripts.length > 0 ? (
|
||||
<MenuSub
|
||||
open={actionsMenuOpen.scripts}
|
||||
onOpenChange={(open) =>
|
||||
setActionsMenuOpen({ presentation, scripts: open, imports: false })
|
||||
}
|
||||
>
|
||||
<MenuSubTrigger density="touch">
|
||||
<ScriptIcon icon="play" className="size-4" />
|
||||
<MenuItemLabel>Project actions</MenuItemLabel>
|
||||
</MenuSubTrigger>
|
||||
<MenuSubPopup className="min-w-32 max-w-[calc(100vw-2rem)]">
|
||||
{scriptItems}
|
||||
</MenuSubPopup>
|
||||
</MenuSub>
|
||||
) : (
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
onClick={openAddDialog}
|
||||
>
|
||||
<PlusIcon className="size-4" />
|
||||
<MenuItemLabel>Add project action…</MenuItemLabel>
|
||||
</MenuItem>
|
||||
)}
|
||||
</>
|
||||
) : primaryScript ? (
|
||||
<Group aria-label="Project scripts">
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
@@ -183,70 +300,25 @@ export default function ProjectScriptsControl({
|
||||
<Menu
|
||||
highlightItemOnHover={false}
|
||||
open={actionsMenuOpen.scripts}
|
||||
onOpenChange={(open) => setActionsMenuOpen({ scripts: open, imports: false })}
|
||||
onOpenChange={(open) =>
|
||||
setActionsMenuOpen({ presentation, scripts: open, imports: false })
|
||||
}
|
||||
>
|
||||
<MenuTrigger
|
||||
render={<Button size="icon-xs" variant="outline" aria-label="Script actions" />}
|
||||
>
|
||||
<ChevronDownIcon className="size-4" />
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="end">
|
||||
{scripts.map((script) => {
|
||||
const shortcutLabel = shortcutLabelForCommand(
|
||||
keybindings,
|
||||
commandForProjectScript(script.id),
|
||||
);
|
||||
return (
|
||||
<MenuItem
|
||||
key={script.id}
|
||||
className={`group ${dropdownItemClassName}`}
|
||||
onClick={() => onRunScript(script)}
|
||||
>
|
||||
<ScriptIcon icon={script.icon} className="size-4" />
|
||||
<span className="truncate">
|
||||
{script.runOnWorktreeCreate ? `${script.name} (setup)` : script.name}
|
||||
</span>
|
||||
<span className="relative ms-auto flex h-6 min-w-6 items-center justify-end">
|
||||
{shortcutLabel && (
|
||||
<MenuShortcut className="ms-0 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0">
|
||||
{shortcutLabel}
|
||||
</MenuShortcut>
|
||||
)}
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
className="absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-0 pointer-events-none transition-opacity group-hover:opacity-100 group-hover:pointer-events-auto group-focus-visible:opacity-100 group-focus-visible:pointer-events-auto"
|
||||
aria-label={`Edit ${script.name}`}
|
||||
onPointerDown={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
openEditDialog(script);
|
||||
}}
|
||||
>
|
||||
<SettingsIcon className="size-3.5" />
|
||||
</Button>
|
||||
</span>
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
{importMenuItems}
|
||||
<MenuItem className={dropdownItemClassName} onClick={openAddDialog}>
|
||||
<PlusIcon className="size-4" />
|
||||
Add action
|
||||
</MenuItem>
|
||||
</MenuPopup>
|
||||
<MenuPopup align="end">{scriptItems}</MenuPopup>
|
||||
</Menu>
|
||||
</Group>
|
||||
) : importableScripts.length > 0 ? (
|
||||
<Menu
|
||||
highlightItemOnHover={false}
|
||||
open={actionsMenuOpen.imports}
|
||||
onOpenChange={(open) => setActionsMenuOpen({ scripts: false, imports: open })}
|
||||
onOpenChange={(open) =>
|
||||
setActionsMenuOpen({ presentation, scripts: false, imports: open })
|
||||
}
|
||||
>
|
||||
<MenuTrigger render={<Button size="xs" variant="outline" aria-label="Project actions" />}>
|
||||
<PlusIcon className="size-3.5" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ReactNode } from "react";
|
||||
import type { ComponentProps, ReactNode } from "react";
|
||||
|
||||
import { cn } from "../lib/utils";
|
||||
|
||||
@@ -26,6 +26,23 @@ interface WorkspaceBreadcrumbItemProps {
|
||||
readonly current?: boolean;
|
||||
}
|
||||
|
||||
export function WorkspaceBreadcrumbText({ children, className, ...props }: ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="workspace-breadcrumb-text"
|
||||
// Center the capital letters with adjacent icons, not the font's leading.
|
||||
// Padding preserves accents and descenders when a label is truncated.
|
||||
className={cn(
|
||||
"block min-w-0 truncate [text-box:trim-both_cap_alphabetic] supports-[text-box:trim-both_cap_alphabetic]:py-[0.5em]",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function WorkspaceBreadcrumbItem({
|
||||
children,
|
||||
className,
|
||||
@@ -45,10 +62,16 @@ export function WorkspaceBreadcrumbItem({
|
||||
);
|
||||
}
|
||||
|
||||
export function WorkspaceBreadcrumbSeparator({ className }: { readonly className?: string }) {
|
||||
export function WorkspaceBreadcrumbSeparator({
|
||||
className,
|
||||
children = "/",
|
||||
}: {
|
||||
readonly className?: string;
|
||||
readonly children?: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<li aria-hidden="true" className={cn("flex shrink-0 items-center text-icon-muted", className)}>
|
||||
/
|
||||
{children}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
isAtomCommandInterrupted,
|
||||
squashAtomCommandFailure,
|
||||
} from "@t3tools/client-runtime/state/runtime";
|
||||
import { ChevronDownIcon } from "lucide-react";
|
||||
import { ChevronDownIcon, EllipsisIcon } from "lucide-react";
|
||||
import {
|
||||
memo,
|
||||
useCallback,
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
type KeyboardEvent as ReactKeyboardEvent,
|
||||
type MouseEvent as ReactMouseEvent,
|
||||
} from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import GitActionsControl from "../GitActionsControl";
|
||||
import { isTrailingDoubleClick } from "../Sidebar.logic";
|
||||
import { type DraftId } from "~/composerDraftStore";
|
||||
@@ -45,8 +46,12 @@ import {
|
||||
WorkspaceBreadcrumb,
|
||||
WorkspaceBreadcrumbItem,
|
||||
WorkspaceBreadcrumbSeparator,
|
||||
WorkspaceBreadcrumbText,
|
||||
} from "../WorkspaceBreadcrumb";
|
||||
import { cn } from "~/lib/utils";
|
||||
import { useIsMobile } from "~/hooks/useMediaQuery";
|
||||
import { Button } from "../ui/button";
|
||||
import { Menu, MenuPopup, MenuSeparator, MenuTrigger } from "../ui/menu";
|
||||
|
||||
interface ChatHeaderProps {
|
||||
activeThreadEnvironmentId: EnvironmentId;
|
||||
@@ -155,6 +160,40 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
breakpoint: { value: HEADER_ACTIONS_EXPANDED_BREAKPOINT_REM, unit: "rem" },
|
||||
});
|
||||
}, [panelAnimationDurationMs, panelAnimationsActive]);
|
||||
const isMobile = useIsMobile();
|
||||
// Side panels can leave a desktop header narrower than a phone.
|
||||
const [isNarrowHeader, setIsNarrowHeader] = useState(false);
|
||||
useEffect(() => {
|
||||
const container = headerActionsRef.current?.parentElement;
|
||||
if (!container) return;
|
||||
const update = () => setIsNarrowHeader(container.clientWidth < 512);
|
||||
update();
|
||||
const observer = new ResizeObserver(update);
|
||||
observer.observe(container);
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
const actionsCollapsed = isMobile || isNarrowHeader;
|
||||
const [actionsOpen, setActionsOpen] = useState(false);
|
||||
const [actionsContainer] = useState(() => {
|
||||
const container = document.createElement("div");
|
||||
container.className = "contents";
|
||||
return container;
|
||||
});
|
||||
// Reparent the DOM host, not the React controls: rotating a phone or resizing
|
||||
// a window must not discard an unsaved script or Git dialog.
|
||||
const mountInlineActions = useCallback(
|
||||
(node: HTMLDivElement | null) => {
|
||||
if (node && !actionsCollapsed) node.appendChild(actionsContainer);
|
||||
},
|
||||
[actionsContainer, actionsCollapsed],
|
||||
);
|
||||
const mountMenuActions = useCallback(
|
||||
(node: HTMLDivElement | null) => {
|
||||
if (node && actionsCollapsed) node.appendChild(actionsContainer);
|
||||
},
|
||||
[actionsContainer, actionsCollapsed],
|
||||
);
|
||||
if (!actionsCollapsed && actionsOpen) setActionsOpen(false);
|
||||
const primaryEnvironmentId = usePrimaryEnvironmentId();
|
||||
const activeProjectName = activeProject?.title;
|
||||
const activeProjectCwd = activeProject?.workspaceRoot ?? null;
|
||||
@@ -312,6 +351,50 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
},
|
||||
[commitRename],
|
||||
);
|
||||
const headerActions = (
|
||||
<>
|
||||
{activeProjectScripts && (
|
||||
<>
|
||||
<ProjectScriptsControl
|
||||
onRequestMenuClose={() => setActionsOpen(false)}
|
||||
presentation={actionsCollapsed ? "menu" : "toolbar"}
|
||||
scripts={activeProjectScripts}
|
||||
fileScripts={fileScripts}
|
||||
keybindings={keybindings}
|
||||
preferredScriptId={preferredScriptId}
|
||||
onRunScript={onRunProjectScript}
|
||||
onAddScript={onAddProjectScript}
|
||||
onUpdateScript={onUpdateProjectScript}
|
||||
onDeleteScript={onDeleteProjectScript}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{showOpenInPicker && (
|
||||
<>
|
||||
{actionsCollapsed && activeProjectScripts && <MenuSeparator />}
|
||||
<OpenInPicker
|
||||
presentation={actionsCollapsed ? "menu" : "toolbar"}
|
||||
environmentId={activeThreadEnvironmentId}
|
||||
keybindings={keybindings}
|
||||
availableEditors={availableEditors}
|
||||
openInCwd={openInCwd}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{activeProjectName && gitCwd && (
|
||||
<>
|
||||
{actionsCollapsed && (activeProjectScripts || showOpenInPicker) && <MenuSeparator />}
|
||||
<GitActionsControl
|
||||
presentation={actionsCollapsed ? "menu" : "toolbar"}
|
||||
gitCwd={gitCwd}
|
||||
activeThreadRef={scopeThreadRef(activeThreadEnvironmentId, activeThreadId)}
|
||||
onOpenPullRequest={onOpenPullRequest}
|
||||
{...(draftId ? { draftId } : {})}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<div
|
||||
className="@container/header-actions flex min-w-0 flex-1 items-center gap-2 sm:gap-3"
|
||||
@@ -339,12 +422,16 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
}
|
||||
>
|
||||
<ProjectFavicon project={activeProject} className="size-3.5" />
|
||||
<span className="max-w-40 truncate">{activeProjectName}</span>
|
||||
<WorkspaceBreadcrumbText className="max-w-40">
|
||||
{activeProjectName}
|
||||
</WorkspaceBreadcrumbText>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">New thread in {activeProjectName}</TooltipPopup>
|
||||
</Tooltip>
|
||||
</WorkspaceBreadcrumbItem>
|
||||
<WorkspaceBreadcrumbSeparator />
|
||||
<WorkspaceBreadcrumbSeparator>
|
||||
<WorkspaceBreadcrumbText>/</WorkspaceBreadcrumbText>
|
||||
</WorkspaceBreadcrumbSeparator>
|
||||
</>
|
||||
) : null}
|
||||
<WorkspaceBreadcrumbItem current className="min-w-10 flex-1">
|
||||
@@ -377,7 +464,9 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
/>
|
||||
}
|
||||
>
|
||||
<h2 className="min-w-0 truncate">{activeThreadTitle}</h2>
|
||||
<h2 className="min-w-0">
|
||||
<WorkspaceBreadcrumbText>{activeThreadTitle}</WorkspaceBreadcrumbText>
|
||||
</h2>
|
||||
<ChevronDownIcon
|
||||
aria-hidden
|
||||
data-thread-title-chevron
|
||||
@@ -389,12 +478,10 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
) : (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<h2 aria-label={activeThreadTitle} className="min-w-0 flex-1 truncate">
|
||||
{activeThreadTitle}
|
||||
</h2>
|
||||
}
|
||||
/>
|
||||
render={<h2 aria-label={activeThreadTitle} className="min-w-0 flex-1" />}
|
||||
>
|
||||
<WorkspaceBreadcrumbText>{activeThreadTitle}</WorkspaceBreadcrumbText>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">{activeThreadTitle}</TooltipPopup>
|
||||
</Tooltip>
|
||||
)}
|
||||
@@ -405,38 +492,37 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
data-chat-header-actions
|
||||
className={cn(
|
||||
"flex shrink-0 items-center justify-end gap-2 @3xl/header-actions:gap-3",
|
||||
rightPanelOpen ? "pr-0" : "pr-16",
|
||||
// Reserve two panel toggles plus their 4px gaps and 1px edge inset.
|
||||
// The page header adds 8px more right padding at sm.
|
||||
rightPanelOpen ? "pr-0" : "pr-[calc(--spacing(18)+1px)] sm:pr-[calc(--spacing(14)+1px)]",
|
||||
"[[data-panel-animations=true]_&]:motion-safe:transition-[padding-right] [[data-panel-animations=true]_&]:motion-safe:[transition-duration:var(--panel-animation-duration)] [[data-panel-animations=true]_&]:motion-safe:ease-out",
|
||||
)}
|
||||
>
|
||||
{activeProjectScripts && (
|
||||
<ProjectScriptsControl
|
||||
scripts={activeProjectScripts}
|
||||
fileScripts={fileScripts}
|
||||
keybindings={keybindings}
|
||||
preferredScriptId={preferredScriptId}
|
||||
onRunScript={onRunProjectScript}
|
||||
onAddScript={onAddProjectScript}
|
||||
onUpdateScript={onUpdateProjectScript}
|
||||
onDeleteScript={onDeleteProjectScript}
|
||||
/>
|
||||
)}
|
||||
{showOpenInPicker && (
|
||||
<OpenInPicker
|
||||
environmentId={activeThreadEnvironmentId}
|
||||
keybindings={keybindings}
|
||||
availableEditors={availableEditors}
|
||||
openInCwd={openInCwd}
|
||||
/>
|
||||
)}
|
||||
{activeProjectName && (
|
||||
<GitActionsControl
|
||||
gitCwd={gitCwd}
|
||||
activeThreadRef={scopeThreadRef(activeThreadEnvironmentId, activeThreadId)}
|
||||
onOpenPullRequest={onOpenPullRequest}
|
||||
{...(draftId ? { draftId } : {})}
|
||||
/>
|
||||
)}
|
||||
<Menu open={actionsCollapsed && actionsOpen} onOpenChange={setActionsOpen}>
|
||||
<MenuTrigger
|
||||
className={
|
||||
actionsCollapsed &&
|
||||
(activeProjectScripts || showOpenInPicker || (activeProjectName && gitCwd))
|
||||
? undefined
|
||||
: "hidden"
|
||||
}
|
||||
render={<Button size="icon-sm" variant="ghost" aria-label="More header actions" />}
|
||||
>
|
||||
<EllipsisIcon className="size-4" />
|
||||
</MenuTrigger>
|
||||
<div ref={mountInlineActions} className="contents" />
|
||||
<MenuPopup
|
||||
data-chat-header-actions
|
||||
keepMounted
|
||||
aria-label="Header actions"
|
||||
align="end"
|
||||
className="min-w-56 max-w-[calc(100vw-2rem)]"
|
||||
finalFocus={actionsCollapsed ? undefined : false}
|
||||
>
|
||||
<div ref={mountMenuActions} className="contents" />
|
||||
{createPortal(headerActions, actionsContainer)}
|
||||
</MenuPopup>
|
||||
</Menu>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -15,10 +15,20 @@ import {
|
||||
useRemoteOpenState,
|
||||
} from "../../remoteOpen";
|
||||
import { useEnvironment } from "../../state/environments";
|
||||
import { ChevronDownIcon, FolderClosedIcon } from "lucide-react";
|
||||
import { ChevronDownIcon, FolderClosedIcon, SquareArrowOutUpRightIcon } from "lucide-react";
|
||||
import { Button } from "../ui/button";
|
||||
import { Group, GroupSeparator } from "../ui/group";
|
||||
import { Menu, MenuItem, MenuPopup, MenuShortcut, MenuTrigger } from "../ui/menu";
|
||||
import {
|
||||
Menu,
|
||||
MenuItem,
|
||||
MenuItemLabel,
|
||||
MenuPopup,
|
||||
MenuShortcut,
|
||||
MenuSub,
|
||||
MenuSubTrigger,
|
||||
MenuSubPopup,
|
||||
MenuTrigger,
|
||||
} from "../ui/menu";
|
||||
import {
|
||||
AntigravityIcon,
|
||||
CursorIcon,
|
||||
@@ -187,6 +197,7 @@ export const OpenInPicker = memo(function OpenInPicker({
|
||||
keybindings,
|
||||
availableEditors,
|
||||
openInCwd,
|
||||
presentation = "toolbar",
|
||||
compact = false,
|
||||
enableShortcut = true,
|
||||
}: {
|
||||
@@ -194,6 +205,7 @@ export const OpenInPicker = memo(function OpenInPicker({
|
||||
keybindings: ResolvedKeybindingsConfig;
|
||||
availableEditors: ReadonlyArray<EditorId>;
|
||||
openInCwd: string | null;
|
||||
presentation?: "toolbar" | "menu";
|
||||
compact?: boolean;
|
||||
enableShortcut?: boolean;
|
||||
}) {
|
||||
@@ -274,6 +286,69 @@ export const OpenInPicker = memo(function OpenInPicker({
|
||||
return () => window.removeEventListener("keydown", handler);
|
||||
}, [enableShortcut, keybindings, openInCwd, openInEditor, preferredEditor]);
|
||||
|
||||
const editorItems = (
|
||||
<>
|
||||
{remote.mode === "remote-unavailable" ? (
|
||||
<MenuItem density={presentation === "menu" ? "touch" : "default"} disabled>
|
||||
No SSH route to {environmentLabel}
|
||||
</MenuItem>
|
||||
) : (
|
||||
<>
|
||||
{options.length === 0 && (
|
||||
<MenuItem density={presentation === "menu" ? "touch" : "default"} disabled>
|
||||
No installed editors found
|
||||
</MenuItem>
|
||||
)}
|
||||
{options.map(({ label, Icon, value, kind }) => (
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
key={value}
|
||||
onClick={() => openInEditor(value)}
|
||||
>
|
||||
<Icon aria-hidden="true" className={getOpenInIconClass(kind)} />
|
||||
<MenuItemLabel>{label}</MenuItemLabel>
|
||||
{value === preferredEditor && openFavoriteEditorShortcutLabel && (
|
||||
<MenuShortcut>{openFavoriteEditorShortcutLabel}</MenuShortcut>
|
||||
)}
|
||||
</MenuItem>
|
||||
))}
|
||||
{remote.mode === "remote-links" && !remoteHintSeen && (
|
||||
<MenuItem density={presentation === "menu" ? "touch" : "default"} disabled>
|
||||
Opens over SSH. Needs your key on {environmentLabel}
|
||||
</MenuItem>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
if (presentation === "menu") {
|
||||
return (
|
||||
<>
|
||||
{primaryOption && (
|
||||
<MenuItem
|
||||
density={presentation === "menu" ? "touch" : "default"}
|
||||
|
||||
disabled={!openInCwd || remote.mode === "remote-unavailable"}
|
||||
onClick={() => openInEditor(preferredEditor)}
|
||||
>
|
||||
<primaryOption.Icon className={cn("size-4", getOpenInIconClass(primaryOption.kind))} />
|
||||
<MenuItemLabel className="truncate">Open in {primaryOption.label}</MenuItemLabel>
|
||||
{openFavoriteEditorShortcutLabel && (
|
||||
<MenuShortcut>{openFavoriteEditorShortcutLabel}</MenuShortcut>
|
||||
)}
|
||||
</MenuItem>
|
||||
)}
|
||||
<MenuSub>
|
||||
<MenuSubTrigger density="touch">
|
||||
<SquareArrowOutUpRightIcon className="size-4" />
|
||||
<MenuItemLabel>Open in…</MenuItemLabel>
|
||||
</MenuSubTrigger>
|
||||
<MenuSubPopup className="min-w-32 max-w-[calc(100vw-2rem)]">{editorItems}</MenuSubPopup>
|
||||
</MenuSub>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Group aria-label="Open in editor">
|
||||
<Button
|
||||
@@ -307,27 +382,7 @@ export const OpenInPicker = memo(function OpenInPicker({
|
||||
>
|
||||
<ChevronDownIcon aria-hidden="true" className="size-4" />
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="end">
|
||||
{remote.mode === "remote-unavailable" ? (
|
||||
<MenuItem disabled>No SSH route to {environmentLabel}</MenuItem>
|
||||
) : (
|
||||
<>
|
||||
{options.length === 0 && <MenuItem disabled>No installed editors found</MenuItem>}
|
||||
{options.map(({ label, Icon, value, kind }) => (
|
||||
<MenuItem key={value} onClick={() => openInEditor(value)}>
|
||||
<Icon aria-hidden="true" className={getOpenInIconClass(kind)} />
|
||||
{label}
|
||||
{value === preferredEditor && openFavoriteEditorShortcutLabel && (
|
||||
<MenuShortcut>{openFavoriteEditorShortcutLabel}</MenuShortcut>
|
||||
)}
|
||||
</MenuItem>
|
||||
))}
|
||||
{remote.mode === "remote-links" && !remoteHintSeen && (
|
||||
<MenuItem disabled>Opens over SSH. Needs your key on {environmentLabel}</MenuItem>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</MenuPopup>
|
||||
<MenuPopup align="end">{editorItems}</MenuPopup>
|
||||
</Menu>
|
||||
</Group>
|
||||
);
|
||||
|
||||
@@ -25,6 +25,7 @@ function MenuPopup({
|
||||
alignOffset,
|
||||
side = "bottom",
|
||||
anchor,
|
||||
keepMounted = false,
|
||||
...props
|
||||
}: MenuPrimitive.Popup.Props & {
|
||||
align?: MenuPrimitive.Positioner.Props["align"];
|
||||
@@ -32,6 +33,7 @@ function MenuPopup({
|
||||
alignOffset?: MenuPrimitive.Positioner.Props["alignOffset"];
|
||||
side?: MenuPrimitive.Positioner.Props["side"];
|
||||
anchor?: MenuPrimitive.Positioner.Props["anchor"];
|
||||
keepMounted?: boolean;
|
||||
}) {
|
||||
const hasExplicitWidthClass =
|
||||
typeof className === "string" &&
|
||||
@@ -41,7 +43,7 @@ function MenuPopup({
|
||||
});
|
||||
|
||||
return (
|
||||
<MenuPrimitive.Portal>
|
||||
<MenuPrimitive.Portal keepMounted={keepMounted}>
|
||||
<MenuPrimitive.Positioner
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
@@ -74,10 +76,12 @@ function MenuGroup(props: MenuPrimitive.Group.Props) {
|
||||
function MenuItem({
|
||||
className,
|
||||
inset,
|
||||
density = "default",
|
||||
variant = "default",
|
||||
...props
|
||||
}: MenuPrimitive.Item.Props & {
|
||||
inset?: boolean;
|
||||
density?: "default" | "touch";
|
||||
variant?: "default" | "destructive" | "ghost";
|
||||
}) {
|
||||
return (
|
||||
@@ -90,8 +94,10 @@ function MenuItem({
|
||||
size: "compact",
|
||||
className: "h-auto min-h-7 w-full sm:text-xs",
|
||||
}),
|
||||
density === "touch" && "min-h-10 sm:min-h-10",
|
||||
className,
|
||||
)}
|
||||
data-density={density}
|
||||
data-inset={inset}
|
||||
data-slot="menu-item"
|
||||
data-variant={variant}
|
||||
@@ -100,6 +106,21 @@ function MenuItem({
|
||||
);
|
||||
}
|
||||
|
||||
// Trim font leading so visible letters center with the icons in touch rows.
|
||||
// Symmetric padding keeps accents and descenders inside truncated labels.
|
||||
function MenuItemLabel({ className, ...props }: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="menu-item-label"
|
||||
className={cn(
|
||||
"min-w-0 in-data-[density=touch]:[text-box:trim-both_cap_alphabetic] supports-[text-box:trim-both_cap_alphabetic]:in-data-[density=touch]:py-[0.5em]",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function MenuCheckboxItem({
|
||||
className,
|
||||
children,
|
||||
@@ -247,10 +268,12 @@ function MenuSub(props: MenuPrimitive.SubmenuRoot.Props) {
|
||||
function MenuSubTrigger({
|
||||
className,
|
||||
inset,
|
||||
density = "default",
|
||||
children,
|
||||
...props
|
||||
}: MenuPrimitive.SubmenuTrigger.Props & {
|
||||
inset?: boolean;
|
||||
density?: "default" | "touch";
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.SubmenuTrigger
|
||||
@@ -261,8 +284,10 @@ function MenuSubTrigger({
|
||||
// also a direct svg — on a sub-trigger with no leading icon it is the
|
||||
// only one, and these rules would take away its `ms-auto` alignment.
|
||||
"[&>svg:not(:last-child)]:-mx-0.5 flex min-h-8 cursor-pointer items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none data-disabled:cursor-not-allowed data-disabled:pointer-events-none data-highlighted:bg-accent data-popup-open:bg-accent data-inset:ps-8 data-highlighted:text-accent-foreground data-popup-open:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&>svg:not(:last-child):not([class*='opacity-'])]:opacity-80 [&_svg]:pointer-events-none [&>svg]:shrink-0",
|
||||
density === "touch" && "min-h-10 sm:min-h-10",
|
||||
className,
|
||||
)}
|
||||
data-density={density}
|
||||
data-inset={inset}
|
||||
data-slot="menu-sub-trigger"
|
||||
{...props}
|
||||
@@ -309,6 +334,7 @@ export {
|
||||
MenuGroup,
|
||||
MenuGroup as DropdownMenuGroup,
|
||||
MenuItem,
|
||||
MenuItemLabel,
|
||||
MenuItem as DropdownMenuItem,
|
||||
MenuCheckboxItem,
|
||||
MenuCheckboxItem as DropdownMenuCheckboxItem,
|
||||
|
||||
@@ -155,7 +155,10 @@ function SidebarProvider({
|
||||
<SidebarContext value={contextValue}>
|
||||
<div
|
||||
// Inset layouts opt into bg-sidebar through className.
|
||||
className={cn("group/sidebar-wrapper flex min-h-svh w-full", className)}
|
||||
className={cn(
|
||||
"group/sidebar-wrapper flex min-h-svh w-full max-sm:[--workspace-titlebar-control-size:--spacing(8)]",
|
||||
className,
|
||||
)}
|
||||
data-sidebar-state={state}
|
||||
data-slot="sidebar-wrapper"
|
||||
style={
|
||||
@@ -337,7 +340,7 @@ function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<t
|
||||
variant="ghost"
|
||||
{...props}
|
||||
>
|
||||
{isOpen ? <PanelLeftCloseIcon /> : <PanelLeftIcon />}
|
||||
{isOpen ? <PanelLeftCloseIcon className="size-4" /> : <PanelLeftIcon className="size-4" />}
|
||||
<span className="sr-only">Toggle Sidebar</span>
|
||||
</Button>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user