Skip to content

Commit 69c4530

Browse files
committed
Add NPM stats page for each library
1 parent 818b0a8 commit 69c4530

File tree

17 files changed

+2601
-984
lines changed

17 files changed

+2601
-984
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ dist
2929
.content-collections
3030

3131
test-results
32+
.claude/CLAUDE.md

src/components/DocsLayout.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ const useMenuConfig = ({
378378
label: 'Contributors',
379379
to: '/$libraryId/$version/docs/contributors',
380380
},
381+
{
382+
label: 'NPM Stats',
383+
to: '/$libraryId/$version/docs/npm-stats',
384+
},
381385
...(config.sections.find((d) => d.label === 'Community Resources')
382386
? [
383387
{
@@ -471,6 +475,8 @@ export function DocsLayout({
471475

472476
const isExample = matches.some((d) => d.pathname.includes('/examples/'))
473477

478+
const isNpmStats = matches.some((d) => d.pathname.includes('/docs/npm-stats'))
479+
474480
const detailsRef = React.useRef<HTMLElement>(null!)
475481

476482
const flatMenu = React.useMemo(
@@ -750,6 +756,7 @@ export function DocsLayout({
750756
!isLandingPage && 'min-h-[88dvh] sm:min-h-0',
751757
!isLandingPage &&
752758
!isExample &&
759+
!isNpmStats &&
753760
!isFullWidth &&
754761
'mx-auto w-[900px]',
755762
)}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import * as React from 'react'
2+
import { HexColorPicker } from 'react-colorful'
3+
4+
export interface ColorPickerPopoverProps {
5+
packageName: string
6+
position: { x: number; y: number }
7+
currentColor: string
8+
onColorChange: (packageName: string, color: string) => void
9+
onReset: (packageName: string) => void
10+
onClose: () => void
11+
}
12+
13+
/**
14+
* A popover component for picking package colors.
15+
* Shows a hex color picker with Reset and Done buttons.
16+
*/
17+
export function ColorPickerPopover({
18+
packageName,
19+
position,
20+
currentColor,
21+
onColorChange,
22+
onReset,
23+
onClose,
24+
}: ColorPickerPopoverProps) {
25+
return (
26+
<div
27+
className="fixed z-50 bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2"
28+
style={{
29+
left: position.x,
30+
top: position.y,
31+
}}
32+
>
33+
<div className="flex justify-between items-center mb-2">
34+
<span className="text-sm font-medium">Pick a color</span>
35+
</div>
36+
<HexColorPicker
37+
color={currentColor}
38+
onChange={(color: string) => onColorChange(packageName, color)}
39+
/>
40+
<div className="flex justify-between mt-2">
41+
<button
42+
onClick={() => {
43+
onReset(packageName)
44+
onClose()
45+
}}
46+
className="px-2 py-1 text-sm text-gray-500 hover:text-red-500"
47+
>
48+
Reset
49+
</button>
50+
<button
51+
onClick={onClose}
52+
className="px-2 py-1 text-sm text-blue-500 hover:text-blue-600"
53+
>
54+
Done
55+
</button>
56+
</div>
57+
</div>
58+
)
59+
}

0 commit comments

Comments
 (0)