Bladeren bron

add loader

master
azri 1 week geleden
bovenliggende
commit
e9ac740f99
5 gewijzigde bestanden met toevoegingen van 70 en 5 verwijderingen
  1. 3
    0
      src/App.js
  2. 45
    0
      src/components/Loader/Loader.jsx
  3. 1
    0
      src/components/Loader/index.js
  4. 1
    1
      src/components/Navbar/Navbar.jsx
  5. 20
    4
      src/index.css

+ 3
- 0
src/App.js Bestand weergeven

@@ -10,6 +10,7 @@ import Checkout from './pages/Checkout';
10 10
 import Navbar from './components/Navbar';
11 11
 import Footer from './components/Footer/Footer';
12 12
 import Header from './components/Header';
13
+import Loader from './components/Loader';
13 14
 import theme from './theme/theme';
14 15
 import { ThemeProvider } from '@mui/material';
15 16
 import { fetchCart, createCart } from './redux/slices/cartSlice';
@@ -43,6 +44,8 @@ function App() {
43 44
 
44 45
   return (
45 46
     <ThemeProvider theme={theme}>
47
+      
48
+      <Loader />
46 49
       <Header />
47 50
       <Navbar />
48 51
       <BrowserRouter>

+ 45
- 0
src/components/Loader/Loader.jsx Bestand weergeven

@@ -0,0 +1,45 @@
1
+import {useState, useEffect} from 'react';
2
+import { Box, Typography } from '@mui/material';
3
+import logoSrc from '../../assets/images/amberlogo.png'
4
+import { useSelector } from 'react-redux';
5
+
6
+
7
+const Loader = () => {
8
+
9
+  const products = useSelector((state) => state.products.products.data) // only used as referenced
10
+  const [display, setDisplay] = useState(true)
11
+
12
+  useEffect(() => {
13
+    
14
+    if (products.length > 0) {
15
+      setDisplay(false)
16
+    }
17
+
18
+  }, [products])
19
+  
20
+
21
+  return (
22
+    <Box sx={{
23
+      width: "100%",
24
+      height: "100%",
25
+      backgroundColor: "white",
26
+      position: "fixed",
27
+      display: (display) ? "flex" : "none",
28
+      alignItems:"center",
29
+      justifyContent:"center",
30
+      zIndex: 999
31
+    }}>
32
+      <Box sx={{display:"flex", alignItems:"center"}}>
33
+        <img src={logoSrc} alt="Logo"
34
+          style={{
35
+            width: 150,
36
+            height: 25,
37
+          }} />
38
+
39
+        <div class="loader" style={{marginLeft:"20px"}}></div>
40
+      </Box>
41
+    </Box>
42
+  );
43
+};
44
+
45
+export default Loader;

+ 1
- 0
src/components/Loader/index.js Bestand weergeven

@@ -0,0 +1 @@
1
+export { default } from "./Loader"

+ 1
- 1
src/components/Navbar/Navbar.jsx Bestand weergeven

@@ -259,6 +259,7 @@ const Navbar = () => {
259 259
     <>
260 260
       <AppBar position="fixed"
261 261
         sx={{
262
+          zIndex:998,
262 263
           backgroundColor: (isAtTop) ? "rgba(0, 0, 0, 0)" : "rgba(255, 255, 255, 0.3)",
263 264
           backdropFilter: (isAtTop) ? "none" : "blur(10px)",
264 265
           boxShadow: 0,
@@ -336,7 +337,6 @@ const Navbar = () => {
336 337
                     height: 25,
337 338
                   }} />
338 339
               </a>
339
-              
340 340
             </Box>
341 341
 
342 342
             {/* Center Section: Nav Items */}

+ 20
- 4
src/index.css Bestand weergeven

@@ -390,9 +390,25 @@
390 390
 .loader {
391 391
   width: 50px;
392 392
   aspect-ratio: 1;
393
+  display: grid;
394
+  border: 4px solid #0000;
393 395
   border-radius: 50%;
394
-  border: 8px solid;
395
-  border-color: #000 #0000;
396
-  animation: l1 1s infinite;
396
+  border-right-color: #95AAC5;
397
+  animation: l15 1s infinite linear;
397 398
 }
398
-@keyframes l1 {to{transform: rotate(.5turn)}}
399
+.loader::before,
400
+.loader::after {    
401
+  content: "";
402
+  grid-area: 1/1;
403
+  margin: 2px;
404
+  border: inherit;
405
+  border-radius: 50%;
406
+  animation: l15 2s infinite;
407
+}
408
+.loader::after {
409
+  margin: 8px;
410
+  animation-duration: 3s;
411
+}
412
+@keyframes l15{ 
413
+  100%{transform: rotate(1turn)}
414
+}

Laden…
Annuleren
Opslaan