Skip to content

Commit 4d8f845

Browse files
urmauurellipsis-dev[bot]
authored andcommitted
✨enhancement: show app size on download dropdown (#5360)
* ✨enhancement: show app size on download dropdown * Update docs/src/utils/format.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * chor: update copy --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
1 parent 4400d50 commit 4d8f845

File tree

4 files changed

+60
-8
lines changed

4 files changed

+60
-8
lines changed

docs/src/components/Download/CardDownload.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { IconType } from 'react-icons/lib'
33
import { FaWindows, FaApple, FaLinux } from 'react-icons/fa'
44
import { twMerge } from 'tailwind-merge'
55
import { DownloadIcon } from 'lucide-react'
6+
import { formatFileSize } from '@/utils/format'
67

78
type Props = {
89
lastRelease: any
@@ -14,6 +15,7 @@ type SystemType = {
1415
logo: IconType
1516
fileFormat: string
1617
href?: string
18+
size?: string
1719
}
1820

1921
const systemsTemplate: SystemType[] = [
@@ -84,9 +86,16 @@ export default function CardDownload({ lastRelease }: Props) {
8486
const downloadUrl = system.fileFormat
8587
.replace('{appname}', appname)
8688
.replace('{tag}', tag)
89+
90+
// Find the corresponding asset to get the file size
91+
const asset = lastRelease.assets.find(
92+
(asset: any) => asset.name === downloadUrl
93+
)
94+
8795
return {
8896
...system,
8997
href: `https://github.com/menloresearch/jan/releases/download/${lastRelease.tag_name}/${downloadUrl}`,
98+
size: asset ? formatFileSize(asset.size) : undefined,
9099
}
91100
})
92101

@@ -118,6 +127,11 @@ export default function CardDownload({ lastRelease }: Props) {
118127
>
119128
<span>{system.label}</span>
120129
<DownloadIcon size={16} />
130+
{system.size && (
131+
<div className="text-sm text-black/60 dark:text-white/60">
132+
{system.size}
133+
</div>
134+
)}
121135
</a>
122136
</div>
123137
))}

docs/src/components/DropdownDownload/index.tsx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { IconType } from 'react-icons/lib'
44
import { IoChevronDownOutline } from 'react-icons/io5'
55
import { useClickOutside } from '@/hooks/useClickOutside'
66
import { twMerge } from 'tailwind-merge'
7+
import { formatFileSize } from '@/utils/format'
78

89
type Props = {
910
lastRelease: any
@@ -14,6 +15,7 @@ type SystemType = {
1415
logo: IconType
1516
fileFormat: string
1617
href?: string
18+
size?: string
1719
}
1820

1921
type 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
))}

docs/src/components/Home/Feature/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const features = [
4444
{
4545
title: 'Chat with your files',
4646
experimantal: true,
47-
description: `Set up and run your own OpenAI-compatible API server using local models with just one click.`,
47+
description: `Talk to PDFs, notes, and other documents directly to get summaries, answers, or insights.`,
4848
image: {
4949
light: '/assets/images/homepage/features05.png',
5050
dark: '/assets/images/homepage/features05dark.png',

docs/src/utils/format.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
export function formatCompactNumber(count: number) {
2-
const formatter = Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 1 })
2+
const formatter = Intl.NumberFormat('en', {
3+
notation: 'compact',
4+
maximumFractionDigits: 1,
5+
})
36
return formatter.format(count)
47
}
58

9+
export function formatFileSize(bytes: number): string {
10+
if (!bytes) return '0 B'
11+
12+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
13+
const i = Math.floor(Math.log(bytes) / Math.log(1024))
14+
15+
if (i === 0) return `${bytes} ${sizes[i]}`
16+
17+
return `${(bytes / Math.pow(1024, i)).toFixed(1)} ${sizes[i]}`
18+
}
19+
620
export const totalDownload = (release: []) => {
721
if (release instanceof Array) {
822
const count = release

0 commit comments

Comments
 (0)