Skip to content

Commit e005206

Browse files
Make research previews clickable cards
1 parent cb14a16 commit e005206

3 files changed

Lines changed: 76 additions & 48 deletions

File tree

‎packages/editor/src/styles.css‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@
2121
box-shadow: var(--shadow-resting);
2222
}
2323

24+
.plan-content [data-research-ready] {
25+
position: relative;
26+
box-shadow: var(--shadow-raised);
27+
transition: box-shadow var(--duration-fast) var(--ease-out);
28+
}
29+
30+
.plan-content [data-research-ready]:hover,
31+
.plan-content [data-research-ready]:focus-within {
32+
box-shadow: var(--shadow-overlay);
33+
}
34+
35+
.plan-research-open {
36+
position: absolute;
37+
z-index: 1;
38+
inset: 0;
39+
cursor: pointer;
40+
border: 0;
41+
border-radius: inherit;
42+
background: transparent;
43+
}
44+
2445
.plan-research-composer {
2546
display: grid;
2647
gap: 0.625rem;

‎packages/editor/src/widgets/research.test.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,12 @@ describe("research card", () => {
636636
expect(markup).toContain("Researched by Planner");
637637
expect(markup).toContain("Open Rollout evidence");
638638
expect(markup.match(/Open Rollout evidence/g)).toHaveLength(1);
639+
expect(markup).toContain('aria-label="Open Rollout evidence"');
640+
expect(markup).toContain('class="plan-research-open"');
641+
expect(markup).toContain('data-research-ready=""');
642+
expect(markup).not.toContain("https://example.com/releases");
643+
expect(markup).not.toContain("Remove research reference");
644+
expect(markup).not.toContain("plan-research-actions");
639645
expect(markup).not.toContain("Expand");
640646
});
641647

‎packages/editor/src/widgets/research.tsx‎

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export function ResearchCard(
226226
: undefined;
227227
let actions = researchActions(request, canEdit);
228228
return (
229-
<SidecarCard label="Research">
229+
<SidecarCard data-research-ready={ready ? "" : undefined} label="Research">
230230
<div className="plan-research-heading">
231231
<strong>{ready ? ready.title : STAGES[request.stage]}</strong>
232232
<span>{ready ? STAGES[request.stage] : request.question}</span>
@@ -241,7 +241,7 @@ export function ResearchCard(
241241
</>
242242
)}
243243
{request.error && <p className="plan-research-error" role="status">{request.error}</p>}
244-
{request.sources.length > 0 && (
244+
{!ready && request.sources.length > 0 && (
245245
<ul aria-label="Research sources" className="plan-research-sources">
246246
{request.sources.map(source => (
247247
<li key={source.url}>
@@ -251,52 +251,53 @@ export function ResearchCard(
251251
</ul>
252252
)}
253253
{actionError && <p className="plan-research-error" role="status">{actionError}</p>}
254-
<div className="plan-research-actions">
255-
{actions.cancel && onCancel && (
256-
<button
257-
aria-label="Cancel research"
258-
className="btn btn-sm btn-secondary"
259-
disabled={busy || !canEdit}
260-
onClick={onCancel}
261-
type="button"
262-
>
263-
Cancel
264-
</button>
265-
)}
266-
{actions.retry && onRetry && (
267-
<button
268-
aria-label="Retry research"
269-
className="btn btn-sm btn-secondary"
270-
disabled={busy || !canEdit}
271-
onClick={onRetry}
272-
type="button"
273-
>
274-
Retry
275-
</button>
276-
)}
277-
{actions.open && ready && onOpen && (
278-
<button
279-
className="btn btn-sm btn-primary"
280-
disabled={busy}
281-
onClick={event => onOpen(event.currentTarget)}
282-
ref={openButtonRef}
283-
type="button"
284-
>
285-
Open {ready.title}
286-
</button>
287-
)}
288-
{actions.remove && onRemove && (
289-
<button
290-
aria-label="Remove research reference"
291-
className="btn btn-sm btn-ghost"
292-
disabled={busy || !canEdit}
293-
onClick={onRemove}
294-
type="button"
295-
>
296-
Remove
297-
</button>
298-
)}
299-
</div>
254+
{!ready && (
255+
<div className="plan-research-actions">
256+
{actions.cancel && onCancel && (
257+
<button
258+
aria-label="Cancel research"
259+
className="btn btn-sm btn-secondary"
260+
disabled={busy || !canEdit}
261+
onClick={onCancel}
262+
type="button"
263+
>
264+
Cancel
265+
</button>
266+
)}
267+
{actions.retry && onRetry && (
268+
<button
269+
aria-label="Retry research"
270+
className="btn btn-sm btn-secondary"
271+
disabled={busy || !canEdit}
272+
onClick={onRetry}
273+
type="button"
274+
>
275+
Retry
276+
</button>
277+
)}
278+
{actions.remove && onRemove && (
279+
<button
280+
aria-label="Remove research reference"
281+
className="btn btn-sm btn-ghost"
282+
disabled={busy || !canEdit}
283+
onClick={onRemove}
284+
type="button"
285+
>
286+
Remove
287+
</button>
288+
)}
289+
</div>
290+
)}
291+
{actions.open && ready && onOpen && (
292+
<button
293+
aria-label={`Open ${ready.title}`}
294+
className="plan-research-open"
295+
disabled={busy}
296+
onClick={event => onOpen(event.currentTarget)}
297+
ref={openButtonRef}
298+
type="button"
299+
/>
300+
)}
300301
</SidecarCard>
301302
);
302303
}

0 commit comments

Comments
 (0)