Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 35 additions & 18 deletions packages/@react-spectrum/ai/src/ResponseStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import {AriaLabelingProps, DOMProps, DOMRef, GlobalDOMAttributes} from '@react-types/shared';
import {
baseColor,
css,
focusRing,
iconStyle,
space,
Expand Down Expand Up @@ -158,12 +159,11 @@ const buttonStyles = style({
}
},
display: 'flex',
flexGrow: 1,
flexGrow: 0,
alignItems: 'center',
paddingX: 'calc(self(minHeight) * 3/8 - 1px)',
gap: 'calc(self(minHeight) * 3/8 - 1px)',
minHeight: 32,
width: 'full',
backgroundColor: 'transparent',
transition: 'default',
borderWidth: 0,
Expand Down Expand Up @@ -282,15 +282,15 @@ export interface ResponseStatusPanelProps
styles?: StyleString;
}

const panelStyles = style({
const panelStyle = {
font: 'body',
height: '--disclosure-panel-height',
overflow: 'clip',
transition: {
default: '[height]',
'@media (prefers-reduced-motion: reduce)': 'none'
}
});
} as const;

const panelInner = style({
paddingTop: 8,
Expand All @@ -317,7 +317,10 @@ export const ResponseStatusPanel = forwardRef(function ResponseStatusPanel(
}, [registerPanel]);

return (
<RACDisclosurePanel {...domProps} ref={panelRef} className={mergeStyles(panelStyles, styles)}>
<RACDisclosurePanel
{...domProps}
ref={panelRef}
className={mergeStyles(style(panelStyle), styles)}>
<div className={panelInner}>{props.children}</div>
</RACDisclosurePanel>
);
Expand Down Expand Up @@ -386,7 +389,9 @@ function DetailTrigger(props: DetailTriggerProps) {

return (
<Button
className={renderProps => mergeStyles(buttonStyles({...renderProps}), detailTriggerStyles)}
className={renderProps =>
mergeStyles(buttonStyles({...renderProps}), detailTriggerStyles) + ' ' + textSizeAdjust
}
slot="trigger">
{children}
<CenterBaseline styles={detailTriggerChevronStyles({isExpanded, isRTL})}>
Expand Down Expand Up @@ -447,19 +452,29 @@ const executionTraceItemDividerStyles = style({
display: 'var(--divider-display, flex)'
});

const executionTraceItemBaseStyles = {
paddingBottom: 12,
const executionTraceDisclosurePanelStyles = style({
...panelStyle,
paddingStart: 8
} as const;
});

const executionTraceDisclosureContainerStyles = style({
paddingBottom: 12,
marginTop: -4

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could get rid of this negative margin if we changed the item to display as a grid

template areas
[['icon', 'button'],
 ['line', 'content']]

then we could center baseline the icon vertically in it's cell, which would be the same height as the text, even if the text were to wrap (don't know if that's a thing)

the line would just have stretch set

I think this would also help with eventual changes to font size or tshirt size

});

const executionTraceWithoutDisclosureStyles = style({
...executionTraceItemBaseStyles,
paddingStart: 8,
display: 'flex',
flexDirection: 'column',
minHeight: 24
});

const executionTraceDetailPanelStyles = style(executionTraceItemBaseStyles);
// Prevents Mobile Safari from auto-inflating the font size of wrapping text
// blocks ("font boosting") when the user changes their text size setting.
const textSizeAdjust = css(`
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
`);

/**
* An ExecutionTraceItem represents a single step within an ExecutionTrace, such as
Expand Down Expand Up @@ -490,15 +505,17 @@ export const ExecutionTraceItem = forwardRef(function ExecutionTraceItem(
<div role="presentation" className={executionTraceItemDividerStyles} />
</div>
{hasDetail && !isAlwaysOpen ? (
<RACDisclosure>
<DetailTrigger>{children}</DetailTrigger>
<RACDisclosurePanel className={mergeStyles(panelStyles, executionTraceDetailPanelStyles)}>
{detail}
</RACDisclosurePanel>
</RACDisclosure>
<div className={executionTraceDisclosureContainerStyles}>
<RACDisclosure>
<DetailTrigger>{children}</DetailTrigger>
<RACDisclosurePanel className={executionTraceDisclosurePanelStyles}>
{detail}
</RACDisclosurePanel>
</RACDisclosure>
</div>
) : (
<div className={executionTraceWithoutDisclosureStyles}>
<span>{children}</span>
<span className={textSizeAdjust}>{children}</span>
{hasDetail && isAlwaysOpen ? <div>{detail}</div> : null}
</div>
)}
Expand Down