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

Wrapped Countdown Component #878

Merged
merged 9 commits into from
Nov 11, 2024
Merged

Wrapped Countdown Component #878

merged 9 commits into from
Nov 11, 2024

Conversation

EricWeng23
Copy link
Collaborator

Summary

Created a countdown for the QMI Wrapped release start 10 days before launch. The page will render a ribbon ball at the button right that will open the countdown when clicked. The countdown component consist of 3 counter: Days, Hours, Minutes. Note that the ribbon ball and countdown component will NOT be visible until the start date for which QMI Wrap begins its countdown. Unfortunately, currently the confetti for when counter reaches 0 is not yet implemented, thus only a cone svg is visible as of right now. Once counter reaches 0, user will be prompted to click a button to view their QMI Wrapped slider which is the Wrapped component.

To keep track of the varying start date and launch date across different semester, update the dates inside of the
constants.ts file

Test Plan

Tested via the local server to check if component renders and functions as expected. Pictures below:

When today is NOT the start date, so no component will be rendered
Screenshot 2024-10-27 at 7 18 01 PM

When today is the start date, then the counter component will be displayed with DAYS, HOURS, MINUTES
Note this is just a test example for visual purposes, so the 18 days depicted is not what will be shown on start date

Screenshot 2024-10-27 at 7 19 57 PM

When the counter is 0, then user will be prompted to click on the view button to open the Wrapped component
Note this is just an example of what happens when counter is 0

Screen.Recording.2024-10-27.at.7.18.25.PM.mov

Notes

Breaking Changes

None

  • I have updated the documentation accordingly.
  • My PR adds a @ts-ignore

@EricWeng23 EricWeng23 requested a review from a team as a code owner October 28, 2024 00:45
@dti-github-bot
Copy link
Member

dti-github-bot commented Oct 28, 2024

[diff-counting] Significant lines: 264.

@EricWeng23 EricWeng23 changed the title Countdown Wrapped Countdown Component Oct 28, 2024
Copy link
Contributor

@rgu0114 rgu0114 left a comment

Choose a reason for hiding this comment

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

Looks great so far Eric! Nice job figuring out the countdown logic independently and styling the component from scratch. It looks pretty good from the pictures and the screen recording you attached. It's not displaying for me when I run it locally for some reason, but we can sync on this during work session tomorrow.

The main thing to note for next steps is the transition to the clickable view (refer to Figma again), which will be a separate step after animating the confetti for some duration. Other than that though, it's looking promising and I'm excited to see this launch!

src/components/pages/SplitView.tsx Outdated Show resolved Hide resolved
src/components/pages/SplitView.tsx Outdated Show resolved Hide resolved
src/components/includes/WrappedCountdown.tsx Outdated Show resolved Hide resolved
// Call the setter function to change the state in the parent
setDisplayWrapped(true); // Set to true to show the modal
};
const launch = new Date(WRAPPED_LAUNCH_DATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Date object creation is redundant each render. Can we move these outside this component, maybe to SplitView?

// Define a zeroCounter object for comparison when there's no time remaining
const zeroCounter = { days: 0, hours: 0, minutes: 0 };
// Helper function to calculate the remaining time in days, hours, and minutes from start date to launch date
const calculateTimeRemaining = (dateProps: WrappedDate): RemainingTime => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: utility functions like these should be declared outside the component, near the top of the file

Copy link
Contributor

Choose a reason for hiding this comment

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

also it might be better to define some of these values for time calculations (like 1000 * 60 * 60 * 24) as constants to improve readability

// Initialize countdown state using the calculateTimeRemaining function
const [timeRemaining, setTimeRemaining] = useState<RemainingTime>(calculateTimeRemaining(date));
useEffect(() => {
const interval = setInterval(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice job setting this up to update the time remaining every second!

Copy link
Contributor

@rgu0114 rgu0114 left a comment

Choose a reason for hiding this comment

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

Here's what I'm thinking: We launch the countdown component with the countdown itself and the click to view modal when countdown reaches zero first (probably after Nov. 5th). Then, we work on the confetti in a separate PR during that 10 day countdown so it's not blocking us on anything.

Copy link
Contributor

@rgu0114 rgu0114 left a comment

Choose a reason for hiding this comment

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

Works great on my side! Confetti's exciting to see. Approving, but also make sure to update the PR description before merging.

@EricWeng23 EricWeng23 mentioned this pull request Nov 11, 2024
2 tasks
@rgu0114 rgu0114 merged commit d2f89af into master Nov 11, 2024
8 checks passed
@rgu0114 rgu0114 deleted the countdown branch November 11, 2024 06:34
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