Skip to content

feat: add stats slice component#844

Merged
acatcalledfrank merged 26 commits intomasterfrom
ENG-4289_stats-slice
Mar 5, 2026
Merged

feat: add stats slice component#844
acatcalledfrank merged 26 commits intomasterfrom
ENG-4289_stats-slice

Conversation

@acatcalledfrank
Copy link
Contributor

@acatcalledfrank acatcalledfrank commented Feb 25, 2026

PR description

What is it doing?

Adding a new Stats Slice component. This component animates-in headline text using a "rolling number" format.

link to Jira ticket:

https://comicrelief.atlassian.net/browse/ENG-4289

Quick Checklist:

  • My PR title follows the Conventional Commit spec.

  • I have filled out the PR description as per the template above.

  • I have added tests to cover new or changed behaviour.

  • I have updated any relevant documentation.

Important! - lastly, make sure to squash merge...

@acatcalledfrank acatcalledfrank self-assigned this Feb 25, 2026
@AndyEPhipps AndyEPhipps removed their request for review March 4, 2026 11:51
Copy link
Contributor

@AndyEPhipps AndyEPhipps left a comment

Choose a reason for hiding this comment

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

Really lovely work, my comments are purely housekeeping, really like what you've done here, looks great!

} from './StatsSlice.style';

// stagger between characters in milliseconds
const characterStagger = 80;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can make this a prop with a default of 80, just for flexibility?

* @param {string} character
* @returns {'string' | 'number'}
*/
function getValueType(character) {
Copy link
Contributor

@AndyEPhipps AndyEPhipps Mar 4, 2026

Choose a reason for hiding this comment

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

Could we break these helper functions out into their own file, in order to ✨s t r e a m l i n e✨ this file a bit? It's pretty biiiiiiiiiiig

// split value into words and characters,
// and get the type of each character;
// we animate string and numeric values differently
const words = stat
Copy link
Contributor

Choose a reason for hiding this comment

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

Image

const wordKey = String(wordIndex) + wordObj.word;
return (
<Word key={wordKey}>
{wordObj.map(({ character, type }, characterIndex) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reduced the amount of repetition in this component, but splitting out the actual Word component/loop is probably more trouble than it's worth.

There's a cumulative characterDelay value that's shared between all words and characters, and gets incremented with every character, so we'd have to implement some kind of back-and-forth updating — definitely possible, but not really worth the time imo.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, appreciate the justification

};

// MARK: string
function AnimatedStringCharacter({
Copy link
Contributor

Choose a reason for hiding this comment

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

Image

};

// MARK: number
function AnimatedNumberCharacter({
Copy link
Contributor

Choose a reason for hiding this comment

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

Image

Copy link
Contributor

@AndyEPhipps AndyEPhipps left a comment

Choose a reason for hiding this comment

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

Lovely!

@acatcalledfrank acatcalledfrank merged commit 4af8ec6 into master Mar 5, 2026
9 checks passed
@acatcalledfrank acatcalledfrank deleted the ENG-4289_stats-slice branch March 5, 2026 15:30
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

🎉 This PR is included in version 8.63.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants