implement day selection

This commit is contained in:
marlon-erler
2024-07-26 03:38:46 +02:00
parent c95dc81870
commit d0131ce3f1
5 changed files with 43 additions and 10 deletions
+4 -3
View File
@@ -4,8 +4,6 @@ import * as React from "bloatless-react";
import CalendarPageViewModel from "../../ViewModel/Pages/calendarPageViewModel";
import { MonthGrid } from "../Components/monthGrid";
import { TaskViewModelToEntry } from "../Components/taskEntry";
import { createPropertyValueIndexState } from "../Components/propertyValueList";
import { translations } from "../translations";
export function CalendarPage(calendarPageViewModel: CalendarPageViewModel) {
@@ -17,7 +15,10 @@ export function CalendarPage(calendarPageViewModel: CalendarPageViewModel) {
if (calendarPageViewModel.monthGrid.value == undefined) {
return <div></div>;
} else {
return MonthGrid(calendarPageViewModel.monthGrid.value);
return MonthGrid(
calendarPageViewModel.monthGrid.value,
calendarPageViewModel.selectedDate
);
}
}
);
+14 -2
View File
@@ -5,7 +5,10 @@ import { MonthGrid } from "../../Model/Files/calendarModel";
import TaskViewModel from "../../ViewModel/Pages/taskViewModel";
import { translations } from "../translations";
export function MonthGrid<T>(monthGrid: MonthGrid<React.MapState<T>>) {
export function MonthGrid<T>(
monthGrid: MonthGrid<React.MapState<T>>,
selectedDate: React.State<number>
) {
const dayLabels: HTMLElement[] = [];
let currentWeekday = monthGrid.firstDayOfWeek;
while (dayLabels.length < 7) {
@@ -37,8 +40,17 @@ export function MonthGrid<T>(monthGrid: MonthGrid<React.MapState<T>>) {
{...Object.entries(monthGrid.days).map((entry) => {
const [date, mapState] = entry;
const isSelected = React.createProxyState(
[selectedDate],
() => selectedDate.value == parseInt(date)
);
function select() {
selectedDate.value = parseInt(date);
}
return (
<button class="tile">
<button class="tile" on:click={select} toggle:selected={isSelected}>
<div>
<b>{date}</b>
<div
+4
View File
@@ -197,6 +197,10 @@ const englishTranslations = {
yearInputPlaceholder: "2000",
monthInputPlaceholder: "01",
///
searchEventsHeadline: "Search Events"
},
},
};