Skip to content

Conversation

@imaryanm
Copy link

Implemented a countup timer widget that tracks the elapsed time from a specified starting point. I pretty much copied the countdown widget and made the necessary changes. I also added years and months to countup. Thanks for considering my pull request

@rafaelveiga
Copy link
Owner

Hey @imaryanm thanks for the contribution! A few thoughts:

I think we shouldn't duplicate code. Maybe a good design would be to implement this functionality within the src/Countdown/index.tsx file, and decide if it is a Countdown or a Countup based on a prop.

We could do as follows:

if (settings.type === "countdown") {
	return <Countdown settings={settings as CountdownSettings} isCountdown={true} />;
}

if (settings.type === "countup") {
	return <Countdown settings={settings as CountdownSettings} isCountdown={false} />;
}

That way, the widget types share the same settings and code. The user would have two widgets to choose from: countdown and countup, both with the same settings: type, date, to. Under the hood, we'll leverage the same code to power those two widgets. As a bonus, the countdown widget gets years and months 😄

To clean this up even further, I would rename the "internal" component name to "Timer". It would still be identified as a countdown or countup, but the component and folder would be named Timer. Still not 100% behind this name, so if you have a better suggestion, I'm all ears.

Is it possible for you to implement these changes? Do you need any help?

@rafaelveiga rafaelveiga mentioned this pull request Dec 8, 2024
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.

2 participants