From ff371eef8d29c7f42dfb67c56277252aa3f87fe0 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Sat, 14 Dec 2024 21:13:24 +0530 Subject: [PATCH] add compact variant to upload card --- .../components/upload-card/UploadCard.css.ts | 5 ++++ src/app/components/upload-card/UploadCard.tsx | 29 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/app/components/upload-card/UploadCard.css.ts b/src/app/components/upload-card/UploadCard.css.ts index bfe2e091..ad3caf10 100644 --- a/src/app/components/upload-card/UploadCard.css.ts +++ b/src/app/components/upload-card/UploadCard.css.ts @@ -17,6 +17,11 @@ export const UploadCard = recipe({ borderWidth: config.borderWidth.B300, }, }, + compact: { + true: { + padding: config.space.S100, + }, + }, }, defaultVariants: { radii: '400', diff --git a/src/app/components/upload-card/UploadCard.tsx b/src/app/components/upload-card/UploadCard.tsx index cf91435a..1e2edb96 100644 --- a/src/app/components/upload-card/UploadCard.tsx +++ b/src/app/components/upload-card/UploadCard.tsx @@ -12,8 +12,13 @@ type UploadCardProps = { }; export const UploadCard = forwardRef( - ({ before, after, children, bottom, radii, outlined }, ref) => ( - + ({ before, after, children, bottom, radii, outlined, compact }, ref) => ( + {before} @@ -33,7 +38,7 @@ type UploadCardProgressProps = { export function UploadCardProgress({ sentBytes, totalBytes }: UploadCardProgressProps) { return ( - + @@ -49,6 +54,24 @@ export function UploadCardProgress({ sentBytes, totalBytes }: UploadCardProgress ); } +export function CompactUploadCardProgress({ sentBytes, totalBytes }: UploadCardProgressProps) { + return ( + + + {`${Math.round(percent(0, totalBytes, sentBytes))}%`} + + + + + + + {bytesToSize(sentBytes)} / {bytesToSize(totalBytes)} + + + + ); +} + type UploadCardErrorProps = { children: ReactNode; };