Skip to content

Commit c055dbb

Browse files
authored
refactor: update package header component to improve private/public badge display (#1160)
1 parent b9f02cc commit c055dbb

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

src/components/ViewPackagePage/components/package-header.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import React, { useEffect } from "react"
1+
import { useEffect } from "react"
22
import { Link } from "wouter"
3-
4-
import { TypeBadge } from "@/components/TypeBadge"
53
import { Button } from "@/components/ui/button"
64
import { Skeleton } from "@/components/ui/skeleton"
75
import {
@@ -10,7 +8,7 @@ import {
108
TooltipProvider,
119
TooltipTrigger,
1210
} from "@/components/ui/tooltip"
13-
import { LockClosedIcon } from "@radix-ui/react-icons"
11+
import { Lock, Globe } from "lucide-react"
1412
import { GitFork, Package, Star } from "lucide-react"
1513

1614
import { useForkPackageMutation } from "@/hooks/use-fork-package-mutation"
@@ -106,13 +104,25 @@ export default function PackageHeader({
106104
{packageName}
107105
</Link>
108106
</h1>
109-
{packageInfo?.name && <TypeBadge type="package" />}
110-
{isPrivate && (
111-
<div className="relative group pl-2">
112-
<LockClosedIcon className="h-4 w-4 text-gray-700" />
113-
<span className="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-1 hidden group-hover:block bg-black text-white text-xs rounded py-1 px-2">
114-
private
115-
</span>
107+
{packageInfo?.name && (
108+
<div
109+
className={`select-none inline-flex items-center px-2 py-1 rounded text-xs font-medium ${
110+
isPrivate
111+
? "bg-gray-100 text-gray-700 border border-gray-200"
112+
: "bg-blue-50 text-blue-700 border border-blue-200"
113+
}`}
114+
>
115+
{isPrivate ? (
116+
<>
117+
<Lock className="w-3 h-3 mr-1 flex-shrink-0" />
118+
<span className="leading-none">Private</span>
119+
</>
120+
) : (
121+
<>
122+
<Globe className="w-3 h-3 mr-1 flex-shrink-0" />
123+
<span className="leading-none">Public</span>
124+
</>
125+
)}
116126
</div>
117127
)}
118128
</>

0 commit comments

Comments
 (0)