From fb6e3ba82a2f4c3d623d3091bc653b5b5692de98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Sat, 17 Sep 2022 17:02:27 -0300 Subject: [PATCH] Add desktop skeleton loading for assignment --- src/screens/Assignment/View.js | 46 ++++++++++++++++++++++++++++++-- src/screens/Assignment/styles.js | 16 +++++++++++ src/services/user-service.js | 2 +- 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/src/screens/Assignment/View.js b/src/screens/Assignment/View.js index 1829f22..b4ecdbe 100644 --- a/src/screens/Assignment/View.js +++ b/src/screens/Assignment/View.js @@ -1,13 +1,22 @@ import parse from 'html-react-parser'; -import { Box, Button, Container, Stack, Typography } from '@mui/material'; +import { + Box, + Button, + Container, + Skeleton, + Stack, + Typography, +} from '@mui/material'; import dayjs from 'dayjs'; import { capitalizeFirstLetter } from '../../utils/capitalizeFirstLetter'; import styles from './styles'; +import { createArrayFrom1ToN } from '../../utils/createArrayFrom1ToN'; function View({ assignment, dropzone, layoutType }) { const { container, + loadingContainer, headerStack, title, classroomColorStack, @@ -21,7 +30,40 @@ function View({ assignment, dropzone, layoutType }) { } = styles[layoutType]; return assignment === null ? ( -

Loading...

+ + + + + + + + + + + {createArrayFrom1ToN(12).map(i => ( + + ))} + + + + + + + ) : ( diff --git a/src/screens/Assignment/styles.js b/src/screens/Assignment/styles.js index 97c3cdc..d9b5fd9 100644 --- a/src/screens/Assignment/styles.js +++ b/src/screens/Assignment/styles.js @@ -7,6 +7,14 @@ const desktopContainer = { marginTop: '30px', }; +const desktopLoadingContainer = { + width: '100%', + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + marginTop: '50px', +}; + const desktopHeaderStack = { width: '70%', paddingBottom: '5px', @@ -68,6 +76,7 @@ const desktopButton = { const desktop = { container: desktopContainer, + loadingContainer: desktopLoadingContainer, headerStack: desktopHeaderStack, title: desktopTitle, classroomColorStack: desktopClassroomColorStack, @@ -86,6 +95,11 @@ const mobileContainer = { marginBottom: '100px', }; +const mobileLoadingContainer = { + ...desktopLoadingContainer, + marginBottom: '100px', +}; + const mobileHeaderStack = { ...desktopHeaderStack, width: '90%', @@ -136,6 +150,7 @@ const mobileButton = { const mobile = { container: mobileContainer, + loadingContainer: mobileLoadingContainer, headerStack: mobileHeaderStack, title: mobileTitle, classroomColorStack: mobileClassroomColorStack, @@ -151,6 +166,7 @@ const mobile = { // ========== Unset ========== const unset = { container: null, + loadingContainer: null, headerStack: null, title: null, classroomColorStack: null, diff --git a/src/services/user-service.js b/src/services/user-service.js index d256832..a440e6d 100644 --- a/src/services/user-service.js +++ b/src/services/user-service.js @@ -53,7 +53,7 @@ const getAllAssignments = userId => }); const getAssignmentById = assignmentId => - sleep(400).then(() => { + sleep(4000).then(() => { console.log('Getting assignment by id ' + assignmentId); return { data: allAssignments.filter(a => a.id === assignmentId)[0],