1- import { Card } from '@douglasneuroinformatics/libui/components' ;
1+ import { Card , Heading , Tooltip } from '@douglasneuroinformatics/libui/components' ;
22import { useTranslation } from '@douglasneuroinformatics/libui/hooks' ;
3+ import type { Language } from '@douglasneuroinformatics/libui/i18n' ;
4+ import { licenses } from '@opendatacapture/licenses' ;
35import { InstrumentIcon } from '@opendatacapture/react-core' ;
46import type { UnilingualInstrumentInfo } from '@opendatacapture/schemas/instrument' ;
7+ import { BadgeAlertIcon , BadgeCheckIcon } from 'lucide-react' ;
58
69export type InstrumentCardProps = {
7- instrument : UnilingualInstrumentInfo ;
10+ instrument : UnilingualInstrumentInfo & {
11+ supportedLanguages : Language [ ] ;
12+ } ;
813 onClick : ( ) => void ;
914} ;
1015
1116export const InstrumentCard = ( { instrument, onClick } : InstrumentCardProps ) => {
1217 const { t } = useTranslation ( ) ;
1318
19+ const license = licenses . get ( instrument . details . license ) ;
20+
1421 return (
1522 < Card
1623 className = "relative flex flex-col p-8 transition-all duration-300 ease-in-out hover:scale-[1.03] hover:cursor-pointer sm:flex-row"
@@ -23,15 +30,106 @@ export const InstrumentCard = ({ instrument, onClick }: InstrumentCardProps) =>
2330 < InstrumentIcon className = "rounded-full" kind = { instrument . kind } style = { { height : 'auto' , width : '32px' } } />
2431 </ div >
2532 < div className = "flex-grow" >
26- < h3
33+ < Heading
2734 className = "title-font mb-0.5 font-semibold text-slate-900 dark:text-slate-100"
2835 data-cy = "instrument-card-title"
36+ variant = "h4"
2937 >
3038 { instrument . details . title }
31- </ h3 >
32- < h5 className = "mb-2 text-sm text-slate-700 dark:text-slate-300" data-cy = "instrument-card-tags" >
33- { `${ t ( 'core.tags' ) } : ${ instrument . tags . join ( ', ' ) } ` }
34- </ h5 >
39+ </ Heading >
40+ < div className = "text-muted-foreground mb-2 flex flex-col text-sm" >
41+ { instrument . details . authors && (
42+ < span > { `${ t ( { en : 'Authors:' , fr : 'Auteurs :' } ) } ${ instrument . details . authors . join ( ', ' ) } ` } </ span >
43+ ) }
44+ < span data-cy = "instrument-card-tags" >
45+ { `${ t ( { en : 'Tags:' , fr : 'Tags :' } ) } ${ instrument . tags . join ( ', ' ) } ` }
46+ </ span >
47+ < span >
48+ { `${ t ( {
49+ en : 'Supported Languages: ' ,
50+ fr : 'Langues disponibles :'
51+ } ) } ${ instrument . supportedLanguages
52+ . map ( ( language ) => {
53+ switch ( language ) {
54+ case 'en' :
55+ return 'English' ;
56+ case 'fr' :
57+ return 'Français' ;
58+ }
59+ } )
60+ . join ( ', ' ) } `}
61+ </ span >
62+ < div className = "flex items-center" >
63+ < span className = "text-muted-foreground text-sm" >
64+ { t ( {
65+ en : 'License: ' ,
66+ fr : 'Licence : '
67+ } ) + ( license ?. name ?? 'NA' ) }
68+ </ span >
69+
70+ < Tooltip >
71+ < Tooltip . Trigger className = "p-1" size = "icon" variant = "ghost" >
72+ { license ?. isOpenSource ? (
73+ < BadgeCheckIcon className = "fill-green-600 stroke-white" />
74+ ) : (
75+ < BadgeAlertIcon className = "fill-red-600 stroke-white" />
76+ ) }
77+ </ Tooltip . Trigger >
78+ < Tooltip . Content >
79+ < p >
80+ { license ?. isOpenSource
81+ ? t ( {
82+ en : 'This is a free and open-source license' ,
83+ fr : "Il s'agit d'une licence libre"
84+ } )
85+ : t ( {
86+ en : 'This is not a free and open source license' ,
87+ fr : "Il ne s'agit pas d'une licence libre"
88+ } ) }
89+ </ p >
90+ </ Tooltip . Content >
91+ </ Tooltip >
92+ </ div >
93+ { instrument . details . referenceUrl && (
94+ < div className = "flex items-center" >
95+ < span >
96+ { t ( {
97+ en : 'Reference Link: ' ,
98+ fr : 'Lien vers la référence : '
99+ } ) }
100+ </ span >
101+
102+ < a
103+ className = "text-muted-foreground hover:text-foreground text-sm underline underline-offset-1"
104+ href = { instrument . details . referenceUrl }
105+ rel = "noopener noreferrer"
106+ target = "_blank"
107+ >
108+ { instrument . details . referenceUrl }
109+ </ a >
110+ </ div >
111+ ) }
112+ { instrument . details . sourceUrl && (
113+ < div className = "flex items-center" >
114+ < span >
115+ { t ( {
116+ en : 'Source Link' ,
117+ fr : 'Lien vers le code source'
118+ } ) }
119+ </ span >
120+
121+ < a
122+ className = "text-muted-foreground hover:text-foreground text-sm underline underline-offset-1"
123+ href = { instrument . details . sourceUrl }
124+ rel = "noopener noreferrer"
125+ target = "_blank"
126+ >
127+ { instrument . details . sourceUrl }
128+ </ a >
129+ </ div >
130+ ) }
131+ </ div >
132+ < div className = "flex items-center" > </ div >
35133 < p className = "text-sm leading-relaxed text-slate-700 dark:text-slate-300" > { instrument . details . description } </ p >
36134 </ div >
37135 </ Card >
0 commit comments