Skip to content
Snippets Groups Projects
Commit a2f00c3a authored by Jose Manuel Serrano Amaut's avatar Jose Manuel Serrano Amaut
Browse files

[FEAT]: Add FileCardComponent MVP

parent 439d17db
No related branches found
No related tags found
No related merge requests found
import * as React from "react"; import * as React from "react";
import ShowDemoCode from "../../show-demo-code/ShowDemoCode"; import ShowDemoCode from "../../show-demo-code/ShowDemoCode";
const CodeJSFileCardBasic = (props) => { const CodeJSFileCardBasic = ({ card }) => {
return ( return (
<ShowDemoCode <ShowDemoCode
codeCompleteJS={completeCodeJS} codeCompleteJS={completeCodeJS(card)}
codeCompleteTS={completeCodeTS} codeCompleteTS={completeCodeTS(card)}
codeSandboxJS="https://codesandbox.io/s/dropzone-ui-basic-3j01v" codeSandboxJS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
codeSandboxTS="https://codesandbox.io/s/dropzone-ui-basic-3j01v" codeSandboxTS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
codeSplittedJS={splittedCodeJS} codeSplittedJS={splittedCodeJS(card)}
codeSplittedTS={splittedCodeTS} codeSplittedTS={splittedCodeTS(card)}
/> />
); );
}; };
export default CodeJSFileCardBasic; export default CodeJSFileCardBasic;
const splittedCodeJS = `<> const splittedCodeJS = (card) => `<>
{value ? ( {value ? (
<FileMosaic {...value} onDelete={removeFile} /> <${!card ? "FileMosaic" : "FileCard"} {...value} onDelete={removeFile} />
) : ( ) : (
<FileInputButton value={value ? [value] : []} onChange={updateFile} /> <FileInputButton value={value ? [value] : []} onChange={updateFile} />
)} )}
<FileMosaic {...sampleFileProps} /> <${!card ? "FileMosaic" : "FileCard"} {...sampleFileProps} />
</> </>
// file props // file props
...@@ -32,7 +32,7 @@ const sampleFileProps = { ...@@ -32,7 +32,7 @@ const sampleFileProps = {
name: "file created from props.jsx", name: "file created from props.jsx",
};`; };`;
const completeCodeJS = `import * as React from "react"; const completeCodeJS = (card) => `import * as React from "react";
import { InputButton, FileMosaic } from "@files-ui/react"; import { InputButton, FileMosaic } from "@files-ui/react";
const sampleFileProps = { const sampleFileProps = {
...@@ -55,22 +55,24 @@ export default function App() { ...@@ -55,22 +55,24 @@ export default function App() {
return ( return (
<div style={{display:"flex", gap:"10px"}}> <div style={{display:"flex", gap:"10px"}}>
{value ? ( {value ? (
<FileMosaic {...value} onDelete={removeFile} info/> <${
!card ? "FileMosaic" : "FileCard"
} {...value} onDelete={removeFile} info/>
) : ( ) : (
<FileInputButton value={value ? [value] : []} onChange={updateFile} /> <FileInputButton value={value ? [value] : []} onChange={updateFile} />
)} )}
<FileMosaic {...sampleFileProps} info/> <${!card ? "FileMosaic" : "FileCard"} {...sampleFileProps} info/>
</div> </div>
); );
};`; };`;
const splittedCodeTS = `<> const splittedCodeTS = (card) => `<>
{value ? ( {value ? (
<FileMosaic {...value} onDelete={removeFile} info/> <${!card ? "FileMosaic" : "FileCard"} {...value} onDelete={removeFile} info/>
) : ( ) : (
<FileInputButton value={value ? [value] : []} onChange={updateFile} /> <FileInputButton value={value ? [value] : []} onChange={updateFile} />
)} )}
<FileMosaic {...sampleFileProps} info/> <${!card ? "FileMosaic" : "FileCard"} {...sampleFileProps} info/>
</> </>
// file props // file props
...@@ -80,7 +82,7 @@ const sampleFileProps: ExtFile = { ...@@ -80,7 +82,7 @@ const sampleFileProps: ExtFile = {
type: "text/plain", type: "text/plain",
name: "file created from props.jsx", name: "file created from props.jsx",
};`; };`;
const completeCodeTS = `import * as React from "react"; const completeCodeTS = (card) => `import * as React from "react";
import { InputButton, FileMosaic, ExtFile } from "@files-ui/react"; import { InputButton, FileMosaic, ExtFile } from "@files-ui/react";
const sampleFileProps:ExtFile = { const sampleFileProps:ExtFile = {
...@@ -103,11 +105,13 @@ export default function App() { ...@@ -103,11 +105,13 @@ export default function App() {
return ( return (
<div style={{display:"flex", gap:"10px"}}> <div style={{display:"flex", gap:"10px"}}>
{value ? ( {value ? (
<FileMosaic {...value} onDelete={removeFile} info/> <${
!card ? "FileMosaic" : "FileCard"
} {...value} onDelete={removeFile} info/>
) : ( ) : (
<FileInputButton value={value ? [value] : []} onChange={updateFile} /> <FileInputButton value={value ? [value] : []} onChange={updateFile} />
)} )}
<FileMosaic {...sampleFileProps} info/> <${!card ? "FileMosaic" : "FileCard"} {...sampleFileProps} info/>
</div> </div>
); );
};`; };`;
import * as React from "react"; import * as React from "react";
import ShowDemoCode from "../../show-demo-code/ShowDemoCode"; import ShowDemoCode from "../../show-demo-code/ShowDemoCode";
const CodeJSFileMosaicImagePreview = () => { const CodeJSFileMosaicImagePreview = (props:{card:boolean}) => {
const {card}=props;
return ( return (
<ShowDemoCode <ShowDemoCode
codeCompleteJS={completeCodeJS} codeCompleteJS={completeCodeJS(card)}
codeCompleteTS={completeCodeTS} codeCompleteTS={completeCodeTS(card)}
codeSandboxJS="https://codesandbox.io/s/dropzone-ui-basic-3j01v" codeSandboxJS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
codeSandboxTS="https://codesandbox.io/s/dropzone-ui-basic-3j01v" codeSandboxTS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
codeSplittedJS={splittedCodeJS} codeSplittedJS={splittedCodeJS(card)}
codeSplittedTS={splittedCodeTS} codeSplittedTS={splittedCodeTS(card)}
/> />
); );
}; };
export default CodeJSFileMosaicImagePreview; export default CodeJSFileMosaicImagePreview;
const splittedCodeJS = `<> const splittedCodeJS = (card:boolean)=>`<>
{value ? ( {value ? (
<FileMosaic {...value} onDelete={removeFile} info preview/> <${card?"FileCard":"FileMosaic"} {...value} onDelete={removeFile} info preview/>
) : ( ) : (
<FileInputButton onChange={updateFile} accept="image/*"/> <FileInputButton onChange={updateFile} accept="image/*"/>
)} )}
<FileMosaic {...sampleFileProps} info/> <${card?"FileCard":"FileMosaic"} {...sampleFileProps} info/>
</> </>
// file props // file props
...@@ -33,7 +34,7 @@ const sampleFileProps = { ...@@ -33,7 +34,7 @@ const sampleFileProps = {
imageUrl:"https://cdn.wallpapersafari.com/0/95/1zms6H.jpg" imageUrl:"https://cdn.wallpapersafari.com/0/95/1zms6H.jpg"
};`; };`;
const completeCodeJS = `import * as React from "react"; const completeCodeJS = (card:boolean)=>`import * as React from "react";
import { InputButton, FileMosaic } from "@files-ui/react"; import { InputButton, FileMosaic } from "@files-ui/react";
const sampleFileProps = { const sampleFileProps = {
...@@ -57,22 +58,22 @@ export default function App() { ...@@ -57,22 +58,22 @@ export default function App() {
return ( return (
<div style={{display:"flex", gap:"10px"}}> <div style={{display:"flex", gap:"10px"}}>
{value ? ( {value ? (
<FileMosaic {...value} onDelete={removeFile} info preview/> <${card?"FileCard":"FileMosaic"} {...value} onDelete={removeFile} info preview/>
) : ( ) : (
<FileInputButton onChange={updateFile} accept="image/*"/> <FileInputButton onChange={updateFile} accept="image/*"/>
)} )}
<FileMosaic {...sampleFileProps} info/> <${card?"FileCard":"FileMosaic"} {...sampleFileProps} info/>
</div> </div>
); );
};`; };`;
const splittedCodeTS = `<> const splittedCodeTS = (card:boolean)=>`<>
{value ? ( {value ? (
<FileMosaic {...value} onDelete={removeFile} info preview/> <${card?"FileCard":"FileMosaic"} {...value} onDelete={removeFile} info preview/>
) : ( ) : (
<FileInputButton onChange={updateFile} accept="image/*"/> <FileInputButton onChange={updateFile} accept="image/*"/>
)} )}
<FileMosaic {...sampleFileProps} info/> <${card?"FileCard":"FileMosaic"} {...sampleFileProps} info/>
</> </>
// file props // file props
...@@ -83,7 +84,7 @@ const sampleFileProps: ExtFile = { ...@@ -83,7 +84,7 @@ const sampleFileProps: ExtFile = {
name: "Thor arrives wakanda.jpg", name: "Thor arrives wakanda.jpg",
imageUrl:"https://cdn.wallpapersafari.com/0/95/1zms6H.jpg" imageUrl:"https://cdn.wallpapersafari.com/0/95/1zms6H.jpg"
};`; };`;
const completeCodeTS = `import * as React from "react"; const completeCodeTS = (card:boolean)=>`import * as React from "react";
import { InputButton, FileMosaic, ExtFile } from "@files-ui/react"; import { InputButton, FileMosaic, ExtFile } from "@files-ui/react";
const sampleFileProps: ExtFile = { const sampleFileProps: ExtFile = {
...@@ -107,11 +108,11 @@ export default function App() { ...@@ -107,11 +108,11 @@ export default function App() {
return ( return (
<div style={{display:"flex", gap:"10px"}}> <div style={{display:"flex", gap:"10px"}}>
{value ? ( {value ? (
<FileMosaic {...value} onDelete={removeFile} info preview/> <${card?"FileCard":"FileMosaic"} {...value} onDelete={removeFile} info preview/>
) : ( ) : (
<FileInputButton onChange={updateFile} accept="image/*"/> <FileInputButton onChange={updateFile} accept="image/*"/>
)} )}
<FileMosaic {...sampleFileProps} info/> <${card?"FileCard":"FileMosaic"} {...sampleFileProps} info/>
</div> </div>
); );
};`; };`;
import { Paper, Stack } from "@mui/material"; import { Paper, Stack, Box } from "@mui/material";
import * as React from "react"; import * as React from "react";
const DemoContainerFileMosaic = ({ children }) => { const DemoContainerFileMosaic = ({ children, card }) => {
return ( return (
<Paper <Paper
variant="outlined" variant="outlined"
...@@ -12,15 +12,21 @@ const DemoContainerFileMosaic = ({ children }) => { ...@@ -12,15 +12,21 @@ const DemoContainerFileMosaic = ({ children }) => {
justifyContent: "center", justifyContent: "center",
}} }}
> >
<Stack <Box
spacing={4} sx={{
direction="row" display: "flex",
alignItems={"center"} gap: "20px",
flexWrap="wrap" flexWrap: "wrap",
justifyContent={"space-evenly"} flexDirection: { xs: card ? "column" : undefined, md: "row" },
justifyContent: {
xs: "center",
md: "space-evenly",
},
alignItems: { xs: "center" },
}}
> >
{children} {children}
</Stack> </Box>
</Paper> </Paper>
); );
}; };
......
...@@ -6,17 +6,17 @@ ...@@ -6,17 +6,17 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
margin: 10px; //margin: 10px;
min-height: 100px; min-height: 100px;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
font-size: 15px; font-size: 15px;
font-weight: 400; font-weight: 400;
width: 350px; width: 320px;
.files-ui-file-card-main-layer-container { .files-ui-file-card-main-layer-container {
border-radius: 8px; border-radius: 8px;
overflow: hidden; overflow: hidden;
width: 380px; width: 320px;
box-sizing: border-box; box-sizing: border-box;
height: 100px; height: 100px;
box-sizing: border-box; box-sizing: border-box;
...@@ -85,9 +85,12 @@ ...@@ -85,9 +85,12 @@
} }
} }
.file-card-data { .file-card-data {
line-height: 18px; padding-right: 10px;
box-sizing: border-box;
line-height: 19px;
font-weight: 500; font-weight: 500;
width: 250px; //width: 250px;
width: calc(100% - 100px);
//flex-grow: 1; //flex-grow: 1;
word-break: break-all; word-break: break-all;
color: black; color: black;
...@@ -101,12 +104,12 @@ ...@@ -101,12 +104,12 @@
} }
.file-card-size { .file-card-size {
font-weight: 400; font-weight: 400;
font-size: 0.95rem; font-size: 0.9rem;
} }
.file-card-name { .file-card-name {
//letter-spacing: 0.09em; //letter-spacing: 0.09em;
font-size: 1rem; font-size: 1rem;
text-align: center; //text-align: center;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
...@@ -121,18 +124,6 @@ ...@@ -121,18 +124,6 @@
} }
} }
.files-ui-file-card-right-layer {
right: 0;
left: unset;
display: flex;
align-items: center;
justify-content: space-between;
flex-direction: column;
padding: 3px;
width: 36px;
//background-color: aquamarine;
height: 100%;
}
.file-card-upload-layer-container { .file-card-upload-layer-container {
display: flex; display: flex;
box-sizing: border-box; box-sizing: border-box;
...@@ -182,7 +173,7 @@ ...@@ -182,7 +173,7 @@
align-items: center; align-items: center;
justify-content: flex-end; justify-content: flex-end;
.file-card-file-info { .file-card-file-info {
width: 250px; width: calc(100% - 100px);
height: 100px; height: 100px;
text-align: left; text-align: left;
scrollbar-width: thin; scrollbar-width: thin;
......
...@@ -10,7 +10,7 @@ import { useIsUploading } from "../file-mosaic/hooks/useIsUploading"; ...@@ -10,7 +10,7 @@ import { useIsUploading } from "../file-mosaic/hooks/useIsUploading";
import LayerContainer from "../file-mosaic/components/file-mosaic-layer/LayerContainer"; import LayerContainer from "../file-mosaic/components/file-mosaic-layer/LayerContainer";
import Layer from "../file-mosaic/components/file-mosaic-layer/Layer"; import Layer from "../file-mosaic/components/file-mosaic-layer/Layer";
import FileMosaicImageLayer from "../file-mosaic/components/FIleMosaicImageLayer/FileMosaicImageLayer"; import FileMosaicImageLayer from "../file-mosaic/components/FIleMosaicImageLayer/FileMosaicImageLayer";
import FileCardRightLayer from "./components/FileCardRightLayer"; import FileCardRightActions from "./components/FileCardRightActions";
import FileCardInfoLayer from "./components/FileCardInfoLayer"; import FileCardInfoLayer from "./components/FileCardInfoLayer";
import FileMosaicStatus from "../file-mosaic/components/FileMosaicStatus/FileMosaicStatus"; import FileMosaicStatus from "../file-mosaic/components/FileMosaicStatus/FileMosaicStatus";
import FileCardUploadLayer from "./components/FileCardUploadLayer"; import FileCardUploadLayer from "./components/FileCardUploadLayer";
...@@ -38,7 +38,8 @@ const makeFileCardClassName = ( ...@@ -38,7 +38,8 @@ const makeFileCardClassName = (
className: string | undefined className: string | undefined
): string => { ): string => {
console.log("FileCard makeFileCardClassName", elevation, darkMode, className); console.log("FileCard makeFileCardClassName", elevation, darkMode, className);
let finalClassName: string = "files-ui-file-card-main-container files-ui-tooltip card"; let finalClassName: string =
"files-ui-file-card-main-container files-ui-tooltip card";
if (elevation) { if (elevation) {
finalClassName += " elevation-" + setFinalElevation(elevation); finalClassName += " elevation-" + setFinalElevation(elevation);
...@@ -296,31 +297,13 @@ const FileCard: React.FC<FileCardProps> = (props: FileCardProps) => { ...@@ -296,31 +297,13 @@ const FileCard: React.FC<FileCardProps> = (props: FileCardProps) => {
</div> </div>
</div> </div>
</Layer> </Layer>
<Layer
{/* <Layer
className="files-ui-file-card-right-layer" className="files-ui-file-card-right-layer"
visible={!isUploading} visible={!isUploading}
> > */}
<FileCardRightLayer
deleteIcon={onDelete !== undefined} {/* </Layer> */}
onDelete={handleDelete}
darkMode={darkMode}
valid={valid}
uploadStatus={uploadStatus}
localization={localization}
sizeFormatted={sizeFormatted}
imageIcon={isImage && onSee !== undefined}
onSee={() => onSee?.(imageSource)}
videoIcon={isVideo && onWatch !== undefined}
onWatch={() => onWatch?.(file)}
downloadIcon={
onDownload !== undefined || downloadUrl !== undefined
}
onDownload={handleDownload}
infoIcon={info !== undefined}
onOpenInfo={handleOpenInfo}
isActive={alwaysActive || hovering}
/>
</Layer>
<Layer className="file-card-info-layer-container" visible={showInfo}> <Layer className="file-card-info-layer-container" visible={showInfo}>
<FileCardInfoLayer <FileCardInfoLayer
...@@ -357,6 +340,26 @@ const FileCard: React.FC<FileCardProps> = (props: FileCardProps) => { ...@@ -357,6 +340,26 @@ const FileCard: React.FC<FileCardProps> = (props: FileCardProps) => {
</Layer> </Layer>
</LayerContainer> </LayerContainer>
<FileCardRightActions
deleteIcon={onDelete !== undefined}
onDelete={handleDelete}
darkMode={darkMode}
valid={valid}
uploadStatus={uploadStatus}
localization={localization}
sizeFormatted={sizeFormatted}
imageIcon={isImage && onSee !== undefined}
onSee={() => onSee?.(imageSource)}
videoIcon={isVideo && onWatch !== undefined}
onWatch={() => onWatch?.(file)}
downloadIcon={onDownload !== undefined || downloadUrl !== undefined}
onDownload={handleDownload}
infoIcon={info !== undefined}
onOpenInfo={handleOpenInfo}
isActive={alwaysActive || hovering}
visible={!isUploading && !showInfo}
/>
<Tooltip <Tooltip
open={resultOnTooltip} open={resultOnTooltip}
uploadStatus={uploadStatus} uploadStatus={uploadStatus}
......
.file-card-right-layer-header { .file-card-right-layer-header {
margin-top: 3px;
margin-right: 3px;
position: absolute;
top: 0;
right: 0;
left: unset;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end; justify-content: flex-end;
height: 20px; gap: 2px;
width: 100%;
} }
.file-card-right-layer-footer { .file-card-right-layer-footer {
margin-bottom: 3px;
margin-right: 3px;
left: unset;
position: absolute;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end; justify-content: flex-end;
gap: 2px; gap: 2px;
height: 20px; //height: 20px;
width: 100%; //width: 100%;
bottom: 0;
right: 0;
} }
...@@ -7,8 +7,9 @@ import { ...@@ -7,8 +7,9 @@ import {
PlayIcon, PlayIcon,
Visibility, Visibility,
} from "../../icons"; } from "../../icons";
import "./FileMosaicRightLayer.scss"; import "./FileCardRightActions.scss";
declare type FileCardRightLayerProps = {
declare type FileCardRightActionsProps = {
darkMode?: boolean; darkMode?: boolean;
deleteIcon?: boolean; deleteIcon?: boolean;
onDelete?: Function; onDelete?: Function;
...@@ -32,9 +33,10 @@ declare type FileCardRightLayerProps = { ...@@ -32,9 +33,10 @@ declare type FileCardRightLayerProps = {
onOpenInfo: Function | undefined; onOpenInfo: Function | undefined;
isActive?: boolean; isActive?: boolean;
visible?: boolean;
}; };
const FileCardRightLayer: React.FC<FileCardRightLayerProps> = ( const FileCardRightActions: React.FC<FileCardRightActionsProps> = (
props: FileCardRightLayerProps props: FileCardRightActionsProps
) => { ) => {
const { const {
darkMode, darkMode,
...@@ -53,8 +55,9 @@ const FileCardRightLayer: React.FC<FileCardRightLayerProps> = ( ...@@ -53,8 +55,9 @@ const FileCardRightLayer: React.FC<FileCardRightLayerProps> = (
localization, localization,
uploadStatus, uploadStatus,
isActive, isActive,
visible
} = props; } = props;
if(visible)
return ( return (
<> <>
<div className="file-card-right-layer-header"> <div className="file-card-right-layer-header">
...@@ -126,6 +129,7 @@ const FileCardRightLayer: React.FC<FileCardRightLayerProps> = ( ...@@ -126,6 +129,7 @@ const FileCardRightLayer: React.FC<FileCardRightLayerProps> = (
)} )}
</div> </div>
</> </>
); )
return <></>
}; };
export default FileCardRightLayer; export default FileCardRightActions;
...@@ -65,7 +65,7 @@ const FileCardDemoPage = (props) => { ...@@ -65,7 +65,7 @@ const FileCardDemoPage = (props) => {
<DemoContainerFileMosaic> <DemoContainerFileMosaic>
<DemoFileCardBasic /> <DemoFileCardBasic />
</DemoContainerFileMosaic> </DemoContainerFileMosaic>
<CodeJSFileCardBasic /> <CodeJSFileCardBasic card/>
<Alert severity="info"> <Alert severity="info">
<AlertTitle> FileInputButton </AlertTitle> <AlertTitle> FileInputButton </AlertTitle>
...@@ -133,11 +133,11 @@ const FileCardDemoPage = (props) => { ...@@ -133,11 +133,11 @@ const FileCardDemoPage = (props) => {
<TypeHighlight>undefined</TypeHighlight>. <TypeHighlight>undefined</TypeHighlight>.
</DescParagraph> </DescParagraph>
<DemoContainerFileMosaic> <DemoContainerFileMosaic card>
<DemoFileMosaicValidation card /> <DemoFileMosaicValidation card />
</DemoContainerFileMosaic> </DemoContainerFileMosaic>
<CodeJSFileMosaicValidation /> <CodeJSFileMosaicValidation card/>
<Alert severity="info"> <Alert severity="info">
Typically, <CodeHighlight>{"<Dropzone/>"}</CodeHighlight> or{" "} Typically, <CodeHighlight>{"<Dropzone/>"}</CodeHighlight> or{" "}
<CodeHighlight>{"<FileInputButton/>"}</CodeHighlight> components set <CodeHighlight>{"<FileInputButton/>"}</CodeHighlight> components set
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment