Skip to content

Commit

Permalink
feat: add file store ui
Browse files Browse the repository at this point in the history
  • Loading branch information
danielstefanequilobe committed Jul 27, 2022
1 parent 24961ba commit 0cac430
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/components/form/UploadFileInput.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback } from 'react';
import styled from 'styled-components';

import { UploadIcon, SuccessIcon } from '..';
import { UploadIcon, SuccessIcon, Body } from '..';

const StyledDiv = styled('div')`
border: 1px dotted #d9d9d9;
Expand All @@ -20,6 +20,14 @@ const StyledInput = styled('input')`
height: 0px;
`;

const StyledNameContainer = styled('div')`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 2px;
`;

const UploadFileInput = ({ file, onChange }) => {
const onFileInputChange = useCallback(e => {
if (e.target.value && e.target.value !== '') {
Expand All @@ -32,7 +40,12 @@ const UploadFileInput = ({ file, onChange }) => {
<StyledDiv>
<label htmlFor="file">
{!file && <UploadIcon width="20" height="20" />}
{file && <SuccessIcon width="20" height="20" />}
{file && (
<StyledNameContainer>
<SuccessIcon width="20" height="20" />
<Body>{file.name}</Body>
</StyledNameContainer>
)}
</label>
<StyledInput type="file" id="file" onChange={onFileInputChange} />
</StyledDiv>
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/FileUploadModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const FileUploadModal = ({ onClose }) => {
file={formData.file}
/>
</InputContainer>
{!fileNameIsValid && (
{!fileIsValid && (
<Body size="Small" color="red">
{intl.formatMessage({
id: 'add-valid-file',
Expand Down

0 comments on commit 0cac430

Please sign in to comment.