Skip to content

Commit

Permalink
[material-ui][Button] Update the file upload demo (#38823)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-leal authored Sep 6, 2023
1 parent ca5ac14 commit 42005c6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 43 deletions.
31 changes: 13 additions & 18 deletions docs/data/material/components/buttons/InputFileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,22 @@ import { styled } from '@mui/material/styles';
import Button from '@mui/material/Button';
import CloudUploadIcon from '@mui/icons-material/CloudUpload';

const VisuallyHiddenInput = styled('input')`
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
bottom: 0;
left: 0;
white-space: nowrap;
width: 1px;
`;
const VisuallyHiddenInput = styled('input')({
clip: 'rect(0 0 0 0)',
clipPath: 'inset(50%)',
height: 1,
overflow: 'hidden',
position: 'absolute',
bottom: 0,
left: 0,
whiteSpace: 'nowrap',
width: 1,
});

export default function InputFileUpload() {
return (
<Button
component="label"
variant="contained"
startIcon={<CloudUploadIcon />}
href="#file-upload"
>
Upload a file
<Button component="label" variant="contained" startIcon={<CloudUploadIcon />}>
Upload file
<VisuallyHiddenInput type="file" />
</Button>
);
Expand Down
31 changes: 13 additions & 18 deletions docs/data/material/components/buttons/InputFileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,22 @@ import { styled } from '@mui/material/styles';
import Button from '@mui/material/Button';
import CloudUploadIcon from '@mui/icons-material/CloudUpload';

const VisuallyHiddenInput = styled('input')`
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
bottom: 0;
left: 0;
white-space: nowrap;
width: 1px;
`;
const VisuallyHiddenInput = styled('input')({
clip: 'rect(0 0 0 0)',
clipPath: 'inset(50%)',
height: 1,
overflow: 'hidden',
position: 'absolute',
bottom: 0,
left: 0,
whiteSpace: 'nowrap',
width: 1,
});

export default function InputFileUpload() {
return (
<Button
component="label"
variant="contained"
startIcon={<CloudUploadIcon />}
href="#file-upload"
>
Upload a file
<Button component="label" variant="contained" startIcon={<CloudUploadIcon />}>
Upload file
<VisuallyHiddenInput type="file" />
</Button>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<Button
component="label"
variant="contained"
startIcon={<CloudUploadIcon />}
href="#file-upload"
>
Upload a file
<Button component="label" variant="contained" startIcon={<CloudUploadIcon />}>
Upload file
<VisuallyHiddenInput type="file" />
</Button>

0 comments on commit 42005c6

Please sign in to comment.