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

[FEAT]: Add img and vid ful screen previews. Add route and option in...

[FEAT]: Add img and vid ful screen previews. Add route and option in mainsidebar for fullscreen demo
parent 78ef49a2
No related branches found
No related tags found
No related merge requests found
Showing
with 507 additions and 16 deletions
...@@ -59,6 +59,12 @@ export default function MainMenuSideBar(props: MainMenuSideBarProps) { ...@@ -59,6 +59,12 @@ export default function MainMenuSideBar(props: MainMenuSideBarProps) {
index: 25, index: 25,
onClick: () => navigate("/components/avatar"), onClick: () => navigate("/components/avatar"),
}, },
{
label: "FullScreen (Img & Vid)",
index: 26,
onClick: () => navigate("/components/fullscreen"),
},
], ],
}, },
{ {
......
...@@ -4,14 +4,14 @@ import { FileMosaic, ExtFile, FileMosaicProps } from "../../../files-ui"; ...@@ -4,14 +4,14 @@ import { FileMosaic, ExtFile, FileMosaicProps } from "../../../files-ui";
import DescParagraph from "../../demo-components/desc-paragraph/DescParagraph"; import DescParagraph from "../../demo-components/desc-paragraph/DescParagraph";
import { FullScreen, ImagePreview, VideoPreview } from "../../../files-ui"; import { FullScreen, ImagePreview, VideoPreview } from "../../../files-ui";
import { import {
NarutoAndSasukeVsMomoshikiEN, // NarutoAndSasukeVsMomoshikiEN,
NarutoAndSasukeVsMomoshikiES, // NarutoAndSasukeVsMomoshikiES,
ThorArrivesWakandaEN, // ThorArrivesWakandaEN,
ThorArrivesWakandaES, ThorArrivesWakandaES,
} from "../../../data/videoLinks"; } from "../../../data/videoLinks";
const VIDEO_URL = /* const VIDEO_URL =
"https://srv23.y2mate.is/download?file=cd448fa7c7fe6c301970e890794fb682137140"; "https://srv23.y2mate.is/download?file=cd448fa7c7fe6c301970e890794fb682137140"; */
interface FileMosaicImageVideoPreviewsProps { interface FileMosaicImageVideoPreviewsProps {
darkMode?: boolean; darkMode?: boolean;
} }
...@@ -64,7 +64,7 @@ const FileMosaicImageVideoPreviews: React.FC< ...@@ -64,7 +64,7 @@ const FileMosaicImageVideoPreviews: React.FC<
console.error(error); console.error(error);
} }
}; };
const handleDownloadXHR = async ( /* const handleDownloadXHR = async (
fileId: FileMosaicProps["id"], fileId: FileMosaicProps["id"],
downloadUrl?: string downloadUrl?: string
) => { ) => {
...@@ -82,7 +82,7 @@ const FileMosaicImageVideoPreviews: React.FC< ...@@ -82,7 +82,7 @@ const FileMosaicImageVideoPreviews: React.FC<
request.send(); request.send();
request.onreadystatechange = function () { request.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) { if (this.readyState === 4 && this.status === 200) {
const imageURL = window.URL.createObjectURL(this.response); const imageURL = window.URL.createObjectURL(this.response);
const anchor = document.createElement("a"); const anchor = document.createElement("a");
...@@ -107,12 +107,12 @@ const FileMosaicImageVideoPreviews: React.FC< ...@@ -107,12 +107,12 @@ const FileMosaicImageVideoPreviews: React.FC<
anchor.click(); anchor.click();
document.body.removeChild(anchor); document.body.removeChild(anchor);
URL.revokeObjectURL(imageURL); URL.revokeObjectURL(imageURL);
/* const resJson = await response.json(); // const resJson = await response.json();
console.log("Download", resJson); */ //console.log("Download", resJson);
} catch (error) { } catch (error) {
console.log("Download error", error); console.log("Download error", error);
} }
}; }; */
return ( return (
<div style={{ width: "100%" }}> <div style={{ width: "100%" }}>
<h3>Or check the previews!</h3> <h3>Or check the previews!</h3>
...@@ -186,7 +186,7 @@ const files: ExtFile[] = [ ...@@ -186,7 +186,7 @@ const files: ExtFile[] = [
imageUrl: imageUrl:
"https://e0.pxfuel.com/wallpapers/626/685/desktop-wallpaper-avengers-infinity-war-thor-arrives-in-wakanda-bring-me-thanos.jpg", "https://e0.pxfuel.com/wallpapers/626/685/desktop-wallpaper-avengers-infinity-war-thor-arrives-in-wakanda-bring-me-thanos.jpg",
downloadUrl: ThorArrivesWakandaES, downloadUrl: ThorArrivesWakandaES,
extraData: { videoUrl: ThorArrivesWakandaES }, videoUrl: ThorArrivesWakandaES ,
}, },
{ {
id: 3, id: 3,
......
import * as React from "react";
import ShowDemoCode from "../../show-demo-code/ShowDemoCode";
const CodeDemoFullScrrenImg = () => {
return (
<ShowDemoCode
codeCompleteJS={completeCodeJS}
codeCompleteTS={completeCodeTS}
codeSandboxJS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
codeSandboxTS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
codeSplittedJS={splittedCodeJS}
codeSplittedTS={splittedCodeTS}
/>
);
};
export default CodeDemoFullScrrenImg;
const splittedCodeJS = `<FileCard id={0} {...imageSample} onSee={handleSee} />
<FileMosaic id={0} {...imageSample} onSee={handleSee} />
<FullScreen
open={imgSrc !== undefined}
onClose={() => setImgSrc(undefined)}
>
<ImagePreview src={imgSrc} />
</FullScreen>
const imageSample = {
id: "fileId-1",
size: 28 * 1024 * 1024,
type: "image/gif",
name: "Iron man in stark tower.gif",
imageUrl:
"https://i.pinimg.com/originals/b6/1d/6a/b61d6a1079d8e54932dcde9dc260dd2e.gif",
};`;
const completeCodeJS = `import * as React from "react";
import { FileCard, FileMosaic, FullScreen, ImagePreview } from "@files-ui/react";
const imageSample = {
id: "fileId-1",
size: 28 * 1024 * 1024,
type: "image/gif",
name: "Iron man in stark tower.gif",
imageUrl:
"https://i.pinimg.com/originals/b6/1d/6a/b61d6a1079d8e54932dcde9dc260dd2e.gif",
};
export default function App() {
const [imgSrc, setImgSrc] = React.useState(undefined);
const handleSee = (imageSource) => {
setImgSrc(imageSource);
};
return (
<>
<FileCard id={0} {...imageSample} onSee={handleSee} />
<FileMosaic id={0} {...imageSample} onSee={handleSee} />
<FullScreen
open={imgSrc !== undefined}
onClose={() => setImgSrc(undefined)}
>
<ImagePreview src={imgSrc} />
</FullScreen>
</>
);
};`;
const splittedCodeTS = `<FileCard id={0} {...imageSample} onSee={handleSee} />
<FileMosaic id={0} {...imageSample} onSee={handleSee} />
<FullScreen
open={imgSrc !== undefined}
onClose={() => setImgSrc(undefined)}
>
<ImagePreview src={imgSrc} />
</FullScreen>
const imageSample: ExtFile = {
id: "fileId-1",
size: 28 * 1024 * 1024,
type: "image/gif",
name: "Iron man in stark tower.gif",
imageUrl:
"https://i.pinimg.com/originals/b6/1d/6a/b61d6a1079d8e54932dcde9dc260dd2e.gif",
};`;
const completeCodeTS = `import * as React from "react";
import { ExtFile, FileCard, FileMosaic, FullScreen, ImagePreview } from "@files-ui/react";
const imageSample: ExtFile = {
id: "fileId-1",
size: 28 * 1024 * 1024,
type: "image/gif",
name: "Iron man in stark tower.gif",
imageUrl:
"https://i.pinimg.com/originals/b6/1d/6a/b61d6a1079d8e54932dcde9dc260dd2e.gif",
};
export default function App() {
const [imgSrc, setImgSrc] = React.useState<string | undefined>(undefined);
const handleSee = (imageSource: string | undefined) => {
setImgSrc(imageSource);
};
return (
<>
<FileCard id={0} {...imageSample} onSee={handleSee} />
<FileMosaic id={0} {...imageSample} onSee={handleSee} />
<FullScreen
open={imgSrc !== undefined}
onClose={() => setImgSrc(undefined)}
>
<ImagePreview src={imgSrc} />
</FullScreen>
</>
);
};`;
import * as React from "react";
import ShowDemoCode from "../../show-demo-code/ShowDemoCode";
const CodeDemoFullScrrenVid = () => {
return (
<ShowDemoCode
codeCompleteJS={completeCodeJS}
codeCompleteTS={completeCodeTS}
codeSandboxJS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
codeSandboxTS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
codeSplittedJS={splittedCodeJS}
codeSplittedTS={splittedCodeTS}
/>
);
};
export default CodeDemoFullScrrenVid;
const splittedCodeJS = `<FileCard id={0} {...videoSample} onWatch={handleWatch} />
<FileMosaic id={0} {...videoSample} onWatch={handleWatch} />
<FullScreen
open={videoSrc !== undefined}
onClose={() => setVideoSrc(undefined)}
>
<VideoPreview src={videoSrc} autoPlay controls />
</FullScreen>
const videoSample = {
id: "fileId-1",
size: 28 * 1024 * 1024,
type: "video/mp4",
name: "Thos arrives wakanda.mp4",
videoUrl: ThorArrivesWakandaEN,
};`;
const completeCodeJS = `import * as React from "react";
import { FileCard, FileMosaic, FullScreen, ImagePreview } from "@files-ui/react";
const videoSample = {
id: "fileId-1",
size: 28 * 1024 * 1024,
type: "video/mp4",
name: "Thos arrives wakanda.mp4",
videoUrl: ThorArrivesWakandaEN,
};
export default function App() {
const [videoSrc, setVideoSrc] = React.useState(undefined);
const handleWatch = (videoSource) => {
setVideoSrc(videoSource);
};
return (
<>
<FileCard id={0} {...videoSample} onWatch={handleWatch} />
<FileMosaic id={0} {...videoSample} onWatch={handleWatch} />
<FullScreen
open={videoSrc !== undefined}
onClose={() => setVideoSrc(undefined)}
>
<VideoPreview src={videoSrc} autoPlay controls />
</FullScreen>
</>
);
};`;
const splittedCodeTS = `<FileCard id={0} {...videoSample} onWatch={handleWatch} />
<FileMosaic id={0} {...videoSample} onWatch={handleWatch} />
<FullScreen
open={videoSrc !== undefined}
onClose={() => setVideoSrc(undefined)}
>
<VideoPreview src={videoSrc} autoPlay controls />
</FullScreen>
const videoSample: ExtFile = {
id: "fileId-1",
size: 28 * 1024 * 1024,
type: "video/mp4",
name: "Thos arrives wakanda.mp4",
videoUrl: ThorArrivesWakandaEN,
};`;
const completeCodeTS = `import * as React from "react";
import { ExtFile, FileCard, FileMosaic, FullScreen, ImagePreview } from "@files-ui/react";
const videoSample: ExtFile = {
id: "fileId-1",
size: 28 * 1024 * 1024,
type: "video/mp4",
name: "Thos arrives wakanda.mp4",
videoUrl: ThorArrivesWakandaEN,
};
export default function App() {
const [videoSrc, setVideoSrc] = React.useState<File | string | undefined>(
undefined
);
const handleWatch = (videoSource: File | string | undefined) => {
setVideoSrc(videoSource);
};
return (
<>
<FileCard id={0} {...videoSample} onWatch={handleWatch} />
<FileMosaic id={0} {...videoSample} onWatch={handleWatch} />
<FullScreen
open={videoSrc !== undefined}
onClose={() => setVideoSrc(undefined)}
>
<VideoPreview src={videoSrc} autoPlay controls />
</FullScreen>
</>
);
};`;
import * as React from "react";
import {
ExtFile,
FileCard,
FileMosaic,
FullScreen,
ImagePreview,
} from "../../../files-ui";
const DemoFullScreenImg = () => {
const [imgSrc, setImgSrc] = React.useState<string | undefined>(undefined);
const handleSee = (imageSource: string | undefined) => {
setImgSrc(imageSource);
};
return (
<>
<FileCard id={0} {...imageSample} onSee={handleSee} />
<FileMosaic id={0} {...imageSample} onSee={handleSee} />
<FullScreen
open={imgSrc !== undefined}
onClose={() => setImgSrc(undefined)}
>
<ImagePreview src={imgSrc} />
</FullScreen>
</>
);
};
export default DemoFullScreenImg;
const imageSample: ExtFile = {
id: "fileId-1",
size: 28 * 1024 * 1024,
type: "image/gif",
name: "Iron man in stark tower.gif",
imageUrl:
"https://i.pinimg.com/originals/b6/1d/6a/b61d6a1079d8e54932dcde9dc260dd2e.gif",
};
import * as React from "react";
import {
ExtFile,
FileCard,
FileMosaic,
FullScreen,
VideoPreview,
} from "../../../files-ui";
import { ThorArrivesWakandaEN } from "../../../data/videoLinks";
const DemoFullScreenVid = () => {
const [videoSrc, setVideoSrc] = React.useState<File | string | undefined>(
undefined
);
const handleWatch = (videoSource: File | string | undefined) => {
setVideoSrc(videoSource);
};
return (
<>
<FileCard id={0} {...videoSample} onWatch={handleWatch} />
<FileMosaic id={0} {...videoSample} onWatch={handleWatch} />
<FullScreen
open={videoSrc !== undefined}
onClose={() => setVideoSrc(undefined)}
>
<VideoPreview src={videoSrc} autoPlay controls />
</FullScreen>
</>
);
};
export default DemoFullScreenVid;
const videoSample: ExtFile = {
id: "fileId-1",
size: 28 * 1024 * 1024,
type: "video/mp4",
name: "Thos arrives wakanda.mp4",
videoUrl: ThorArrivesWakandaEN,
};
...@@ -20,8 +20,9 @@ export const FullScreenAPIPropRows = [ ...@@ -20,8 +20,9 @@ export const FullScreenAPIPropRows = [
default: <TypeHighlight np></TypeHighlight>, default: <TypeHighlight np></TypeHighlight>,
description: ( description: (
<> <>
The content of the dropozone. Tipically it is an array of{" "} The content of the component. Tipically it is the
<CodeHighlight>{"<FileMosaic/>"}</CodeHighlight> components. <CodeHighlight>{"<ImagePreview/>"}</CodeHighlight> or the{" "}
<CodeHighlight>{"<VideoPreview/>"}</CodeHighlight> components.
</> </>
), ),
}, },
......
...@@ -38,6 +38,16 @@ const FullScreenApi = () => { ...@@ -38,6 +38,16 @@ const FullScreenApi = () => {
For examples and details on the usage of this React component, visit For examples and details on the usage of this React component, visit
the component demo pages: the component demo pages:
<ul> <ul>
<li>
<AnchorToTab href="/components/fullscreen#imagepreview">
ImagePreview (FullScreen)
</AnchorToTab>
</li>
<li>
<AnchorToTab href="/components/fullscreen#videopreview">
VideoPreview (FullScreen)
</AnchorToTab>
</li>
<li> <li>
<AnchorToTab href="/components/filemosaic"> <AnchorToTab href="/components/filemosaic">
FileMosaic FileMosaic
......
...@@ -356,17 +356,17 @@ const FileCardDemoPage = (props) => { ...@@ -356,17 +356,17 @@ const FileCardDemoPage = (props) => {
</AnchorToTab> </AnchorToTab>
</li> </li>
<li> <li>
<AnchorToTab href="/api/preview#fullscreen"> <AnchorToTab href="/api/fullscreen">
{"<FullScreen/>"} {"<FullScreen/>"}
</AnchorToTab> </AnchorToTab>
</li> </li>
<li> <li>
<AnchorToTab href="/api/preview#imagepreview"> <AnchorToTab href="/api/imagepreview">
{"<ImagePreview/>"} {"<ImagePreview/>"}
</AnchorToTab> </AnchorToTab>
</li> </li>
<li> <li>
<AnchorToTab href="/api/preview#videopreview"> <AnchorToTab href="/api/videopreview">
{"<VideoPreview/>"} {"<VideoPreview/>"}
</AnchorToTab> </AnchorToTab>
</li> </li>
......
...@@ -373,6 +373,21 @@ const FileMosaicDemoPage = (props) => { ...@@ -373,6 +373,21 @@ const FileMosaicDemoPage = (props) => {
{"<FileInputButton/>"} {"<FileInputButton/>"}
</AnchorToTab> </AnchorToTab>
</li> </li>
<li>
<AnchorToTab href="/api/fullscreen">
{"<FullScreen/>"}
</AnchorToTab>
</li>
<li>
<AnchorToTab href="/api/imagepreview">
{"<ImagePreview/>"}
</AnchorToTab>
</li>
<li>
<AnchorToTab href="/api/videopreview">
{"<VideoPreview/>"}
</AnchorToTab>
</li>
</ul> </ul>
</section> </section>
</MainContentContainer> </MainContentContainer>
......
import { Alert, Paper } from "@mui/material";
import * as React from "react";
import CodeHighlight from "../../components/codeHighlight/CodeHighlight";
import DescParagraph from "../../components/demo-components/desc-paragraph/DescParagraph";
import CodeDemoFullScrrenImg from "../../components/demo-components/fullsceen/CodeDemoFullScreenImg";
import CodeDemoFullScrrenVid from "../../components/demo-components/fullsceen/CodeDemoFullScreenVid";
import DemoFullScreenImg from "../../components/demo-components/fullsceen/DemoFullScreenImg";
import DemoFullScreenVid from "../../components/demo-components/fullsceen/DemoFullScreenVid";
import SubTitle from "../../components/demo-components/sub-title/SubTitle";
import MainContentContainer from "../../components/layout-pages/MainContentContainer";
import RightMenuContainer from "../../components/layout-pages/RightMenuContainer";
import MainTitle from "../../components/main-title/MainTitle";
import MainParagraph from "../../components/paragraph-main/MainParagraph";
import RightMenu from "../../components/RightMenu/RightMenu";
import TypeHighlight from "../../components/typeHighlight/TypeHighlight";
import AnchorToTab from "../../components/util-components/AnchorToTab";
interface FullScreenDemoPageProps {}
const FullScreenDemoPage: React.FC<FullScreenDemoPageProps> = (
props: FullScreenDemoPageProps
) => {
return (
<React.Fragment>
<MainContentContainer>
<MainTitle>FullScreen</MainTitle>
<MainParagraph>
Basically the purpose of the{" "}
<CodeHighlight>{"<FullScreen/>"}</CodeHighlight> component is to
highlight any kind of component and works in a similar way a modal
does. It provides important prompts in a user flow.
<br />
You can close it by clicking on the close button or with the "esc"
key.
</MainParagraph>
<Alert severity="info">
While included here as a standalone component, the most common use
will be to display the the image preview or video preview
withSubMenufiring the onSee event or onWatch event from
<CodeHighlight>{"<FileMosaic/>"}</CodeHighlight> or{" "}
<CodeHighlight>{"<FileCard/>"}</CodeHighlight> components, so for
completeness, those components are included in the examples
</Alert>
<section id="imagepreview">
<SubTitle content="Image preview" />
<DescParagraph>
To display an image in full screen you can use the {"<FullScreen/>"}{" "}
and {"<ImagePreview/>"} components.
</DescParagraph>
<Paper
variant="outlined"
style={{
padding: "25px",
display: "flex",
alignItems: "center",
justifyContent: "space-evenly",
gap: "7px",
flexWrap: "wrap",
width: "100%",
//padding: "25px 0",
flexDirection: "row",
}}
>
<DemoFullScreenImg />
</Paper>
<CodeDemoFullScrrenImg />
</section>
<section id="videopreview">
<SubTitle content="Video preview" />
<DescParagraph>
To display a video in full screen you can use the {"<FullScreen/>"}{" "}
and {"<VideoPreview/>"} components.
</DescParagraph>
<Paper
variant="outlined"
style={{
padding: "25px",
display: "flex",
alignItems: "center",
justifyContent: "space-evenly",
gap: "7px",
flexWrap: "wrap",
width: "100%",
//padding: "25px 0",
flexDirection: "row",
}}
>
<DemoFullScreenVid />
</Paper>
<CodeDemoFullScrrenVid />
</section>
<section id="api">
<SubTitle content="API" />
<DescParagraph>
See the documentation below for a complete reference to all of the
props available to the components mentioned here.
</DescParagraph>
<ul>
<li>
<AnchorToTab href="/api/fullscreen">
{"<FullScreen/>"}
</AnchorToTab>
</li>
<li>
<AnchorToTab href="/api/imagepreview">
{"<ImagePreview/>"}
</AnchorToTab>
</li>
<li>
<AnchorToTab href="/api/videopreview">
{"<VideoPreview/>"}
</AnchorToTab>
</li>
<li>
<AnchorToTab href="/api/filecard">{"<FileCard/>"}</AnchorToTab>
</li>
<li>
<AnchorToTab href="/api/fileinputbuttom">
{"<FileInputButton/>"}
</AnchorToTab>
</li>
</ul>
</section>
</MainContentContainer>
<RightMenuContainer>
<RightMenu width="240px" items={rightMenuItems} />
</RightMenuContainer>
</React.Fragment>
);
};
export default FullScreenDemoPage;
const rightMenuItems = [
{
id: 0,
label: "Fullscreen Image",
referTo: "/components/fullscreen#imagepreview",
},
{
id: 1,
label: "FullScreen Video",
referTo: "/components/fullscreen#videopreview",
},
];
...@@ -26,6 +26,7 @@ import LocalizationPage from "../pages/localization/LocalizationPage"; ...@@ -26,6 +26,7 @@ import LocalizationPage from "../pages/localization/LocalizationPage";
import VideoPreviewApi from "../pages/api/VideoPreviewApi"; import VideoPreviewApi from "../pages/api/VideoPreviewApi";
import ImagePreviewApi from "../pages/api/ImagePreviewApi"; import ImagePreviewApi from "../pages/api/ImagePreviewApi";
import FullScreenApi from "../pages/api/FullScreenApi"; import FullScreenApi from "../pages/api/FullScreenApi";
import FullScreenDemoPage from "../pages/demo/FullScreenDemoPage";
const router = createBrowserRouter([ const router = createBrowserRouter([
{ {
...@@ -73,6 +74,10 @@ const router = createBrowserRouter([ ...@@ -73,6 +74,10 @@ const router = createBrowserRouter([
path: "/components/filecard", path: "/components/filecard",
element: <FileCardDemoPage />, element: <FileCardDemoPage />,
}, },
{
path: "/components/fullscreen",
element: <FullScreenDemoPage />,
},
], ],
}, },
{ {
......
...@@ -327,3 +327,8 @@ $border-color-dark: #0a1929; ...@@ -327,3 +327,8 @@ $border-color-dark: #0a1929;
} }
} }
} }
.rc-hl-code-line {
font-size: 16px !important;
line-height: 19px !important;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment