From 88fe8b84e3c4fc791745c810d13169b009056b40 Mon Sep 17 00:00:00 2001 From: brausjonas Date: Thu, 4 May 2023 16:41:21 +0200 Subject: [PATCH] Calender Prototype --- anwendung/src/components/CalenderEntry.js | 9 +++ anwendung/src/components/CalenderView.jsx | 79 +++++++++++++++++++++++ anwendung/src/pages/index.js | 4 +- anwendung/src/styles/globals.css | 73 +++++++++++++++++++++ 4 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 anwendung/src/components/CalenderEntry.js create mode 100644 anwendung/src/components/CalenderView.jsx diff --git a/anwendung/src/components/CalenderEntry.js b/anwendung/src/components/CalenderEntry.js new file mode 100644 index 0000000..67da2ae --- /dev/null +++ b/anwendung/src/components/CalenderEntry.js @@ -0,0 +1,9 @@ +export class CalenderEntry +{ + constructor(start_point, end_point) + { + this.start_point = start_point; + this.end_point = end_point; + this.parent = null; + } +} \ No newline at end of file diff --git a/anwendung/src/components/CalenderView.jsx b/anwendung/src/components/CalenderView.jsx new file mode 100644 index 0000000..35ca87a --- /dev/null +++ b/anwendung/src/components/CalenderView.jsx @@ -0,0 +1,79 @@ +import {useEffect, useState} from "react"; +import {CalenderEntry} from "@/components/CalenderEntry"; + +let entries = {mo:[], tu:[], we:[], th:[], fr:[], sa:[]} + +export default function CalenderView(p) { + const [t, setT] = useState(false) + + function mouse_click(e) { + let y_window = e.clientY; + let y_target_offset = e.target.getBoundingClientRect().top; + let row = Math.floor((y_window - y_target_offset) / 3) + 1 + let current_list = entries[e.currentTarget.id]; + current_list.push(new CalenderEntry(row - 10, row + 5)); + setT(!t); + } + + function internal_to_time(internal) + { + internal /= 15 + let integer = Math.floor(internal) + let decimal = internal.toFixed(2); + let minutes = Math.floor((decimal - integer) * 60); + let minutes_string = minutes.toString().length === 1 ? "0" + minutes : minutes + return integer + ":" + minutes_string; + } + + return ( +
+
+
+
Montag
+ {entries["mo"].map(d => (
+

{internal_to_time(d.start_point)}

+

{internal_to_time(d.end_point)}

+
))} +
+
+
Dienstag
+ {entries["tu"].map(d => (
+ +

{internal_to_time(d.start_point)}

+

{internal_to_time(d.end_point)}

+
))} +
+
+
Mittwoch
+ {entries["we"].map(d => (
+ +

{internal_to_time(d.start_point)}

+

{internal_to_time(d.end_point)}

+
))} +
+
+
Donnerstag
+ {entries["th"].map(d => (
+ +

{internal_to_time(d.start_point)}

+

{internal_to_time(d.end_point)}

+
))} +
+
+
Freitag
+ {entries["fr"].map(d => (
+

{internal_to_time(d.start_point)}

+

{internal_to_time(d.end_point)}

+
))} +
+
+
Samstag
+ {entries["sa"].map(d => (
+

{internal_to_time(d.start_point)}

+

{internal_to_time(d.end_point)}

+
))} +
+
+
+ ) +} \ No newline at end of file diff --git a/anwendung/src/pages/index.js b/anwendung/src/pages/index.js index f75d63f..725d8a2 100644 --- a/anwendung/src/pages/index.js +++ b/anwendung/src/pages/index.js @@ -5,6 +5,7 @@ import Button from "@/components/Button"; import {arrowLeft, arrowRight} from "@/components/Icons"; import WeekSelector from "@/components/WeekSelector"; import PopUp from "@/components/PopUp"; +import CalenderView from "@/components/CalenderView"; const inter = Inter({subsets: ['latin']}) @@ -16,8 +17,7 @@ export default function Home(p) { return ( <> - - + ) diff --git a/anwendung/src/styles/globals.css b/anwendung/src/styles/globals.css index 651022e..6438ccc 100644 --- a/anwendung/src/styles/globals.css +++ b/anwendung/src/styles/globals.css @@ -181,3 +181,76 @@ Popup justify-content: end; gap: 5px; } + +/* +Calender View + */ + +.calender-container +{ + margin-top: 100px; + max-height: 300px; + overflow: scroll; +} + +.calender-view +{ + /* + Test + */ + width: 500px; + height: 1110px; + /* + End Test + */ + background-color: #5d606e; + display: flex; + flex-direction: row; + align-items: stretch; + border-radius: 5px; + justify-content: stretch; + gap: 2px; + padding: 2px; +} + +.calender-view .spalte +{ + border-radius: 5px; + width: 100px; + background-color: white; + display: grid; + grid-template-columns: 100%; + grid-template-rows: repeat(370, 3px); +} + +.spalte .wochen-tag +{ + text-align: center; + background-color: #f80000; + width: 100%; + color: white; + border-radius: 5px 5px 0 0; + display: flex; + align-items: center; + justify-content: center; + + grid-row-start: 1; + grid-row-end: 10; +} + +.entry +{ + background-color: #dc910b; + border-radius: 5px; + display: flex; + flex-direction: column; + justify-content: space-between; + padding: 2px; + align-items: center; +} + +.entry p +{ + color: white; + font-size: 10px; +} \ No newline at end of file