-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: proposed input file #151
Open
davisLjr
wants to merge
26
commits into
master
Choose a base branch
from
fix_proposed_input_file
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
fa3f4f5
ci: se agrega la rama dev al workflow
alan199912 696dbcf
fix: se corrige espaciado de icono en boton (#136)
victorianastasi bbcd007
feat: tooltip (#137)
Jesus1397 edf59ff
fix: se modifica visualizacion de breadcrumb en storybook, se reempla…
victorianastasi 369da51
feat: alert dismissible (#135)
alan199912 0ec710f
fix: pagination (#141)
victorianastasi e991777
Merge branch 'master' into dev
lautarorodriguez96 bc5e398
feat: Alerta - Tooltip - Paginador - Breadcrumb
lautarorodriguez96 e4015d7
fix: version actual de manera dinamica
alan199912 a853d58
feat: navegacion por pestañas (#138)
davisLjr 8c7f677
fix: se modifican nombres, se reemplaza textos secundarios por epigra…
victorianastasi e014658
Merge branch 'master' dev
lautarorodriguez96 7b26553
fix: spinner y boton con spinner (#142)
victorianastasi 243573c
fix: barra de progreso (#146)
Jesus1397 752c852
fix: accesos (#134)
matilope 3abb2f8
fix: se genera propuesta para el componente adjuntar archivo
davisLjr 05c7cc1
fix: se formatea el archivo
davisLjr 4bc7450
fix: se cambian nombres de español a ingles
davisLjr b994f93
fix: se elimina variable de texto
davisLjr e94f039
fix: se elimina clase container dentro del contenido
davisLjr 8b65b18
fix: se elimina clase label
davisLjr 1d56139
fix: se elimina props label
davisLjr f2ba95a
fix: se agregan nuevos espaciados segun comentarios en pr
davisLjr abc6d5f
fix: se elimina el interface
davisLjr 396a04c
fix: Merge branch 'master' into fix_proposed_input_file
davisLjr e332963
fix: actualizacion de componente maquetado y estilos
davisLjr File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,75 @@ | ||
// Base | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import './Form.stories.scss'; | ||
|
||
// Addons | ||
import { withA11y } from '@storybook/addon-a11y'; | ||
import { InputFile } from '.'; | ||
|
||
// Configuración general del componente | ||
export default { | ||
title: 'Formulario|Archivo', | ||
decorators: [withA11y] | ||
}; | ||
|
||
export const SubirUnArchivo = (): JSX.Element => { | ||
export const LoadFile = (): JSX.Element => { | ||
const [files, setFiles] = useState<File[]>([]); | ||
|
||
return ( | ||
<div className="form-wrapper"> | ||
<div className="form-group"> | ||
<label htmlFor="file-input">Adjuntar un archivo de ejemplo</label> | ||
<input type="file" className="form-control-file" id="file-input" /> | ||
</div> | ||
<div className="form-wrapper-lg"> | ||
<InputFile | ||
title="Arrastrá tus archivos acá o hace click para adjuntar" | ||
isMultiple={false} | ||
files={files} | ||
setFiles={setFiles} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
SubirUnArchivo.story = { | ||
LoadFile.story = { | ||
name: 'Subir un archivo' | ||
}; | ||
|
||
export const LoadFileMulti = (): JSX.Element => { | ||
const [files, setFiles] = useState<File[]>([]); | ||
|
||
return ( | ||
<div className="form-wrapper-lg"> | ||
<InputFile | ||
title="Arrastrá tus archivos acá o hace click para adjuntar" | ||
isMultiple={true} | ||
files={files} | ||
setFiles={setFiles} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
LoadFileMulti.story = { | ||
name: 'Subir un archivo multiple' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tal vez lo modificaria por Subir múltiples archivos , para que sea más claro |
||
}; | ||
|
||
export const Example = (): JSX.Element => { | ||
const contenidoUno = 'Este es el contenido del archivo.'; | ||
const contenidoDos = 'Este es el contenido del archivo dos.'; | ||
const [files, setFiles] = useState<File[]>([ | ||
new File([contenidoUno], 'archivo1.txt', { type: 'text/plain' }), | ||
new File([contenidoDos], 'archivo2.txt', { type: 'text/plain' }) | ||
]); | ||
|
||
return ( | ||
<div className="form-wrapper-lg"> | ||
<InputFile | ||
title="Arrastrá tus archivos acá o hace click para adjuntar" | ||
isMultiple={true} | ||
files={files} | ||
setFiles={setFiles} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
Example.story = { | ||
name: 'Archivo cargado' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tal vez se podria mencionar como Demo (como en modal) |
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,8 @@ | |
max-width: 400px; | ||
width: 100%; | ||
} | ||
|
||
.form-wrapper-lg { | ||
max-width: 600px; | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
export interface InputProps { | ||
title?: string; | ||
isMultiple?: boolean; | ||
files: File[]; | ||
setFiles: (value: File[] | ((prevFiles: File[]) => File[])) => void; | ||
} | ||
|
||
interface FileItemProps { | ||
file: File; | ||
onRemove: () => void; | ||
} | ||
|
||
const FileItem: React.FC<FileItemProps> = ({ file, onRemove }) => { | ||
const fileName = file.name.length > 20 ? `${file.name.slice(0, 20)}...` : file.name; | ||
|
||
return ( | ||
<div className="file-item"> | ||
<label className="file-name"> | ||
<div className="file-box"> | ||
<i className="bx bx-file"></i> | ||
{fileName} | ||
</div> | ||
</label> | ||
<div> | ||
<button type="button" className="btn btn-outline-danger btn-sm" onClick={onRemove}> | ||
Eliminar | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export const InputFile: React.FC<InputProps> = (props) => { | ||
const { title = 'Arrastrá tus archivos acá o hace click para adjuntar', isMultiple = false, files, setFiles } = props; | ||
|
||
const [inputKey, setInputKey] = useState<number>(0); | ||
|
||
useEffect(() => { | ||
setInputKey(inputKey + 1); | ||
}, [files]); | ||
|
||
const handleAddFiles = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const fileList = e.target.files; | ||
if (fileList) { | ||
const newFiles = Array.from(fileList); | ||
setFiles((prevFiles: File[]) => { | ||
const updatedFiles = newFiles.map((file: File) => file); | ||
return isMultiple ? [...prevFiles, ...updatedFiles] : updatedFiles; | ||
}); | ||
} | ||
}; | ||
|
||
const handleRemoveFile = (index: number) => { | ||
setFiles((prevFiles: File[]) => prevFiles.filter((_, i) => i !== index)); | ||
setInputKey((prevKey) => prevKey + 1); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className="file-group"> | ||
<label htmlFor="file-input" className="input-file-title"> | ||
<input | ||
key={inputKey} | ||
type="file" | ||
className="form-control-file custom-file" | ||
id="file-input" | ||
onChange={handleAddFiles} | ||
multiple={isMultiple} | ||
/> | ||
<span className="main-file"> | ||
<i className="bx bx-cloud-upload"></i> | ||
{title} | ||
</span> | ||
</label> | ||
</div> | ||
{Boolean(files.length) && ( | ||
<div key={inputKey} className={`filename-detail${isMultiple ? ' multiple' : ''}`}> | ||
{files.map((file: File, index: number) => ( | ||
<FileItem | ||
key={`${file.lastModified}-${Math.floor(Math.random() * 1000000)}`} | ||
file={file} | ||
onRemove={() => handleRemoveFile(index)} | ||
/> | ||
))} | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
davisLjr marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consultaria sobre el tipo de archivo permitido y el tamaño maximo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Falta detallar