From 8d7f6d52469484a461a28123e9416b38ad5f3347 Mon Sep 17 00:00:00 2001 From: Michael Kolchanov <01gicha01@gmail.com> Date: Fri, 7 Jun 2024 05:36:01 +0400 Subject: [PATCH] change mini calendar view --- src/components/MiniCalendar.tsx | 57 +++++++++++++------------------ src/components/PeriodTracking.tsx | 10 +----- tailwind.config.js | 2 ++ 3 files changed, 27 insertions(+), 42 deletions(-) diff --git a/src/components/MiniCalendar.tsx b/src/components/MiniCalendar.tsx index 21f394b..2306751 100644 --- a/src/components/MiniCalendar.tsx +++ b/src/components/MiniCalendar.tsx @@ -23,7 +23,7 @@ const MiniCalendar: React.FC = ({ lastMenstruationDate, cycle const dates = generateNext7Days(); - const dayNames = ['П', 'Вт', 'Ср', 'Че', 'П', 'Сб', 'Во']; + const dayNames = ['П', 'В', 'С', 'Ч', 'П', 'С', 'В']; const getOrderedDayNames = () => { const startIndex = (today.getDay() + 6) % 7; // getDay() returns 0 for Sunday, so adjust @@ -34,55 +34,46 @@ const MiniCalendar: React.FC = ({ lastMenstruationDate, cycle const orderedDayNames = getOrderedDayNames(); return ( -
-
- {orderedDayNames.map((day, index) => { - const daysFromStartOfCycle = (daysSinceLastPeriod + index) % cycleLength; - const isPeriod = daysFromStartOfCycle >= 0 && daysFromStartOfCycle < 5; - const isToday = index === 0; // First element corresponds to today +
+ {orderedDayNames.map((day, index) => { + const daysFromStartOfCycle = (daysSinceLastPeriod + index) % cycleLength; + const isPeriod = daysFromStartOfCycle >= 0 && daysFromStartOfCycle < 5; + const isOvulation = daysFromStartOfCycle >= 12 && daysFromStartOfCycle < 17; + const date = dates[index]; + const isToday = date.toDateString() === today.toDateString(); - return ( + return ( +
{isToday ? 'СЕГОДНЯ' : day} - ); - })} -
-
- {dates.map((date, index) => { - const daysFromStartOfCycle = (daysSinceLastPeriod + index) % cycleLength; - const isPeriod = daysFromStartOfCycle >= 0 && daysFromStartOfCycle < 5; - const isOvulation = daysFromStartOfCycle >= 12 && daysFromStartOfCycle < 17; - const isToday = date.toDateString() === today.toDateString(); - - return ( -
+
+ } ${ + isPeriod ? 'text-bright-orange' : isOvulation ? 'text-blue-bright' : 'text-black' + }`}> {date.getDate()}
- ); - })} -
+
+ ); + })}
); }; diff --git a/src/components/PeriodTracking.tsx b/src/components/PeriodTracking.tsx index a503191..47c8127 100644 --- a/src/components/PeriodTracking.tsx +++ b/src/components/PeriodTracking.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import MiniCalendar from './MiniCalendar'; import recommendationsData from '../assets/recommendations.json'; @@ -71,14 +71,6 @@ const PeriodTracking: React.FC = ({ return (
-
-
- -

Female TON

-
- -
-
diff --git a/tailwind.config.js b/tailwind.config.js index 7dc396c..66c1dc8 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -19,6 +19,8 @@ module.exports = { 'telegram-primary': 'var(--telegram-button-color)', 'telegram-primary-text': 'var(--telegram-button-text-color)', 'telegram-secondary-white': 'var(--telegram-secondary-bg-color)', + 'blue-bright': '#007AFF', + 'bright-orange': '#F77047', }, }, },