@@ -4,6 +4,7 @@ import { IconType } from 'react-icons/lib'
44import { IoChevronDownOutline } from 'react-icons/io5'
55import { useClickOutside } from '@/hooks/useClickOutside'
66import { twMerge } from 'tailwind-merge'
7+ import { formatFileSize } from '@/utils/format'
78
89type Props = {
910 lastRelease : any
@@ -14,6 +15,7 @@ type SystemType = {
1415 logo : IconType
1516 fileFormat : string
1617 href ?: string
18+ size ?: string
1719}
1820
1921type GpuInfo = {
@@ -130,6 +132,7 @@ const DropdownDownload = ({ lastRelease }: Props) => {
130132 const updateDownloadLinks = async ( ) => {
131133 try {
132134 const firstAssetName = await lastRelease . assets [ 0 ] ?. name
135+
133136 const appname = extractAppName ( firstAssetName )
134137 if ( ! appname ) {
135138 console . error (
@@ -147,9 +150,16 @@ const DropdownDownload = ({ lastRelease }: Props) => {
147150 const downloadUrl = system . fileFormat
148151 . replace ( '{appname}' , appname )
149152 . replace ( '{tag}' , tag )
153+
154+ // Find the corresponding asset to get the file size
155+ const asset = lastRelease . assets . find (
156+ ( asset : any ) => asset . name === downloadUrl
157+ )
158+
150159 return {
151160 ...system ,
152161 href : `https://github.com/menloresearch/jan/releases/download/${ lastRelease . tag_name } /${ downloadUrl } ` ,
162+ size : asset ? formatFileSize ( asset . size ) : undefined ,
153163 }
154164 } )
155165 setSystems ( updatedSystems )
@@ -176,10 +186,15 @@ const DropdownDownload = ({ lastRelease }: Props) => {
176186 < div className = "inline-flex flex-shrink-0 justify-center relative" >
177187 < a
178188 href = { defaultSystem . href }
179- className = "dark:border-r-0 dark:nx-bg-neutral-900 dark:text-white bg-black text-white hover:text-white justify-center dark:border dark:border-neutral-800 flex-shrink-0 pl-4 pr-6 py-4 rounded-l-xl inline-flex items-center !rounded-r-none"
189+ className = "min-w-[300px] dark:border-r-0 dark:nx-bg-neutral-900 dark:text-white bg-black text-white hover:text-white dark:border dark:border-neutral-800 flex-shrink-0 pl-4 pr-6 py-4 rounded-l-xl inline-flex items-center !rounded-r-none"
180190 >
181191 < defaultSystem . logo className = "h-4 mr-2" />
182- { defaultSystem . name }
192+ < span > { defaultSystem . name } </ span >
193+ { defaultSystem . size && (
194+ < span className = "text-white/60 text-sm ml-2" >
195+ ({ defaultSystem . size } )
196+ </ span >
197+ ) }
183198 </ a >
184199 < button
185200 className = "dark:nx-bg-neutral-900 dark:text-white bg-black text-white hover:text-white justify-center dark:border border-l border-gray-500 dark:border-neutral-800 flex-shrink-0 p-4 px-3 rounded-r-xl"
@@ -192,18 +207,27 @@ const DropdownDownload = ({ lastRelease }: Props) => {
192207 </ button >
193208 { open && (
194209 < div
195- className = "absolute left-0 top-[64px] w-full dark:nx-bg-neutral-900 bg-black z-30 rounded-xl lg:w-[300px ]"
210+ className = "absolute left-0 top-[64px] w-full dark:nx-bg-neutral-900 bg-black z-30 rounded-xl lg:w-[380px ]"
196211 ref = { setRefDropdownContent }
197212 >
198213 { systems . map ( ( system ) => (
199214 < div key = { system . name } className = "py-1" >
200215 < a
201216 href = { system . href || '' }
202- className = "flex px-4 py-3 items-center text-white hover:text-white hover:bg-white/10 dark:hover:bg-white/5"
217+ className = "flex px-4 py-3 items-center text-white hover:text-white hover:bg-white/10 dark:hover:bg-white/5 justify-between "
203218 onClick = { ( ) => setOpen ( false ) }
204219 >
205- < system . logo className = "w-3 mr-3 -mt-1 flex-shrink-0" />
206- < span className = "text-white font-medium" > { system . name } </ span >
220+ < div className = "flex items-center" >
221+ < system . logo className = "w-3 mr-3 -mt-1 flex-shrink-0" />
222+ < span className = "text-white font-medium flex-1" >
223+ { system . name }
224+ </ span >
225+ </ div >
226+ { system . size && (
227+ < span className = "text-white/60 text-sm ml-2" >
228+ { system . size }
229+ </ span >
230+ ) }
207231 </ a >
208232 </ div >
209233 ) ) }
0 commit comments