Skip to content

Commit

Permalink
feat(KUI-1378): delay is added to the shimmer effect
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhossein-haerian committed Sep 3, 2024
1 parent ef2f3de commit 113e220
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions public/js/app/components/RoundInformation/RoundInformation.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react'
import React, { useEffect, useMemo, useState } from 'react'

import Alert from '../../components-shared/Alert'
import BankIdAlert from '../../components/BankIdAlert'
Expand Down Expand Up @@ -42,8 +42,22 @@ function RoundInformation({ courseCode, courseData, courseRound, semesterRoundSt
const isLoading = courseEmployeesLoading || plannedModulesIsLoading
const isError = courseEmployeesError || plannedModulesError

const [isLoaderVisible, setIsLoaderVisible] = useState(false)

useEffect(() => {
let timer
if (isLoading) {
setIsLoaderVisible(true)
} else {
timer = setTimeout(() => {
setIsLoaderVisible(false)
}, 300)
}
return () => clearTimeout(timer)
}, [isLoading])

return (
<div className={`roundInformation ${!isError && isLoading ? 'shimmer-effect' : 'fadeIn'}`}>
<div className={`roundInformation ${!isError && isLoaderVisible ? 'shimmer-effect' : 'fadeIn'}`}>
<h3>
{translation.courseRoundInformation.round_header} {selectedRoundHeader}
</h3>
Expand Down

0 comments on commit 113e220

Please sign in to comment.