-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add progress meter #19
Open
7MinutesDead-Git
wants to merge
17
commits into
labrocadabro:main
Choose a base branch
from
7MinutesDead-Git:progress-meter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
aa7da09
Removed duplicate semicolon
7MinutesDead-Git 734316f
Simplified boolean expression
7MinutesDead-Git 0461337
Merge branch 'main' of https://github.com/7MinutesDead-Git/communityt…
7MinutesDead-Git 0dbaab1
Add progressBar mixin to allLessons page
7MinutesDead-Git a872265
Add initial progress bar styling
7MinutesDead-Git bc75418
Add progressBar client-side logic
7MinutesDead-Git 1f7a06a
Create basic progress bar mixin
7MinutesDead-Git af86276
Revert "Add initial progress bar styling"
7MinutesDead-Git 2b7c349
Convert progressBar pug classes to tailwind (...)
7MinutesDead-Git 6613874
Refactor meter selector and variable name to be more specific
7MinutesDead-Git ecad540
Add tailwind transition styling to progress meter (...)
7MinutesDead-Git fd0251a
Add conditional render depending on presence of totalCount from server
7MinutesDead-Git f51252f
Refactor initial completed count to be based on server-side rendered …
7MinutesDead-Git f6cba91
Include total and completed lesson counts in dashboard render
7MinutesDead-Git 12863e0
Include completed lesson count in allLessons render
7MinutesDead-Git a03dcb9
Render progress bar conditionally when logged in (...)
7MinutesDead-Git cd69c35
Render progress bar conditionally when logged in (...)
7MinutesDead-Git File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const innerMeter = document.querySelector('.meter-inner'); | ||
const checkboxes = document.querySelectorAll('.watched'); | ||
let completed = Number(innerMeter.innerText); | ||
|
||
if (checkboxes) { | ||
for (const checkbox of checkboxes) { | ||
checkbox.addEventListener('change', updateProgress); | ||
} | ||
} | ||
|
||
function updateWidth() { | ||
innerMeter.style.width = `${completed / checkboxes.length * 100}%`; | ||
innerMeter.innerText = `${completed} / ${checkboxes.length} `; | ||
if (completed === checkboxes.length) { | ||
innerMeter.innerText = "You are a software engineer."; | ||
} | ||
} | ||
|
||
function updateProgress(e) { | ||
if (e.target.checked) { | ||
completed += 1; | ||
} else { | ||
completed -= 1; | ||
} | ||
updateWidth(); | ||
} | ||
|
||
// Set the progress bar width on page load | ||
updateWidth(); |
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
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,6 @@ | ||
mixin progressBar(completedCount, totalCount) | ||
div.meter.w-full.h-8.rounded.mb-6.bg-twilight-50.border | ||
if totalCount | ||
div.meter-inner.text-center.text-lg.font-medium.h-8.text-twilight-50.bg-pink-800(style=`width: ${completedCount / totalCount * 100}%`) #{completedCount} / #{totalCount} | ||
else | ||
div.meter-inner.text-center.text-lg.font-medium.h-8.text-twilight-50.bg-pink-800 #{completedCount} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For totalCount, if traffic to your site ever starts really picking up, it may then be best to do this query only once on server startup, and keep its value cached in memory for subsequent requests for all users as it's unlikely the total lessons will change often (if ever). For now though this works for simplicity's sake.