-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
😊 Add progress bar and progress page split components
- Loading branch information
1 parent
a54da60
commit bef3d3a
Showing
6 changed files
with
42 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useEffect, useState } from "preact/hooks"; | ||
import ProgressBar from "../components/ProgressBar.tsx"; | ||
|
||
function Progress() { | ||
const [progress, setProgress] = useState(0); | ||
const [done, setDone] = useState(0); | ||
const [total, setTotal] = useState(0); | ||
useEffect(() => { | ||
console.log(localStorage); | ||
const done = Object.keys(localStorage).filter((key) => { | ||
return localStorage.getItem(key) === "done"; | ||
}); | ||
const notdone = Object.keys(localStorage).filter((key) => { | ||
return localStorage.getItem(key) === "notdone"; | ||
}); | ||
setProgress(done.length / (done.length + notdone.length)); | ||
setDone(done.length); | ||
setTotal(done.length + notdone.length); | ||
}, []); | ||
return ( | ||
<div className="flex flex-col gap-2"> | ||
<h1 className="text-sm">لقد تعلمت {done} من أصل {total} درس</h1> | ||
<ProgressBar progress={Math.floor(progress * 100)} /> | ||
</div> | ||
); | ||
} | ||
|
||
export default Progress; |
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