async def getMarkedDays(month: str, year: str, cookie = Depends(users.isLoggedIn)):
days_with_logs = []
days_with_files = []
+ days_bookmarked = []
content:dict = fileHandling.getMonth(cookie["user_id"], year, int(month))
if "days" not in content.keys():
- return {"days_with_logs": [], "days_with_files": []}
+ return {"days_with_logs": [], "days_with_files": [], "days_bookmarked": []}
for dayLog in content["days"]:
if "text" in dayLog.keys():
days_with_logs.append(dayLog["day"])
if "files" in dayLog.keys() and len(dayLog["files"]) > 0:
days_with_files.append(dayLog["day"])
+ if "bookmarked" in dayLog.keys() and dayLog["bookmarked"]:
+ days_bookmarked.append(dayLog["day"])
- return {"days_with_logs": days_with_logs, "days_with_files": days_with_files}
+ return {"days_with_logs": days_with_logs, "days_with_files": days_with_files, "days_bookmarked": days_bookmarked}
@router.get("/loadMonthForReading")
})
return history
- return []
\ No newline at end of file
+ return []
+
+@router.get("/bookmarkDay")
+async def bookmarkDay(day: int, month: int, year: int, cookie = Depends(users.isLoggedIn)):
+ content:dict = fileHandling.getMonth(cookie["user_id"], year, month)
+
+ if "days" not in content.keys():
+ content["days"] = []
+
+ day_found = False
+ bookmarked = True
+ for dayLog in content["days"]:
+ if dayLog["day"] == day:
+ day_found = True
+ if "bookmarked" in dayLog and dayLog["bookmarked"]:
+ dayLog["bookmarked"] = False
+ bookmarked = False
+ else:
+ dayLog["bookmarked"] = True
+ break
+
+ if not day_found:
+ content["days"].append({"day": day, "bookmarked": True})
+
+ if not fileHandling.writeMonth(cookie["user_id"], year, month, content):
+ raise HTTPException(status_code=500, detail="Failed to bookmark day - error writing log")
+
+ return {"success": True, "bookmarked": bookmarked}
\ No newline at end of file
import * as bootstrap from 'bootstrap';
import { offcanvasIsOpen, sameDate } from '$lib/helpers.js';
+ let { bookmarkDay } = $props();
+
let days = $state([]);
let animationDirection = $state(1); // swipe the dates left or right
class="day
{$cal.daysWithLogs.includes(day.day) ? 'mark-background' : ''}
{$cal.daysWithFiles.includes(day.day) ? 'mark-dot' : ''}
+ {$cal.daysBookmarked.includes(day.day) ? 'mark-circle' : ''}
{(!$readingDate && sameDate($selectedDate, day)) || sameDate($readingDate, day) ? 'selected' : ''}"
onclick={() => onDateClick(day)}
>
>
</div>
<div class="col-4 d-flex justify-content-end">
- <button class="btn btn-secondary me-2"> Mark </button>
+ <!-- svelte-ignore a11y_consider_explicit_label -->
+ <button class="btn btn-secondary me-2" onclick={bookmarkDay}>
+ <svg
+ id="bookmark-icon"
+ data-name="Layer 1"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 91.5 122.88"
+ width="18"
+ ><defs
+ ><style>
+ .cls-1 {
+ fill-rule: evenodd;
+ }
+ </style></defs
+ ><title>add-bookmark</title>
+ {#if !$cal.daysBookmarked.includes($selectedDate.day)}
+ <path
+ class="cls-1"
+ d="M62.42,0A29.08,29.08,0,1,1,33.34,29.08,29.08,29.08,0,0,1,62.42,0ZM3.18,19.65H24.73a38,38,0,0,0-1,6.36H6.35v86.75L37.11,86.12a3.19,3.19,0,0,1,4.18,0l31,26.69V66.68a39.26,39.26,0,0,0,6.35-2.27V119.7a3.17,3.17,0,0,1-5.42,2.24l-34-29.26-34,29.42a3.17,3.17,0,0,1-4.47-.33A3.11,3.11,0,0,1,0,119.7H0V22.83a3.18,3.18,0,0,1,3.18-3.18Zm55-2.79a4.1,4.1,0,0,1,.32-1.64l0-.06a4.33,4.33,0,0,1,3.9-2.59h0a4.23,4.23,0,0,1,1.63.32,4.3,4.3,0,0,1,1.39.93,4.15,4.15,0,0,1,.93,1.38l0,.07a4.23,4.23,0,0,1,.3,1.55v8.6h8.57a4.3,4.3,0,0,1,3,1.26,4.23,4.23,0,0,1,.92,1.38l0,.07a4.4,4.4,0,0,1,.31,1.49v.18a4.37,4.37,0,0,1-.32,1.55,4.45,4.45,0,0,1-.93,1.4,4.39,4.39,0,0,1-1.38.92l-.08,0a4.14,4.14,0,0,1-1.54.3H66.71v8.57a4.35,4.35,0,0,1-1.25,3l-.09.08a4.52,4.52,0,0,1-1.29.85l-.08,0a4.36,4.36,0,0,1-1.54.31h0a4.48,4.48,0,0,1-1.64-.32,4.3,4.3,0,0,1-1.39-.93,4.12,4.12,0,0,1-.92-1.38,4.3,4.3,0,0,1-.34-1.62V34H49.56a4.28,4.28,0,0,1-1.64-.32l-.07,0a4.32,4.32,0,0,1-2.25-2.28l0-.08a4.58,4.58,0,0,1-.3-1.54v0a4.39,4.39,0,0,1,.33-1.63,4.3,4.3,0,0,1,3.93-2.66h8.61V16.86Z"
+ />
+ {:else}
+ <path
+ class="cls-1"
+ d="M62.42,0A29.08,29.08,0,1,1,33.34,29.08,29.08,29.08,0,0,1,62.42,0ZM3.18,19.65H24.73a38,38,0,0,0-1,6.36H6.35v86.75L37.11,86.12a3.19,3.19,0,0,1,4.18,0l31,26.69V66.68a39.26,39.26,0,0,0,6.35-2.27V119.7a3.17,3.17,0,0,1-5.42,2.24l-34-29.26-34,29.42a3.17,3.17,0,0,1-4.47-.33A3.11,3.11,0,0,1,0,119.7H0V22.83a3.18,3.18,0,0,1,3.18-3.18Zm72.1,5.77a4.3,4.3,0,0,1,3,1.26,4.23,4.23,0,0,1,.92,1.38l0,.07a4.4,4.4,0,0,1,.31,1.49v.18a4.37,4.37,0,0,1-.32,1.55,4.45,4.45,0,0,1-.93,1.4,4.39,4.39,0,0,1-1.38.92l-.08,0a4.14,4.14,0,0,1-1.54.3H49.56a4.28,4.28,0,0,1-1.64-.32l-.07,0a4.32,4.32,0,0,1-2.25-2.28l0-.08a4.58,4.58,0,0,1-.3-1.54v0a4.39,4.39,0,0,1,.33-1.63,4.3,4.3,0,0,1,3.93-2.66Z"
+ />
+ {/if}
+ </svg>
+ </button>
</div>
</div>
</div>
<style>
+ button:has(#bookmark-icon) {
+ background: #f57c00;
+ border: none;
+ }
+ button:has(#bookmark-icon):hover {
+ background: rgb(223, 111, 0);
+ }
+
.btnLeftRight {
color: white;
}
color: white;
aspect-ratio: 1;
}
+
+ .day.mark-circle {
+ /* background-color: transparent;*/
+ border: 3px solid #f57c00;
+ /* color: #ff9224; */
+ }
+
.day.mark-dot::after {
content: '';
width: 6px;