mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-02-12 08:43:38 +01:00
add compact variant to upload card
This commit is contained in:
parent
fa199dfeae
commit
ff371eef8d
2 changed files with 31 additions and 3 deletions
|
@ -17,6 +17,11 @@ export const UploadCard = recipe({
|
|||
borderWidth: config.borderWidth.B300,
|
||||
},
|
||||
},
|
||||
compact: {
|
||||
true: {
|
||||
padding: config.space.S100,
|
||||
},
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
radii: '400',
|
||||
|
|
|
@ -12,8 +12,13 @@ type UploadCardProps = {
|
|||
};
|
||||
|
||||
export const UploadCard = forwardRef<HTMLDivElement, UploadCardProps & css.UploadCardVariant>(
|
||||
({ before, after, children, bottom, radii, outlined }, ref) => (
|
||||
<Box className={css.UploadCard({ radii, outlined })} direction="Column" gap="200" ref={ref}>
|
||||
({ before, after, children, bottom, radii, outlined, compact }, ref) => (
|
||||
<Box
|
||||
className={css.UploadCard({ radii, outlined, compact })}
|
||||
direction="Column"
|
||||
gap="200"
|
||||
ref={ref}
|
||||
>
|
||||
<Box alignItems="Center" gap="200">
|
||||
{before}
|
||||
<Box alignItems="Center" grow="Yes" gap="200">
|
||||
|
@ -33,7 +38,7 @@ type UploadCardProgressProps = {
|
|||
|
||||
export function UploadCardProgress({ sentBytes, totalBytes }: UploadCardProgressProps) {
|
||||
return (
|
||||
<Box direction="Column" gap="200">
|
||||
<Box grow="Yes" direction="Column" gap="200">
|
||||
<ProgressBar variant="Secondary" size="300" min={0} max={totalBytes} value={sentBytes} />
|
||||
<Box alignItems="Center" justifyContent="SpaceBetween">
|
||||
<Badge variant="Secondary" fill="Solid" radii="Pill">
|
||||
|
@ -49,6 +54,24 @@ export function UploadCardProgress({ sentBytes, totalBytes }: UploadCardProgress
|
|||
);
|
||||
}
|
||||
|
||||
export function CompactUploadCardProgress({ sentBytes, totalBytes }: UploadCardProgressProps) {
|
||||
return (
|
||||
<Box grow="Yes" gap="200" alignItems="Center">
|
||||
<Badge variant="Secondary" fill="Solid" radii="Pill">
|
||||
<Text size="L400">{`${Math.round(percent(0, totalBytes, sentBytes))}%`}</Text>
|
||||
</Badge>
|
||||
<Box grow="Yes" direction="Column">
|
||||
<ProgressBar variant="Secondary" size="300" min={0} max={totalBytes} value={sentBytes} />
|
||||
</Box>
|
||||
<Badge variant="Secondary" fill="Soft" radii="Pill">
|
||||
<Text size="L400">
|
||||
{bytesToSize(sentBytes)} / {bytesToSize(totalBytes)}
|
||||
</Text>
|
||||
</Badge>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
type UploadCardErrorProps = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue