Skip to content
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

zip: fbx files added #90

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 8 additions & 34 deletions src/components/Brand/IconsBrand/buttonAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,23 @@ import { Button } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import JSZip from 'jszip';
import { saveAs } from 'file-saver';
import {filesZip} from '../../../utils/logosBase64'
import {filesZip, files3DZip} from '../../../utils/logosBase64'

const ButtonAll = () => {
// const [files, setFiles] = useState()
const classes = useStyles();

// const convertToBase64 = (filesToconvert) =>{
// let arrayFiles = [];
// Array.from(filesToconvert).forEach(file =>{
// let reader = new FileReader();
// reader.readAsDataURL(file);
// reader.onload = () => {
// let array = [];
// let base64 = reader.result
// array = base64.split(',')
// arrayFiles.push({base64: array[1], name: file.name})
// console.log(array[1])
// };
// })
// setFiles({...files, arrayFiles})
// }

// const toDataURL = (url) =>
// fetch(url)
// .then((response) => response.blob())
// .then(
// (blob) =>
// new Promise((resolve, reject) => {
// const reader = new FileReader();
// reader.onloadend = () => resolve(reader.result);
// reader.onerror = reject;
// reader.readAsDataURL(blob);
// }),
// );


const onDownloadZip = async () => {
let zip = new JSZip();
const { arrayFiles } = filesZip;
let folder = zip.folder('logos');
const { arrayFiles3D } = files3DZip;
let folder = zip.folder('Logos');
let folder3D = zip.folder('Animated Logos')
arrayFiles.map(file => {
folder.file(file.name, file.base64, { base64: true });
})
arrayFiles3D.map((file) => {
folder3D.file(file.name, file.base64, { base64: true });
});
zip.generateAsync({ type: 'blob' }).then(function (content) {
saveAs(content, 'logosOctosoft.zip');
});
Expand All @@ -56,7 +30,7 @@ const ButtonAll = () => {
<Button className={classes.button} onClick={() => onDownloadZip()}>
DOWNLOAD ALL LOGOS
</Button>
{/* <input type="file" multiple onChange={(e) =>{convertToBase64(e.target.files)}}/> */}

</>
);
};
Expand Down
13 changes: 2 additions & 11 deletions src/components/Brand/IconsBrand/indexIcons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React from 'react';
import { Grid, Box } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import IconsCards from './iconsCards';
Expand All @@ -8,15 +8,6 @@ import ButtonAll from './buttonAll';
import TitleIcons from './titleIcons';

const IndexIcons = ({ logos }) => {
const [logoFiles, setLogoFiles] = useState([]);

useEffect(() => {
let array = [];
logos.forEach((logo) => {
array.push(logo.image.file.url);
});
setLogoFiles(array);
}, [logos]);

const classes = useStyles();
return (
Expand All @@ -28,7 +19,7 @@ const IndexIcons = ({ logos }) => {
<TitleIcons title={' ANIMATED LOGO BEHAVIOUR'} sort={'Left'} />
<IconsMovie logos={logos} />
<Box className={classes.buttonAll}>
<ButtonAll files={logoFiles} />
<ButtonAll />
</Box>
</Grid>
);
Expand Down
53 changes: 53 additions & 0 deletions src/utils/logosBase64.js

Large diffs are not rendered by default.