-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pompurin404
committed
Aug 2, 2024
1 parent
e11a98b
commit ba72269
Showing
6 changed files
with
68 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Button, Card, CardBody, CardFooter, Progress } from '@nextui-org/react' | ||
import { calcPercent, calcTraffic } from '@renderer/utils/calc' | ||
import React from 'react' | ||
import { IoMdRefresh } from 'react-icons/io' | ||
|
||
interface Props { | ||
info: IProfileItem | ||
isCurrent: boolean | ||
onClick: () => void | ||
} | ||
|
||
const ProfileItem: React.FC<Props> = (props) => { | ||
const { info, onClick, isCurrent } = props | ||
const extra = info?.extra | ||
const usage = (extra?.upload ?? 0) + (extra?.download ?? 0) | ||
const total = extra?.total ?? 0 | ||
return ( | ||
<Card fullWidth isPressable onPress={onClick} className={isCurrent ? 'bg-primary' : ''}> | ||
<CardBody> | ||
<div className="flex justify-between h-[32px]"> | ||
<h3 className="select-none text-ellipsis whitespace-nowrap overflow-hidden text-md font-bold leading-[32px]"> | ||
{info?.name} | ||
</h3> | ||
<Button isIconOnly size="sm" variant="light" color="default"> | ||
<IoMdRefresh color="default" className="text-[24px]" /> | ||
</Button> | ||
</div> | ||
</CardBody> | ||
<CardFooter className="pt-1"> | ||
<Progress | ||
classNames={{ indicator: 'bg-foreground', label: 'select-none' }} | ||
label={extra ? `${calcTraffic(usage)}/${calcTraffic(total)}` : undefined} | ||
value={calcPercent(extra?.upload, extra?.download, extra?.total)} | ||
className="max-w-md" | ||
/> | ||
</CardFooter> | ||
</Card> | ||
) | ||
} | ||
|
||
export default ProfileItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters