diff --git a/index.html b/index.html
index b64b0de..86a2c86 100644
--- a/index.html
+++ b/index.html
@@ -4,7 +4,7 @@
-
Гринтаймер
+ MetaTimer
diff --git a/src/components/Button/Button.module.css b/src/components/Button/Button.module.css
index e613ab4..e5c8f14 100644
--- a/src/components/Button/Button.module.css
+++ b/src/components/Button/Button.module.css
@@ -1,6 +1,6 @@
button.button {
- width: 48px;
- height: 48px;
+ min-width: 48px;
+ min-height: 48px;
border-radius: 8px;
background-color: #AB71ED;
color: #FFFFFF;
diff --git a/src/components/Timer/Timer.module.css b/src/components/Timer/Timer.module.css
index 03bff9d..c1dca56 100644
--- a/src/components/Timer/Timer.module.css
+++ b/src/components/Timer/Timer.module.css
@@ -47,6 +47,29 @@
transform: translateY(4px);
}
+.dates_container {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+ gap: 16px;
+}
+
+.dates_item {
+ display: flex;
+ justify-content: center;
+ color: black;
+ border-radius: 16px;
+ border-color: #DCC3F8;
+ border-width: 4px;
+ border-style: solid;
+ padding: 8px;
+ width: 100%;
+
+ font-family: 'Montserrat';
+ font-weight: bold;
+ font-size: 24px;
+}
+
.presets_buttons {
display: flex;
flex-direction: row;
diff --git a/src/components/Timer/Timer.tsx b/src/components/Timer/Timer.tsx
index b4a3b69..c026b81 100644
--- a/src/components/Timer/Timer.tsx
+++ b/src/components/Timer/Timer.tsx
@@ -6,12 +6,30 @@ import styles from './Timer.module.css'
const Timer = () => {
const [timeManager, recreateTimeManager] = useState(() => new TimeManager(0))
const [remainingTime, setRemainingTime] = useState({ minutes: 0, seconds: 0 });
+ const [startDate, setStartDate] = useState('00:00');
+ const [endDate, setEndDate] = useState('00:00');
+
+ const formatTime = (date: Date) => {
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+ return `${hours}:${minutes}`;
+ };
useEffect(() => {
timeManager.start()
console.log("timer started")
const interval = setInterval(() => {
- setRemainingTime(timeManager.getRemainingTime())
+ setRemainingTime(timeManager.getRemainingTime());
+ let startString = formatTime(timeManager.getStartDate());
+ let endString = formatTime(timeManager.getEndDate());
+ if (startString === endString) {
+ setStartDate('00:00');
+ setEndDate('00:00');
+ }
+ else {
+ setStartDate(startString);
+ setEndDate(endString);
+ }
}, 100);
return () => {
@@ -29,14 +47,22 @@ const Timer = () => {
-
-
+
handleRecreation(-1)}/>
+
+
+ {startDate}
+
+
+ {endDate}
+
+
handleRecreation(15)}/>
handleRecreation(30)}/>
diff --git a/src/helpers/TimeManager.ts b/src/helpers/TimeManager.ts
index 0660b2d..48cb41c 100644
--- a/src/helpers/TimeManager.ts
+++ b/src/helpers/TimeManager.ts
@@ -1,4 +1,6 @@
class TimeManager {
+ private startDate: Date;
+ private endDate: Date;
private initialTime: number;
private endTime: number;
private pauseTime: number | null = null;
@@ -7,8 +9,10 @@ class TimeManager {
private isPaused: boolean = false;
constructor(minutes: number) {
+ this.startDate = new Date();
this.initialTime = minutes * 60;
this.endTime = Date.now() + this.initialTime * 1000;
+ this.endDate = new Date(this.endTime);
}
start(): void {
@@ -53,10 +57,12 @@ class TimeManager {
addTime(minutes: number): void {
this.endTime += minutes * 60 * 1000;
+ this.endDate = new Date(this.endTime);
}
subtractTime(minutes: number): void {
this.endTime = Math.max(Date.now(), this.endTime - minutes * 60 * 1000);
+ this.endDate = new Date(this.endTime); // Обновляем endDate
}
getRemainingTime(): { minutes: number; seconds: number } {
@@ -85,6 +91,14 @@ class TimeManager {
this.pause()
}
}
+
+ getStartDate(): Date {
+ return this.startDate;
+ }
+
+ getEndDate(): Date {
+ return this.endDate;
+ }
}
export default TimeManager
\ No newline at end of file
diff --git a/src/pages/Timers/Timers.module.css b/src/pages/Timers/Timers.module.css
index d5e20e6..d65b04a 100644
--- a/src/pages/Timers/Timers.module.css
+++ b/src/pages/Timers/Timers.module.css
@@ -5,6 +5,12 @@ body, html {
font-family: 'Montserrat', serif;
}
+.header {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+}
+
.content {
padding: 32px;
display: flex;
@@ -30,34 +36,4 @@ body, html {
justify-content: space-between;
flex-wrap: wrap;
gap: 16px;
-}
-
-.notes_container {
- display: flex;
- flex-direction: column;
- gap: 10px;
- background-color: #FFFFFF;
- border-radius: 32px;
- padding: 32px;
- height: 400px;
-}
-
-.notes_container textarea {
- height: 100%;
- border: 1px dashed #000;
- resize: none;
- font-size: 40px;
-}
-
-footer {
- display: flex;
- background-color: #FFF;
- border-radius: 32px;
- flex-direction: column;
- padding: 32px;
- color: #000;
-}
-
-footer a {
- font-size: 24px;
}
\ No newline at end of file
diff --git a/src/pages/Timers/Timers.tsx b/src/pages/Timers/Timers.tsx
index ab4551a..e41ed1c 100644
--- a/src/pages/Timers/Timers.tsx
+++ b/src/pages/Timers/Timers.tsx
@@ -1,11 +1,30 @@
+import { useEffect, useState } from 'react';
import Timer from '../../components/Timer/Timer';
import styles from './Timers.module.css';
const Timers = () => {
+ const [time, setTime] = useState(new Date());
+
+ useEffect(() => {
+ const intervalId = setInterval(() => {
+ setTime(new Date());
+ }, 500);
+
+ return () => clearInterval(intervalId);
+ }, [])
+
+ const formatTime = (date: Date) => {
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+ const seconds = String(date.getSeconds()).padStart(2, '0');
+ return `${hours}:${minutes}:${seconds}`;
+ };
+
return (
)
}