:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
@import '../../../../frontend/src/lib/components/ProductEmptyState/previewMixins';
.WebPreview {
--web-preview-accent: var(--empty-state-accent, var(--color-primary-500));
display: flex;
flex-direction: column;
gap: 0.75rem;
// Hidden filter state. A direct child of .WebPreview so `:checked ~` reaches every card.
&__checkbox {
position: absolute;
width: 0;
height: 0;
pointer-events: none;
opacity: 0;
}
&__card {
min-width: 0;
overflow: hidden;
background: var(--color-bg-surface-primary);
border: 1px solid var(--color-border-primary);
border-radius: var(--radius);
}
// Filtered/idle pairs share one grid cell and crossfade, so filtering never shifts layout.
&__swap {
display: grid;
}
&__swap > * {
grid-area: 1 / 1;
min-width: 0;
}
&__when-filtered {
@include preview-swap-hidden;
}
&__when-idle {
@include preview-swap-visible;
}
&__head {
display: flex;
gap: 0.5rem;
align-items: center;
justify-content: space-between;
padding: 0.5rem 0.75rem;
border-bottom: 1px solid var(--color-border-primary);
}
&__title {
display: flex;
gap: 0.375rem;
align-items: center;
min-width: 0;
font-size: 0.75rem;
font-weight: 600;
}
&__live-dot {
flex-shrink: 0;
width: 7px;
height: 7px;
background: var(--web-preview-accent);
border-radius: 50%;
animation: WebPreview__pulse 2s ease-in-out infinite;
}
&__stat {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: baseline;
padding: 0.625rem 0.75rem 0;
}
&__stat-value {
font-size: 1.25rem;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
&__stat-change {
font-size: 0.625rem;
font-weight: 600;
@include preview-accent-text(var(--web-preview-accent));
}
&__chart {
padding: 0.25rem 0.75rem 0.625rem;
}
// A fixed height: a percentage does not resolve inside the swap grid's auto-height row.
&__chart svg {
display: block;
width: 100%;
height: 2.75rem;
overflow: visible;
}
&__line {
fill: none;
stroke: var(--web-preview-accent);
stroke-width: 1.5;
vector-effect: non-scaling-stroke;
}
&__area {
fill: color-mix(in oklab, var(--web-preview-accent) 18%, transparent);
}
&__columns {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
gap: 0.75rem;
}
&__rows {
display: flex;
flex-direction: column;
padding: 0.25rem 0.375rem 0.375rem;
}
&__row {
position: relative;
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 0.5rem;
align-items: center;
padding: 0.3125rem 0.5rem;
border-radius: var(--radius);
transition:
background-color 250ms ease,
opacity 250ms ease;
}
&__row--hero {
cursor: pointer;
user-select: none;
}
&__row--hero:hover {
background: var(--color-bg-fill-highlight-50);
}
&__bar {
position: absolute;
inset: 0.1875rem auto 0.1875rem 0;
background: color-mix(in oklab, var(--web-preview-accent) 14%, transparent);
border-radius: var(--radius);
}
&__bar--direct {
width: 100%;
}
&__bar--google {
width: 73%;
}
&__bar--newsletter {
width: 29%;
}
&__bar--linkedin {
width: 22%;
}
&__name {
position: relative;
overflow: hidden;
font-size: 0.6875rem;
text-overflow: ellipsis;
white-space: nowrap;
}
&__name--mono {
font-family: var(--font-mono);
}
&__count {
position: relative;
font-size: 0.625rem;
font-variant-numeric: tabular-nums;
color: var(--color-text-secondary);
}
&__hint {
font-size: 0.625rem;
color: var(--color-text-tertiary);
}
}
.WebPreview__checkbox:checked ~ * .WebPreview__when-filtered {
@include preview-swap-visible;
}
.WebPreview__checkbox:checked ~ * .WebPreview__when-idle {
@include preview-swap-hidden;
}
.WebPreview__checkbox:checked ~ .WebPreview__columns .WebPreview__row--hero {
background: color-mix(in oklab, var(--web-preview-accent) 12%, transparent);
box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--web-preview-accent) 45%, transparent);
}
// Filtering by the newsletter surfaces the page it sent people to and dims the rest.
.WebPreview__checkbox:checked
~ .WebPreview__columns
.WebPreview__row:not(.WebPreview__row--hero, .WebPreview__row--match) {
opacity: 0.35;
}
.WebPreview__checkbox:checked ~ .WebPreview__columns .WebPreview__row--match {
background: color-mix(in oklab, var(--web-preview-accent) 12%, transparent);
}
// The checkbox stays keyboard-focusable while visually hidden, so the row it labels needs a
// visible focus indicator (WCAG 2.4.7).
.WebPreview__checkbox:focus-visible ~ .WebPreview__columns .WebPreview__row--hero {
outline: 2px solid var(--web-preview-accent);
outline-offset: 1px;
}
.WebPreview:not(.WebPreview--static) .WebPreview__checkbox:not(:checked) ~ .WebPreview__columns .WebPreview__row--hero {
animation: WebPreview__nudge 2.4s ease-in-out infinite;
}
@keyframes WebPreview__nudge {
0%,
100% {
box-shadow: 0 0 0 0 color-mix(in oklab, var(--web-preview-accent) 40%, transparent);
}
50% {
box-shadow: 0 0 0 4px color-mix(in oklab, var(--web-preview-accent) 15%, transparent);
}
}
@keyframes WebPreview__pulse {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.35;
}
}
// Storybook snapshots and reduced motion drop all ambient motion; clicking the row still flips
// the state (transitions only).
@include preview-motion-guards('WebPreview');