From f615c3bb440782a90d1f32632a4b9c4e4ec4c60e Mon Sep 17 00:00:00 2001 From: therealrinku Date: Sat, 29 Jun 2024 18:04:32 +0545 Subject: [PATCH] feat: show loading animation for 2sec --- src/renderer/App.css | 56 ++++++++++++++++++++++++++++- src/renderer/App.tsx | 16 +++++++-- src/renderer/components/Loading.tsx | 10 ++++++ 3 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 src/renderer/components/Loading.tsx diff --git a/src/renderer/App.css b/src/renderer/App.css index e611897..b2a0119 100644 --- a/src/renderer/App.css +++ b/src/renderer/App.css @@ -33,4 +33,58 @@ textarea { background-color: rgb(152 151 149); border: 3px solid rgb(152 151 149); } -} \ No newline at end of file +} + +/* loading animation */ +/* credit:https://loading.io/css/ */ + +.lds-ripple, +.lds-ripple div { + box-sizing: border-box; +} +.lds-ripple { + display: inline-block; + position: relative; + width: 80px; + height: 80px; +} +.lds-ripple div { + position: absolute; + border: 4px solid currentColor; + opacity: 1; + border-radius: 50%; + animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite; +} +.lds-ripple div:nth-child(2) { + animation-delay: -0.5s; +} +@keyframes lds-ripple { + 0% { + top: 36px; + left: 36px; + width: 8px; + height: 8px; + opacity: 0; + } + 4.9% { + top: 36px; + left: 36px; + width: 8px; + height: 8px; + opacity: 0; + } + 5% { + top: 36px; + left: 36px; + width: 8px; + height: 8px; + opacity: 1; + } + 100% { + top: 0; + left: 0; + width: 80px; + height: 80px; + opacity: 0; + } +} diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 328430d..3fff086 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -4,7 +4,8 @@ import Home from './pages/Home'; import './App.css'; import { RootContextProvider } from './context/RootContext'; import useDir from './hooks/useDir'; -import { useEffect } from 'react'; +import { useEffect, useState } from 'react'; +import Loading from './components/Loading'; export default function App() { return ( @@ -21,6 +22,15 @@ export default function App() { function SetupApp() { const { rootDir } = useDir(); + const [showLoading, setShowLoading] = useState(true); + + // show loading animation for 2 seconds + useEffect(() => { + setTimeout(() => { + setShowLoading(false); + }, 2000); + }, []); + useEffect(() => { // load-theme if (localStorage.getItem('color-theme') === 'dark') { @@ -43,7 +53,9 @@ function SetupApp() { } } - if (rootDir) { + if (showLoading) { + return ; + } else if (rootDir) { return ; } else { return ; diff --git a/src/renderer/components/Loading.tsx b/src/renderer/components/Loading.tsx new file mode 100644 index 0000000..ea67cf6 --- /dev/null +++ b/src/renderer/components/Loading.tsx @@ -0,0 +1,10 @@ +export default function Loading() { + return ( +
+
+
+
+
+
+ ); +}