[go: up one dir, main page]

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

Implement a number-count animation for DORA-cards #385

Open
3 tasks
e-for-eshaan opened this issue May 23, 2024 · 13 comments
Open
3 tasks

Implement a number-count animation for DORA-cards #385

e-for-eshaan opened this issue May 23, 2024 · 13 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed web-server Issue related to web-server

Comments

@e-for-eshaan
Copy link
Contributor
e-for-eshaan commented May 23, 2024

Why do we need this ?

we can add some animation to the cards' numbers on
image

similar to this
use-count-up

Acceptance Criteria

  • try not to introduce packages within the code base, writing optimized code will be appreciated

  • It's best if you apply these animation for the Deployment frequency and Change failure rate first. These look farely straight forward

  • using a component/custom-hook based approach is appreciated

  • TODO 1

  • TODO 2

  • TODO 3

Further Comments / References

@e-for-eshaan e-for-eshaan added enhancement New feature or request web-server Issue related to web-server labels May 23, 2024
@e-for-eshaan e-for-eshaan self-assigned this May 23, 2024
@jayantbh jayantbh added good first issue Good for newcomers help wanted Extra attention is needed labels May 23, 2024
@e-for-eshaan e-for-eshaan removed their assignment May 24, 2024
@KartikChawla09
Copy link
Contributor

@e-for-eshaan I would like to work on this issue, can you assign it to me.

@jayantbh
Copy link
Contributor
jayantbh commented Jul 2, 2024

Hey @KartikChawla09, sure you can take this up.

@jayantbh
Copy link
Contributor
jayantbh commented Jul 2, 2024

I'm assigning this to you. In case that changes, let me know and I'll unassign you.

@KartikChawla09
Copy link
Contributor

I'm assigning this to you. In case that changes, let me know and I'll unassign you.

Thank you for assigning it to me. Can you have a look at #459 while I work on this ?

@jayantbh
Copy link
Contributor
jayantbh commented Jul 5, 2024

Hey @KartikChawla09, #459 was merged. 👏🏽 👏🏽 👏🏽
Feel free to continue on this.

@KartikChawla09
Copy link
Contributor

Hey @KartikChawla09, #459 was merged. 👏🏽 👏🏽 👏🏽 Feel free to continue on this.

Yes! I am working on it. Will raise a PR ASAP.

@KartikChawla09
Copy link
Contributor

Hey @e-for-eshaan @jayantbh .
image
The page is getting stuck on this loading animation for more than 5 minutes. It used to work previously but after fetching the latest commit it stopped to work.
I am attaching the logs below.
image
image
Is this an issue with my local deployment ?

@jayantbh
Copy link
Contributor
jayantbh commented Jul 7, 2024

Hey @KartikChawla09, this shouldn't have happened. Did you check if there is an older commit that seems to not have this issue?

@KartikChawla09
Copy link
Contributor

Hey @KartikChawla09, this shouldn't have happened. Did you check if there is an older commit that seems to not have this issue?

The last commit I remember working correctly was this one. But maybe the issue is at my end only. It would really help if someone could confirm that by checking on their local deployment.

@e-for-eshaan
Copy link
Contributor Author

Hey @KartikChawla09 , are you still working on this?

@KartikChawla09
Copy link
Contributor

Hey @KartikChawla09 , are you still working on this?

Yes! I have implemented the counter as well but I am having some issues with my local deployment due to which I am not able to test the code locally. I will push the code when I am able to fix the issue. I have sent the error on Slack as well.

@e-for-eshaan
Copy link
Contributor Author

@KartikChawla09 been a while, how's this coming up, should I assign this to someone else?

@KartikChawla09
Copy link
Contributor

There was some issue with my local deployment, as I mentioned I raised as issue on Slack as well but it didn't get fixed so I couldn't test my code.

import { useEffect, useState } from "react";

const easeInOutQuad = (t: number) => {
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
};

const CounterAnimation = ({
targetValue,
duration,
}: {
targetValue: number;
duration: number;
}) => {
const [count, setCount] = useState(0);

useEffect(() => {
const flag = Math.floor(targetValue) === targetValue;
let start = 0;
const iterations = 10;
const time = duration / iterations;
const startTime = performance.now();
const counter = setInterval(() => {
const elapsed = performance.now() - startTime;
const progress = elapsed / duration;
const easedProgress = easeInOutQuad(progress);
start += 1;
flag
? setCount(Math.floor(easedProgress * targetValue))
: setCount(parseFloat((easedProgress * targetValue).toFixed(2)));
if (start >= iterations) {
clearInterval(counter);
setCount(targetValue);
}
}, time);
}, [duration, targetValue]);

return <>{count}</>;
};

export default CounterAnimation;

This code snippet might help the person who takes up this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed web-server Issue related to web-server
Projects
None yet
Development

No branches or pull requests

3 participants