Skip to content

Commit

Permalink
docs(suspensive.org): type guard
Browse files Browse the repository at this point in the history
  • Loading branch information
manudeli committed Nov 14, 2024
1 parent 7e92277 commit fbb937b
Showing 1 changed file with 42 additions and 39 deletions.
81 changes: 42 additions & 39 deletions docs/suspensive.org/src/components/BubbleChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const contributorsQueryOptions = () =>
c: number // Number of commits
}[]
}[]
| Record<never, never>
| undefined
}
throw new Error('Failed to fetch contributors')
Expand Down Expand Up @@ -89,8 +90,12 @@ export const BubbleChart = () => {
<Suspense clientOnly fallback={<></>}>
<SuspenseQuery {...contributorsQueryOptions()}>
{({ data }) => {
if (!data || !('filter' in data)) {
throw new Error('Failed to fetch contributors')
}

const chartData = data
?.filter(
.filter(
({ author }) =>
![
'github-actions[bot]',
Expand All @@ -105,44 +110,42 @@ export const BubbleChart = () => {
htmlUrl: author.html_url,
}))

if (chartData) {
return (
<>
<div className="flex w-[100%] items-center justify-center overflow-visible sm:hidden md:hidden lg:hidden">
<BubbleChartSize
chartData={chartData}
height={400}
width={400}
padding={2}
/>
</div>
<div className="hidden w-[100%] items-center justify-center overflow-visible sm:flex md:hidden lg:hidden">
<BubbleChartSize
chartData={chartData}
height={630}
width={630}
padding={6}
/>
</div>
<div className="hidden w-[100%] items-center justify-center overflow-visible sm:hidden md:flex lg:hidden">
<BubbleChartSize
chartData={chartData}
height={560}
width={560}
padding={4}
/>
</div>
<div className="hidden w-[100%] items-center justify-center overflow-visible sm:hidden md:hidden lg:flex">
<BubbleChartSize
chartData={chartData}
height={760}
width={760}
padding={8}
/>
</div>
</>
)
}
return (
<>
<div className="flex w-[100%] items-center justify-center overflow-visible sm:hidden md:hidden lg:hidden">
<BubbleChartSize
chartData={chartData}
height={400}
width={400}
padding={2}
/>
</div>
<div className="hidden w-[100%] items-center justify-center overflow-visible sm:flex md:hidden lg:hidden">
<BubbleChartSize
chartData={chartData}
height={630}
width={630}
padding={6}
/>
</div>
<div className="hidden w-[100%] items-center justify-center overflow-visible sm:hidden md:flex lg:hidden">
<BubbleChartSize
chartData={chartData}
height={560}
width={560}
padding={4}
/>
</div>
<div className="hidden w-[100%] items-center justify-center overflow-visible sm:hidden md:hidden lg:flex">
<BubbleChartSize
chartData={chartData}
height={760}
width={760}
padding={8}
/>
</div>
</>
)

return (
<Link href="https://github.com/toss/suspensive/graphs/contributors">
Expand Down

0 comments on commit fbb937b

Please sign in to comment.