Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch florian #14

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Branch florian #14

wants to merge 1 commit into from

Conversation

tatamare123
Copy link
Collaborator

No description provided.

@MDGcode MDGcode changed the base branch from main to dev September 22, 2024 07:24
Comment on lines +4 to +6
const [timeLeft, setTimeLeft] = useState<number>(60);
const [isActive, setIsActive] = useState<boolean>(false);
const intervalRef = useRef<number | null>(null);
Copy link
Member

@cristim67 cristim67 Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are currently managing two states: timeLeft and isActive. Consider if you could combine these into a single state object to reduce unnecessary re-renders, as each setState call triggers a re-render.

Comment on lines +4 to +6
const [timeLeft, setTimeLeft] = useState<number>(60);
const [isActive, setIsActive] = useState<boolean>(false);
const intervalRef = useRef<number | null>(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);

Comment on lines +95 to +103
<button style={buttonStyle} onClick={handleStart} disabled={isActive}>
Start
</button>
<button style={buttonStyle} onClick={handleReset}>
Reset
</button>
<button style={buttonStyle} onClick={handleStop}>
Stop
</button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding aria-label or aria-live attributes


const progressBarContainerStyle: React.CSSProperties = {
width: '80%',
height: '40px',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might overflow on smaller screens. Add media queries or use rem.

Comment on lines +89 to +103
<div style={containerStyle}>
<h1 style={timerStyle}>{timeLeft}</h1>
<div style={progressBarContainerStyle}>
<div style={progressBarStyle}></div>
</div>
<div style={buttonContainerStyle}>
<button style={buttonStyle} onClick={handleStart} disabled={isActive}>
Start
</button>
<button style={buttonStyle} onClick={handleReset}>
Reset
</button>
<button style={buttonStyle} onClick={handleStop}>
Stop
</button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please refactor with TailwindCss

};

const progressBarContainerStyle: React.CSSProperties = {
width: '80%',
Copy link
Member

@cristim67 cristim67 Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to:

const progressBarStyle: React.CSSProperties = {
  width: `${(timeLeft / 60) * 100}%`,
  // ...
};

@@ -0,0 +1,109 @@
import React, { useState, useEffect, useRef } from 'react';

const CountdownTimer: React.FC = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add zero case handling: if the countdown reaches 0 as a use i like to show me something like: "Time's up!"
or disabling the Start button

};

const buttonContainerStyle: React.CSSProperties = {
marginTop: '40px', // Increased margin to move the buttons further down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments.

margin: '10px',
fontSize: '1.5rem',
color: '#FFFFFF',
backgroundColor: isCritical ? '#C026D3' : '#1D4ED8',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the color for the last second from purple to red

setIsActive(false);
};

const isCritical = timeLeft < 10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add more checkpoints like this through the process:
One for 45 seconds, one for 30 and one for 20s
Choose the colors so that they convert from blue to red
Also try to ease in into the transition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants