From 6ba06e09d27b3442218a475211bd4214f7ecb510 Mon Sep 17 00:00:00 2001 From: Walidoux Date: Fri, 28 Apr 2023 14:42:51 +0100 Subject: [PATCH] feat(components|public): Add Design Loader and change Downloaders popup style This commit adds a Design Loader to Downloaders component and modifies the popup style with new classes. The loader is shown when the user clicks the Download GameData button. The popup is now centered and uses flex to position its content. Additionally, it now displays a message that depends on the state of the download process, and the close button's style is also modified. --- public/icons/cross.png | Bin 0 -> 373 bytes src/components/design/index.ts | 1 + .../layout/Downloaders/Downloaders.tsx | 46 ++++++++++++++++-- src/components/system/Popup/Popup.tsx | 2 +- 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100755 public/icons/cross.png create mode 100644 src/components/design/index.ts diff --git a/public/icons/cross.png b/public/icons/cross.png new file mode 100755 index 0000000000000000000000000000000000000000..6a5c0571fee2c4a602d5c8758fc482d5f88e394a GIT binary patch literal 373 zcmV-*0gC>KP)aB^>EX>4U6ba`-PAVE-2F#rGvnd3@N%}XuHOjal;%1_J8 zN##-i17i~|6H60IqeKG(0}BHPFf=eQHUyGJK(;wlDA51~n3$WT0in5BvY9D}&jkQa zx)o>}E!d0z006;BL_t(Ijg^zJ3BxcDMZYwJLEs?*u3csV^~nTTzyo-JOyKmIAf;+U zh6o5UM4Tc>Sf@ML{@s1Uvz8B?p5b90jNcz#|5Bo$j>38JL1 z83w@GREMr(A*wdn%yU+A5M4|a0vr$kG61ZtPUWOI^9Y0mh!E%MfUP@+apVD}?_~&i zSlX}R>R#*(!TX|_3qRZ)z<;&VBJF|DFhEv0La;hwlJ`Y81FRu6iJxf?g!|4vQhj2V TPA~^R00000NkvXXu0mjfrTmLT literal 0 HcmV?d00001 diff --git a/src/components/design/index.ts b/src/components/design/index.ts new file mode 100644 index 0000000..4e20d2b --- /dev/null +++ b/src/components/design/index.ts @@ -0,0 +1 @@ +export * from './Loader' diff --git a/src/components/layout/Downloaders/Downloaders.tsx b/src/components/layout/Downloaders/Downloaders.tsx index c665a6c..4d0fccb 100644 --- a/src/components/layout/Downloaders/Downloaders.tsx +++ b/src/components/layout/Downloaders/Downloaders.tsx @@ -1,4 +1,5 @@ import { Fragment, useState } from 'react' +import classNames from 'classnames' import { Image, Popup } from '../../system' import { Button } from '../Button' @@ -6,10 +7,13 @@ import { GameAssetsDownloader, GameDataDownloader } from '../../../config/GameDo import { handleConvertion } from '../../../tools/handleConvertion' import { Downloader } from './Downloader' import type { ConvertionHandler } from '../../../types/global' +import { Loader } from '../../design' export const Downloaders: React.FC = () => { const [message, setMessage] = useState('') - const [loading, setLoading] = useState(false) + const [error, setError] = useState(false) + const [popup, setPopup] = useState(false) + const [loading, setLoading] = useState(true) const callback: ConvertionHandler = (message, state = 'idle') => { switch (state) { @@ -21,13 +25,47 @@ export const Downloaders: React.FC = () => { return setLoading(false) case 'error': setMessage(message) + setError(true) return setLoading(false) } } + const downloadGameData = async (): Promise => { + setPopup(true) + setLoading(true) + + const startTime = new Date() + await handleConvertion('com', callback) + + const endTime = new Date() + const seconds = ((endTime.getTime() - startTime.getTime()) / 1000).toFixed(2) + + return callback(`Completed in: ${seconds} seconds`, 'success') + } + return ( - xd + + + {message} + + + + +