Skip to content

Commit 8d26c19

Browse files
fix(story): collapse evidence callouts
1 parent cf51e04 commit 8d26c19

2 files changed

Lines changed: 73 additions & 7 deletions

File tree

src/main.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,18 +495,24 @@ function renderStoryEvidenceCallout(container, callout) {
495495
container.hidden = !callout;
496496
if (!callout) return;
497497

498+
container.tabIndex = 0;
499+
498500
const label = document.createElement("p");
499501
label.className = "story-evidence-callout__label";
500502
label.textContent = callout.label;
501503

504+
const content = document.createElement("div");
505+
content.className = "story-evidence-callout__content";
506+
502507
const title = document.createElement("h3");
503508
title.textContent = callout.title;
504509

505510
const body = document.createElement("p");
506511
body.className = "story-evidence-callout__body";
507512
body.textContent = callout.body;
508513

509-
container.append(label, title, body);
514+
content.append(title, body);
515+
container.append(label, content);
510516

511517
if (!callout.stats?.length) return;
512518
const statList = document.createElement("div");
@@ -516,7 +522,7 @@ function renderStoryEvidenceCallout(container, callout) {
516522
badge.textContent = stat;
517523
statList.append(badge);
518524
}
519-
container.append(statList);
525+
content.append(statList);
520526
}
521527

522528
/**

src/story.css

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,12 @@
474474
right: 22px;
475475
z-index: 3;
476476
display: grid;
477-
gap: 10px;
478-
width: min(320px, calc(100% - 44px));
479-
padding: 16px;
477+
gap: 0;
478+
width: min(176px, calc(100% - 44px));
479+
max-width: min(320px, calc(100% - 44px));
480+
max-height: 48px;
481+
overflow: hidden;
482+
padding: 13px 14px 12px;
480483
border: 1px solid rgba(111, 161, 255, 0.32);
481484
border-radius: var(--radius-md);
482485
background:
@@ -487,13 +490,35 @@
487490
0 18px 50px rgba(0, 0, 0, 0.42);
488491
backdrop-filter: blur(18px) saturate(140%);
489492
-webkit-backdrop-filter: blur(18px) saturate(140%);
490-
pointer-events: none;
493+
pointer-events: auto;
494+
transition:
495+
width 240ms cubic-bezier(0.2, 0.8, 0.2, 1),
496+
max-height 240ms cubic-bezier(0.2, 0.8, 0.2, 1),
497+
padding 240ms cubic-bezier(0.2, 0.8, 0.2, 1),
498+
border-color 200ms ease,
499+
box-shadow 200ms ease;
491500
}
492501

493502
.story-evidence-callout[hidden] {
494503
display: none;
495504
}
496505

506+
.story-evidence-callout:hover,
507+
.story-evidence-callout:focus-within {
508+
width: min(320px, calc(100% - 44px));
509+
max-height: 280px;
510+
padding: 16px;
511+
border-color: rgba(111, 161, 255, 0.5);
512+
box-shadow:
513+
0 1px 0 rgba(255, 255, 255, 0.08) inset,
514+
0 24px 54px rgba(0, 0, 0, 0.46);
515+
}
516+
517+
.story-evidence-callout:focus-visible {
518+
outline: 2px solid rgba(111, 161, 255, 0.6);
519+
outline-offset: 4px;
520+
}
521+
497522
.map-tooltip {
498523
position: absolute;
499524
z-index: 6;
@@ -569,10 +594,34 @@
569594
.story-evidence-callout__label {
570595
margin: 0;
571596
color: var(--accent);
572-
font-size: 0.66rem;
597+
font-size: 0.7rem;
573598
font-weight: 850;
574599
letter-spacing: 0.16em;
575600
text-transform: uppercase;
601+
white-space: nowrap;
602+
}
603+
604+
.story-evidence-callout__content {
605+
display: grid;
606+
gap: 10px;
607+
max-height: 0;
608+
margin-top: 0;
609+
overflow: hidden;
610+
opacity: 0;
611+
transform: translateY(-8px);
612+
transition:
613+
max-height 240ms cubic-bezier(0.2, 0.8, 0.2, 1),
614+
margin-top 240ms cubic-bezier(0.2, 0.8, 0.2, 1),
615+
opacity 180ms ease,
616+
transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
617+
}
618+
619+
.story-evidence-callout:hover .story-evidence-callout__content,
620+
.story-evidence-callout:focus-within .story-evidence-callout__content {
621+
max-height: 220px;
622+
margin-top: 10px;
623+
opacity: 1;
624+
transform: translateY(0);
576625
}
577626

578627
.story-evidence-callout h3 {
@@ -697,8 +746,19 @@ footer {
697746
top: auto;
698747
right: auto;
699748
width: auto;
749+
max-width: none;
750+
max-height: none;
700751
margin: 0 18px 18px;
701752
pointer-events: auto;
753+
overflow: visible;
754+
}
755+
756+
.story-evidence-callout__content {
757+
max-height: none;
758+
margin-top: 10px;
759+
overflow: visible;
760+
opacity: 1;
761+
transform: none;
702762
}
703763

704764
.story-step {

0 commit comments

Comments
 (0)