@@ -2,6 +2,7 @@ import { useMemo } from 'react'
22import { useTranslation } from 'react-i18next'
33import { Check , Copy } from 'lucide-react'
44import { Button } from '@/shared/ui/button'
5+ import { Tabs , TabsContent , TabsList , TabsTrigger } from '@/shared/ui/tabs'
56import { useCopyToClipboard } from '@/shared/lib/clipboard'
67
78interface InstallCommandProps {
@@ -33,13 +34,21 @@ export function buildInstallCommand(namespace: string, slug: string, baseUrl: st
3334 return `npx clawhub install ${ installTarget } --registry ${ baseUrl } `
3435}
3536
36- export function InstallCommand ( { namespace, slug } : InstallCommandProps ) {
37- const { t } = useTranslation ( )
38- const [ copied , copy ] = useCopyToClipboard ( )
37+ export function buildSkillhubInstallCommand ( namespace : string , slug : string , baseUrl : string ) : string {
38+ const namespaceArg = namespace === 'global' ? '' : ` --namespace ${ namespace } `
39+ return `npx @astron-team/skillhub@latest install ${ slug } ${ namespaceArg } --registry ${ baseUrl } `
40+ }
3941
40- const baseUrl = useMemo ( ( ) => getBaseUrl ( ) , [ ] )
42+ interface CommandBlockProps {
43+ command : string
44+ }
45+
46+ const installMethodTabTriggerClass =
47+ "relative border-b-0 px-1 py-2 text-xs after:absolute after:bottom-[-1px] after:left-1/2 after:h-0.5 after:w-6 after:-translate-x-1/2 after:rounded-full after:bg-transparent after:content-[''] data-[state=active]:after:bg-primary"
4148
42- const command = useMemo ( ( ) => buildInstallCommand ( namespace , slug , baseUrl ) , [ baseUrl , namespace , slug ] )
49+ function CommandBlock ( { command } : CommandBlockProps ) {
50+ const { t } = useTranslation ( )
51+ const [ copied , copy ] = useCopyToClipboard ( )
4352
4453 const handleCopy = async ( ) => {
4554 try {
@@ -70,3 +79,29 @@ export function InstallCommand({ namespace, slug }: InstallCommandProps) {
7079 </ div >
7180 )
7281}
82+
83+ export function InstallCommand ( { namespace, slug } : InstallCommandProps ) {
84+ const { t } = useTranslation ( )
85+ const baseUrl = useMemo ( ( ) => getBaseUrl ( ) , [ ] )
86+ const clawhubCommand = useMemo ( ( ) => buildInstallCommand ( namespace , slug , baseUrl ) , [ baseUrl , namespace , slug ] )
87+ const skillhubCommand = useMemo ( ( ) => buildSkillhubInstallCommand ( namespace , slug , baseUrl ) , [ baseUrl , namespace , slug ] )
88+
89+ return (
90+ < Tabs defaultValue = "clawhub" className = "space-y-3" >
91+ < TabsList className = "w-full gap-6 border-border/70 bg-transparent p-0 text-xs" >
92+ < TabsTrigger value = "clawhub" className = { installMethodTabTriggerClass } >
93+ { t ( 'skillDetail.installMethodClawhub' ) }
94+ </ TabsTrigger >
95+ < TabsTrigger value = "skillhub" className = { installMethodTabTriggerClass } >
96+ { t ( 'skillDetail.installMethodSkillhub' ) }
97+ </ TabsTrigger >
98+ </ TabsList >
99+ < TabsContent value = "clawhub" >
100+ < CommandBlock command = { clawhubCommand } />
101+ </ TabsContent >
102+ < TabsContent value = "skillhub" >
103+ < CommandBlock command = { skillhubCommand } />
104+ </ TabsContent >
105+ </ Tabs >
106+ )
107+ }
0 commit comments