Skip to content

Commit 6b0cbb5

Browse files
committed
fix: polish metric and bar chart layouts
1 parent 77b0bbe commit 6b0cbb5

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/components/BlockRenderer.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,18 @@ export function BlockRenderer({
180180
if (block.kind === "metric-group") {
181181
return (
182182
<Panel block={block} className="bg-card/80" emphasized={emphasized} layout={layout}>
183-
<div
184-
className="grid gap-px overflow-hidden rounded-lg bg-border"
185-
style={{ gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 13rem), 1fr))" }}
186-
>
183+
<div className="grid gap-2" style={{ gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 11rem), 1fr))" }}>
187184
{block.metrics.map((metric) => (
188-
<div className="group min-w-0 bg-card px-4 py-3 transition-colors hover:bg-accent/45" key={metric.label}>
185+
<div
186+
className="group min-w-0 rounded-lg border border-border bg-card px-4 py-3 transition-colors hover:bg-accent/45"
187+
key={metric.label}
188+
>
189189
<div className="mb-2 flex items-center gap-2 text-xs font-medium text-muted-foreground">
190190
<span aria-hidden="true" className={cn("size-1.5 rounded-full", toneDot[metric.tone || "neutral"])} />
191191
{metric.label}
192192
</div>
193193
<div className="flex min-w-0 items-end gap-2">
194-
<span className="min-w-0 break-words text-[clamp(1.25rem,2vw,1.5rem)] font-semibold leading-tight tracking-tight tabular-nums">
194+
<span className="min-w-0 break-words text-[clamp(1rem,1.5vw,1.25rem)] font-semibold leading-tight tracking-tight tabular-nums">
195195
{formatValue(metric.value, metric.format, instance)}
196196
{metric.unit ? <span className="ml-1 text-sm font-medium text-muted-foreground">{metric.unit}</span> : null}
197197
</span>

src/components/ChartVisual.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ function barDomain(values: number[]) {
5353
const max = Math.max(...values, 0)
5454
if (min === max) return { min: min - 1, max: max + 1 }
5555
const padding = (max - min) * 0.08
56-
return { min: Math.min(0, min - padding), max: Math.max(0, max + padding) }
56+
return {
57+
min: min >= 0 ? 0 : min - padding,
58+
max: max <= 0 ? 0 : max + padding,
59+
}
5760
}
5861

5962
function yPosition(value: number, min: number, max: number) {

0 commit comments

Comments
 (0)