fix(web): composer banner actions stay inline whenever they fit (#17640)
Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
1 parent
cc62349c37
commit
3e94afa7c2
3 files changed
+9
-22
No files matched your search
@@ -2542,7 +2542,6 @@ export default function ChatView(props: ChatViewProps) {
|
||||
return {
|
||||
id: `project-clone:${projectId}`,
|
||||
variant: "info",
|
||||
compact: true,
|
||||
priority: "activity",
|
||||
icon: <DownloadIcon />,
|
||||
title: `Cloning ${name}`,
|
||||
@@ -2566,7 +2565,6 @@ export default function ChatView(props: ChatViewProps) {
|
||||
return {
|
||||
id: `project-clone:${projectId}`,
|
||||
variant: cancelled ? "warning" : "error",
|
||||
compact: true,
|
||||
icon: <DownloadIcon />,
|
||||
title: cancelled ? `Cancelled cloning ${name}` : `Failed to clone ${name}`,
|
||||
description: cancelled ? "Retry to bring in the repository." : activeProjectClone.error,
|
||||
|
||||
@@ -183,17 +183,15 @@ function Row({
|
||||
layout = "inline",
|
||||
...props
|
||||
}: useRender.ComponentProps<"div"> & {
|
||||
layout?: "inline" | "wrap-actions" | "wrap-actions-narrow" | "approval";
|
||||
layout?: "inline" | "wrap-actions" | "approval";
|
||||
}) {
|
||||
const rowProps = {
|
||||
className: cn(
|
||||
"group/banner-row grid min-h-(--composer-banner-icon-column) w-full min-w-0 grid-cols-[var(--composer-banner-icon-column)_minmax(0,1fr)_auto] items-center gap-x-1 text-start",
|
||||
"not-has-[>[data-slot=composer-banner-actions]]:grid-cols-[var(--composer-banner-icon-column)_minmax(0,1fr)]",
|
||||
"[&:is(button)]:cursor-pointer [&:is(button)]:rounded-md [&:is(button)]:focus-visible:outline-2 [&:is(button)]:focus-visible:-outline-offset-2 [&:is(button)]:focus-visible:outline-ring",
|
||||
layout === "wrap-actions" &&
|
||||
"@max-[400px]:*:data-[slot=composer-banner-content]:min-h-(--composer-banner-icon-column)",
|
||||
layout === "wrap-actions-narrow" &&
|
||||
"@max-[320px]:*:data-[slot=composer-banner-content]:min-h-(--composer-banner-icon-column)",
|
||||
// Actions share the title row while the title fits and move below it otherwise.
|
||||
layout === "wrap-actions" && "flex flex-wrap *:data-[slot=composer-banner-content]:grow",
|
||||
layout === "approval" && "items-start gap-x-2 gap-y-3",
|
||||
className,
|
||||
),
|
||||
@@ -257,8 +255,7 @@ function Actions({ className, ...props }: ComponentProps<"span">) {
|
||||
className={cn(
|
||||
"col-start-3 row-start-1 flex flex-wrap items-center justify-end gap-1",
|
||||
"group-data-[composer-banner-layout=approval]/banner-row:self-center group-data-[composer-banner-layout=approval]/banner-row:gap-1.5 @max-[560px]:group-data-[composer-banner-layout=approval]/banner-row:col-start-2 @max-[560px]:group-data-[composer-banner-layout=approval]/banner-row:col-end-4 @max-[560px]:group-data-[composer-banner-layout=approval]/banner-row:row-start-2",
|
||||
"@max-[400px]:group-data-[composer-banner-layout=wrap-actions]/banner-row:has-[>:nth-child(2)]:col-start-2 @max-[400px]:group-data-[composer-banner-layout=wrap-actions]/banner-row:has-[>:nth-child(2)]:col-end-4 @max-[400px]:group-data-[composer-banner-layout=wrap-actions]/banner-row:has-[>:nth-child(2)]:row-start-2 @max-[400px]:group-data-[composer-banner-layout=wrap-actions]/banner-row:has-[>:nth-child(2)]:justify-end",
|
||||
"@max-[320px]:group-data-[composer-banner-layout=wrap-actions-narrow]/banner-row:has-[>:nth-child(2)]:col-start-2 @max-[320px]:group-data-[composer-banner-layout=wrap-actions-narrow]/banner-row:has-[>:nth-child(2)]:col-end-4 @max-[320px]:group-data-[composer-banner-layout=wrap-actions-narrow]/banner-row:has-[>:nth-child(2)]:row-start-2 @max-[320px]:group-data-[composer-banner-layout=wrap-actions-narrow]/banner-row:has-[>:nth-child(2)]:-ms-2 @max-[320px]:group-data-[composer-banner-layout=wrap-actions-narrow]/banner-row:has-[>:nth-child(2)]:justify-start",
|
||||
"group-data-[composer-banner-layout=wrap-actions]/banner-row:ms-auto",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -13,7 +13,6 @@ export interface ComposerBannerStackItem {
|
||||
readonly id: string;
|
||||
readonly variant: ComposerBannerVariant;
|
||||
readonly priority?: "urgent" | "activity" | "notice";
|
||||
readonly compact?: boolean;
|
||||
readonly icon: ReactNode;
|
||||
readonly title: ReactNode;
|
||||
readonly description?: ReactNode;
|
||||
@@ -250,7 +249,7 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
|
||||
}
|
||||
|
||||
/** Keep full descriptions reachable only when their inline copy is clipped. */
|
||||
function NoticeDescription({ children, compact }: { children: ReactNode; compact?: boolean }) {
|
||||
function NoticeDescription({ children }: { children: ReactNode }) {
|
||||
const descriptionRef = useRef<HTMLSpanElement>(null);
|
||||
const detailsRef = useRef<HTMLButtonElement>(null);
|
||||
const [showDetails, setShowDetails] = useState(false);
|
||||
@@ -283,13 +282,10 @@ function NoticeDescription({ children, compact }: { children: ReactNode; compact
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<span className={compact ? "contents" : "flex min-w-8 flex-1 items-center gap-1"}>
|
||||
<span className="contents">
|
||||
<span
|
||||
ref={descriptionRef}
|
||||
className={cn(
|
||||
"min-w-0 truncate text-muted-foreground",
|
||||
compact && "shrink-[9999] @max-[400px]:sr-only",
|
||||
)}
|
||||
className="w-0 min-w-0 grow truncate text-muted-foreground @max-[400px]:sr-only"
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
@@ -354,17 +350,13 @@ function ComposerBannerStackAlert({
|
||||
variant={item.variant}
|
||||
density="comfortable"
|
||||
>
|
||||
<ComposerBanner.Row layout={item.compact ? "wrap-actions-narrow" : "wrap-actions"}>
|
||||
<ComposerBanner.Row layout="wrap-actions">
|
||||
<ComposerBanner.Icon className="h-(--composer-banner-icon-column) self-start">
|
||||
{item.icon}
|
||||
</ComposerBanner.Icon>
|
||||
<ComposerBanner.Content className="whitespace-nowrap">
|
||||
<span className="min-w-0 truncate font-medium leading-7 sm:leading-6">{item.title}</span>
|
||||
{item.description ? (
|
||||
<NoticeDescription compact={item.compact ?? false}>
|
||||
{item.description}
|
||||
</NoticeDescription>
|
||||
) : null}
|
||||
{item.description ? <NoticeDescription>{item.description}</NoticeDescription> : null}
|
||||
</ComposerBanner.Content>
|
||||
{item.actions || item.onDismiss ? (
|
||||
<ComposerBanner.Actions>
|
||||
|
||||
Reference in new issue
Block a user