fix: align table headers with row data using CSS grid
- Switch FrustrationTable from flex to grid columns so headers and row cells share the same column widths - Replace bar chart with pie chart for frustration trend - Remove Card wrapper borders, footer line, and total signals text - Change dead clicks color from yellow to darker orange
This commit is contained in:
@@ -65,6 +65,9 @@ function SelectorCell({ selector }: { selector: string }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GRID_WITH_AVG = 'grid grid-cols-[1fr_60px_50px_64px_64px_40px] items-center gap-2 h-9 px-2 -mx-2'
|
||||||
|
const GRID_NO_AVG = 'grid grid-cols-[1fr_60px_64px_64px_40px] items-center gap-2 h-9 px-2 -mx-2'
|
||||||
|
|
||||||
function Row({
|
function Row({
|
||||||
item,
|
item,
|
||||||
showAvgClicks,
|
showAvgClicks,
|
||||||
@@ -73,32 +76,30 @@ function Row({
|
|||||||
showAvgClicks?: boolean
|
showAvgClicks?: boolean
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-between h-9 group hover:bg-neutral-50 dark:hover:bg-neutral-800 rounded-lg px-2 -mx-2 transition-colors">
|
<div className={`${showAvgClicks ? GRID_WITH_AVG : GRID_NO_AVG} group hover:bg-neutral-50 dark:hover:bg-neutral-800 rounded-lg transition-colors`}>
|
||||||
<div className="flex items-center gap-3 flex-1 min-w-0">
|
<div className="flex items-center gap-2 min-w-0">
|
||||||
<SelectorCell selector={item.selector} />
|
<SelectorCell selector={item.selector} />
|
||||||
<span
|
<span
|
||||||
className="text-xs text-neutral-400 dark:text-neutral-500 truncate max-w-[120px]"
|
className="text-xs text-neutral-400 dark:text-neutral-500 truncate"
|
||||||
title={item.page_path}
|
title={item.page_path}
|
||||||
>
|
>
|
||||||
{item.page_path}
|
{item.page_path}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-4 ml-4 shrink-0">
|
{showAvgClicks && (
|
||||||
{showAvgClicks && item.avg_click_count != null && (
|
<span className="text-xs text-neutral-400 dark:text-neutral-500 tabular-nums text-right">
|
||||||
<span className="text-xs text-neutral-400 dark:text-neutral-500 tabular-nums">
|
{item.avg_click_count != null ? item.avg_click_count.toFixed(1) : '–'}
|
||||||
avg {item.avg_click_count.toFixed(1)}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<span className="text-xs text-neutral-400 dark:text-neutral-500 tabular-nums">
|
|
||||||
{item.sessions} {item.sessions === 1 ? 'session' : 'sessions'}
|
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-neutral-400 dark:text-neutral-500 tabular-nums" title={item.last_seen}>
|
)}
|
||||||
{formatRelativeTime(item.last_seen)}
|
<span className="text-xs text-neutral-400 dark:text-neutral-500 tabular-nums text-right">
|
||||||
</span>
|
{item.sessions}
|
||||||
<span className="text-sm font-semibold text-neutral-600 dark:text-neutral-400 tabular-nums">
|
</span>
|
||||||
{formatNumber(item.count)}
|
<span className="text-xs text-neutral-400 dark:text-neutral-500 tabular-nums text-right" title={item.last_seen}>
|
||||||
</span>
|
{formatRelativeTime(item.last_seen)}
|
||||||
</div>
|
</span>
|
||||||
|
<span className="text-sm font-semibold text-neutral-600 dark:text-neutral-400 tabular-nums text-right">
|
||||||
|
{formatNumber(item.count)}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -166,17 +167,12 @@ export default function FrustrationTable({
|
|||||||
) : hasData ? (
|
) : hasData ? (
|
||||||
<div>
|
<div>
|
||||||
{/* Column headers */}
|
{/* Column headers */}
|
||||||
<div className="flex items-center justify-between px-2 -mx-2 mb-2 text-xs font-medium text-neutral-400 dark:text-neutral-500 uppercase tracking-wider">
|
<div className={`${showAvgClicks ? GRID_WITH_AVG : GRID_NO_AVG} mb-2 text-xs font-medium text-neutral-400 dark:text-neutral-500 uppercase tracking-wider !h-auto`}>
|
||||||
<div className="flex items-center gap-3">
|
<span>Selector / Page</span>
|
||||||
<span>Selector</span>
|
{showAvgClicks && <span className="text-right">Avg</span>}
|
||||||
<span>Page</span>
|
<span className="text-right">Sessions</span>
|
||||||
</div>
|
<span className="text-right">Last Seen</span>
|
||||||
<div className="flex items-center gap-4">
|
<span className="text-right">Count</span>
|
||||||
{showAvgClicks && <span>Avg</span>}
|
|
||||||
<span>Sessions</span>
|
|
||||||
<span>Last Seen</span>
|
|
||||||
<span>Count</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-0.5">
|
<div className="space-y-0.5">
|
||||||
{items.map((item, i) => (
|
{items.map((item, i) => (
|
||||||
|
|||||||
@@ -3,14 +3,6 @@
|
|||||||
import { TrendUp } from '@phosphor-icons/react'
|
import { TrendUp } from '@phosphor-icons/react'
|
||||||
import { Pie, PieChart } from 'recharts'
|
import { Pie, PieChart } from 'recharts'
|
||||||
|
|
||||||
import {
|
|
||||||
Card,
|
|
||||||
CardContent,
|
|
||||||
CardDescription,
|
|
||||||
CardFooter,
|
|
||||||
CardHeader,
|
|
||||||
CardTitle,
|
|
||||||
} from '@/components/ui/card'
|
|
||||||
import {
|
import {
|
||||||
ChartContainer,
|
ChartContainer,
|
||||||
ChartTooltip,
|
ChartTooltip,
|
||||||
@@ -48,7 +40,7 @@ const chartConfig = {
|
|||||||
},
|
},
|
||||||
dead_clicks: {
|
dead_clicks: {
|
||||||
label: 'Dead Clicks',
|
label: 'Dead Clicks',
|
||||||
color: '#F59E0B',
|
color: '#E04E0A',
|
||||||
},
|
},
|
||||||
prev_rage_clicks: {
|
prev_rage_clicks: {
|
||||||
label: 'Prev Rage Clicks',
|
label: 'Prev Rage Clicks',
|
||||||
@@ -106,12 +98,17 @@ export default function FrustrationTrend({ summary, loading }: FrustrationTrendP
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="flex flex-col h-full">
|
<div className="bg-white dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-2xl p-6 h-full flex flex-col">
|
||||||
<CardHeader className="items-center pb-0">
|
<div className="flex items-center justify-between mb-1">
|
||||||
<CardTitle>Frustration Trend</CardTitle>
|
<h3 className="text-lg font-semibold text-neutral-900 dark:text-white">
|
||||||
<CardDescription>Current vs. previous period</CardDescription>
|
Frustration Trend
|
||||||
</CardHeader>
|
</h3>
|
||||||
<CardContent className="flex-1 pb-0">
|
</div>
|
||||||
|
<p className="text-sm text-neutral-500 dark:text-neutral-400 mb-4">
|
||||||
|
Rage and dead clicks split across current and previous period
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="flex-1">
|
||||||
<ChartContainer
|
<ChartContainer
|
||||||
config={chartConfig}
|
config={chartConfig}
|
||||||
className="mx-auto aspect-square max-h-[250px]"
|
className="mx-auto aspect-square max-h-[250px]"
|
||||||
@@ -129,25 +126,21 @@ export default function FrustrationTrend({ summary, loading }: FrustrationTrendP
|
|||||||
/>
|
/>
|
||||||
</PieChart>
|
</PieChart>
|
||||||
</ChartContainer>
|
</ChartContainer>
|
||||||
</CardContent>
|
</div>
|
||||||
<CardFooter className="flex-col gap-2 text-sm">
|
|
||||||
<div className="flex items-center gap-2 leading-none font-medium">
|
<div className="flex items-center justify-center gap-2 text-sm font-medium pt-2">
|
||||||
{totalChange !== null ? (
|
{totalChange !== null ? (
|
||||||
<>
|
<>
|
||||||
{totalChange > 0 ? 'Up' : totalChange < 0 ? 'Down' : 'No change'} by {Math.abs(totalChange)}% vs previous period <TrendUp className="h-4 w-4" />
|
{totalChange > 0 ? 'Up' : totalChange < 0 ? 'Down' : 'No change'} by {Math.abs(totalChange)}% vs previous period <TrendUp className="h-4 w-4" />
|
||||||
</>
|
</>
|
||||||
) : totalCurrent > 0 ? (
|
) : totalCurrent > 0 ? (
|
||||||
<>
|
<>
|
||||||
{totalCurrent.toLocaleString()} new signals this period <TrendUp className="h-4 w-4" />
|
{totalCurrent.toLocaleString()} new signals this period <TrendUp className="h-4 w-4" />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
'No frustration signals detected'
|
'No frustration signals detected'
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="leading-none text-muted-foreground">
|
</div>
|
||||||
{totalCurrent.toLocaleString()} total signals in current period
|
|
||||||
</div>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user