-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from 4lysson-a/dev
Merge develop into main
- Loading branch information
Showing
9 changed files
with
109 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,32 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import Rive from "@rive-app/react-canvas"; | ||
import { LocalStorage } from "@/helpers/LocalStorage"; | ||
|
||
export default function LogoLoading() { | ||
const localStorageExit = JSON.parse(localStorage.getItem("exit")); | ||
const isExitValid = | ||
localStorageExit && localStorageExit.expire > new Date().getTime(); | ||
const localExit = LocalStorage.get("initial_loading"); | ||
const isExitValid = localExit && localExit.expire > new Date().getTime(); | ||
|
||
const [exit, setExit] = React.useState(isExitValid); | ||
const [exit, setExit] = React.useState(isExitValid); | ||
|
||
React.useEffect(() => { | ||
setTimeout(() => { | ||
setExit(true); | ||
localStorage.setItem( | ||
"exit", | ||
JSON.stringify({ | ||
exit: true, | ||
expire: new Date().getTime() + 1000 * 60 * 60 * 24, | ||
}) | ||
); | ||
}, 5000); | ||
}, []); | ||
React.useEffect(() => { | ||
setTimeout(() => { | ||
setExit(true); | ||
LocalStorage.set("initial_loading", { | ||
exit: true, | ||
expire: new Date().getTime() + 1000 * 60 * 60 * 24 | ||
}); | ||
}, 5000); | ||
}, []); | ||
|
||
if (exit) { | ||
return null; | ||
} | ||
if (exit) { | ||
return null; | ||
} | ||
|
||
return ReactDOM.createPortal( | ||
<div className="h-screen w-full z-50 fixed top-0 left-0 flex items-center justify-center bg-background"> | ||
<Rive src="/rive/visualizaai.riv" /> | ||
</div>, | ||
document.getElementById("loading") | ||
); | ||
} | ||
return ReactDOM.createPortal( | ||
<div className="h-screen w-full !z-[999999999999] fixed top-0 left-0 flex items-center justify-center bg-background"> | ||
<Rive src="/rive/visualizaai.riv" /> | ||
</div>, | ||
document.getElementById("loading") | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import React from 'react'; | ||
import Lottie from 'lottie-react'; | ||
import React from "react"; | ||
import Lottie from "lottie-react"; | ||
|
||
import loadingDark from '@/assets/animations/loading-dark.json'; | ||
import loadingLight from '@/assets/animations/loading-light.json'; | ||
import loadingDark from "@/assets/animations/loading-dark.json"; | ||
import loadingLight from "@/assets/animations/loading-light.json"; | ||
import { LocalStorage } from "@/helpers/LocalStorage"; | ||
|
||
export default function Loading() { | ||
const theme = localStorage.getItem('theme'); | ||
const animate = theme === 'dark' ? loadingDark : loadingLight; | ||
const theme = LocalStorage.get("theme"); | ||
const animate = theme === "dark" ? loadingDark : loadingLight; | ||
|
||
return ( | ||
<div className='flex flex-col h-full justify-center items-center'> | ||
<Lottie animationData={animate} /> | ||
</div> | ||
); | ||
return ( | ||
<div className="flex flex-col h-full justify-center items-center"> | ||
<Lottie animationData={animate} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export class LocalStorage { | ||
static set(key, value) { | ||
localStorage.setItem(key, JSON.stringify(value)); | ||
} | ||
|
||
static get(key) { | ||
return JSON.parse(localStorage.getItem(key)); | ||
} | ||
|
||
static remove(key) { | ||
localStorage.removeItem(key); | ||
} | ||
|
||
static logout() { | ||
const keys = Object.keys(localStorage); | ||
keys.forEach(key => { | ||
if (key !== "version" && key !== "initial_loading") { | ||
localStorage.removeItem(key); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import React from "react"; | ||
|
||
import { LocalStorage } from "@/helpers/LocalStorage"; | ||
|
||
const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)"); | ||
|
||
export default function useChangeTheme() { | ||
React.useEffect(() => { | ||
prefersDarkScheme.addEventListener('change', () => { | ||
if (prefersDarkScheme.matches) { | ||
localStorage.setItem('theme', 'dark'); | ||
} | ||
|
||
else { | ||
localStorage.setItem('theme', 'light'); | ||
} | ||
}); | ||
}, []) | ||
React.useEffect(() => { | ||
prefersDarkScheme.addEventListener("change", () => { | ||
if (prefersDarkScheme.matches) { | ||
LocalStorage.set("theme", "dark"); | ||
} else { | ||
LocalStorage.set("theme", "light"); | ||
} | ||
}); | ||
}, []); | ||
|
||
return prefersDarkScheme; | ||
} | ||
return prefersDarkScheme; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters