Skip to content

Commit 5b2acbc

Browse files
chore(site): add FileUpload stories (#12456)
Related to #12260
1 parent 18d1c17 commit 5b2acbc

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Link from "@mui/material/Link";
2+
import type { Meta, StoryObj } from "@storybook/react";
3+
import { FileUpload } from "./FileUpload";
4+
5+
const meta: Meta<typeof FileUpload> = {
6+
title: "components/FileUpload",
7+
component: FileUpload,
8+
args: {
9+
title: "Upload template",
10+
description: (
11+
<>
12+
The template has to be a .tar or .zip file. You can also use our{" "}
13+
<Link href="/starter-templates">starter templates</Link> to getting
14+
started with Coder.
15+
</>
16+
),
17+
},
18+
};
19+
20+
export default meta;
21+
type Story = StoryObj<typeof FileUpload>;
22+
23+
export const Default: Story = {};
24+
25+
export const Uploading: Story = {
26+
args: {
27+
isUploading: true,
28+
},
29+
};
30+
31+
export const WithFile: Story = {
32+
args: {
33+
file: new File([], "template.zip"),
34+
},
35+
};

site/src/components/FileUpload/FileUpload.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ export const FileUpload: FC<FileUploadProps> = ({
6464
{...fileDrop}
6565
>
6666
<Stack alignItems="center" spacing={1}>
67-
{isUploading ? (
68-
<CircularProgress size={32} />
69-
) : (
70-
<UploadIcon css={styles.icon} />
71-
)}
67+
<div css={styles.iconWrapper}>
68+
{isUploading ? (
69+
<CircularProgress size={32} />
70+
) : (
71+
<UploadIcon css={styles.icon} />
72+
)}
73+
</div>
7274

7375
<Stack alignItems="center" spacing={0.5}>
7476
<span css={styles.title}>{title}</span>
@@ -155,6 +157,15 @@ const styles = {
155157
opacity: 0.75,
156158
},
157159

160+
// Used to maintain the size of icon and spinner
161+
iconWrapper: {
162+
width: 64,
163+
height: 64,
164+
display: "flex",
165+
alignItems: "center",
166+
justifyContent: "center",
167+
},
168+
158169
icon: {
159170
fontSize: 64,
160171
},

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy