Skip to content

Commit 5f2eeb7

Browse files
committed
chore: Rework version adoption calculation
1 parent f5b72ab commit 5f2eeb7

File tree

6 files changed

+164
-225
lines changed

6 files changed

+164
-225
lines changed

packages/docs/src/app/(pages)/stats/_components/version-adoption.tsx

-129
This file was deleted.

packages/docs/src/app/(pages)/stats/_components/versions.tsx

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
'use client'
22

3-
import { LineChart } from '@tremor/react'
3+
import { LineChart, Tab, TabGroup, TabList } from '@tremor/react'
44
import { Boxes } from 'lucide-react'
5+
import { useQueryState } from 'nuqs'
56
import { formatStatNumber } from '../lib/format'
7+
import { pkgOptions, pkgParser } from '../searchParams'
68
import { Widget } from './widget'
79

810
type VersionProps = {
@@ -25,13 +27,30 @@ type VersionProps = {
2527
// stroke-purple-500 fill-purple-500 bg-purple-500 text-purple-500
2628

2729
export function Versions({ records, versions }: VersionProps) {
30+
const [activeTab, setActiveTab] = useQueryState(
31+
'pkg',
32+
pkgParser.withOptions({
33+
shallow: false
34+
})
35+
)
2836
return (
2937
<Widget
3038
className="lg:col-span-2"
3139
title={
3240
<>
3341
<Boxes size={24} strokeWidth={1.5} />
3442
Version adoption
43+
<TabGroup
44+
className="ml-auto w-auto"
45+
index={pkgOptions.indexOf(activeTab)}
46+
onIndexChange={index => setActiveTab(pkgOptions[index])}
47+
>
48+
<TabList variant="solid">
49+
<Tab>nuqs</Tab>
50+
<Tab>next-usequerystate</Tab>
51+
<Tab>combined</Tab>
52+
</TabList>
53+
</TabGroup>
3554
</>
3655
}
3756
>

packages/docs/src/app/(pages)/stats/_components/widget.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export function Widget({
1717
className={cn('px-4 py-0 pb-2 pt-4 dark:bg-background', className)}
1818
{...props}
1919
>
20-
<h3 className="flex items-center gap-2 text-lg font-bold">{title}</h3>
20+
<h3 className="flex flex-wrap items-center gap-2 text-lg font-bold">
21+
{title}
22+
</h3>
2123
{children}
2224
</Card>
2325
)

0 commit comments

Comments
 (0)