Skip to content

Commit 9e8d2a7

Browse files
Redesign seen assignments feature (#160)
This shows seen assignments in a more legible left-highlighted border with a new badge indicator as well. It moves the "mark as seen" button to a floating position at the bottom of the screen to make it harder to miss. When logging in on a new device it will no longer mark all existing assignments as new.
1 parent 5b23aa0 commit 9e8d2a7

File tree

3 files changed

+42
-19
lines changed

3 files changed

+42
-19
lines changed

src/routes/(authed)/grades/[index]/+page.svelte

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -326,24 +326,6 @@
326326
</Alert>
327327
{/if}
328328

329-
{#if unseenAssignments.length > 0 && !hypotheticalMode}
330-
<div transition:fade={{ duration: 200 }} class="mt-4">
331-
<Alert color="green" border class="mx-4 flex items-center justify-between p-2 text-base">
332-
{unseenAssignments.length} new assignments
333-
<Button
334-
color="green"
335-
size="sm"
336-
onclick={() => {
337-
unseenAssignments.forEach(({ id }) => seenAssignmentIDs.add(id));
338-
saveSeenAssignments();
339-
}}
340-
>
341-
Mark as seen
342-
</Button>
343-
</Alert>
344-
</div>
345-
{/if}
346-
347329
<div class="m-4 flex flex-wrap items-center gap-2">
348330
<Checkbox bind:checked={hypotheticalMode}>
349331
<div id="hypothetical-toggle" class="mr-2 flex items-center">
@@ -400,6 +382,30 @@
400382
</Alert>
401383
</div>
402384
{/if}
385+
386+
{#if unseenAssignments.length > 0 && !hypotheticalMode}
387+
<div transition:fade={{ duration: 200 }} class="sticky bottom-8 flex justify-center">
388+
<Alert
389+
color="gray"
390+
border
391+
class="mx-4 flex w-fit items-center justify-between border-1 p-2 pl-3 text-base shadow-lg/30 dark:border-gray-600"
392+
>
393+
{unseenAssignments.length} new assignments
394+
<Button
395+
color="green"
396+
size="sm"
397+
outline
398+
class="cursor-pointer"
399+
onclick={() => {
400+
unseenAssignments.forEach(({ id }) => seenAssignmentIDs.add(id));
401+
saveSeenAssignments();
402+
}}
403+
>
404+
Mark as seen
405+
</Button>
406+
</Alert>
407+
</div>
408+
{/if}
403409
{/if}
404410

405411
{#snippet assignmentList(filter?: (assignment: Assignment) => boolean)}

src/routes/(authed)/grades/[index]/AssignmentCard.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
8080
const percentageChange = $derived(Math.round((gradePercentageChange ?? 0) * 100) / 100);
8181
82-
const border = $derived(unseen ? 'dark:border-t-green-600 border-t-4' : '');
82+
const border = $derived(unseen ? 'dark:border-l-green-600 border-l-4' : '');
8383
8484
let commentsVisible = $state(false);
8585
const toggleComments = () => {
@@ -180,6 +180,9 @@
180180
{#if date}
181181
<DateBadge {date} />
182182
{/if}
183+
{#if unseen}
184+
<Badge border color="green">New</Badge>
185+
{/if}
183186
</div>
184187

185188
<div class="mr-2 ml-auto flex shrink-0 items-center gap-2">

src/routes/(authed)/grades/gradebook.svelte.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@ export const loadGradebooks = async () => {
117117

118118
// Save the state to localStorage
119119
saveGradebooksState();
120+
121+
// If there aren't any seen assignment ids saved, mark all assignments as seen
122+
if (seenAssignmentIDs.size === 0) {
123+
gradebooksState.records.forEach((record) =>
124+
record?.data?.Courses.Course.map((course) => course.Marks)
125+
.filter((marks) => marks !== '')
126+
.forEach((marks) =>
127+
marks.Mark.Assignments.Assignment?.forEach((assignment) =>
128+
seenAssignmentIDs.add(assignment._GradebookID)
129+
)
130+
)
131+
);
132+
saveSeenAssignments();
133+
}
120134
};
121135

122136
export const showGradebook = async (overrideIndex?: number, forceRefresh = false) => {

0 commit comments

Comments
 (0)