-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
feat(RandomContributor): Migrate Component #5378
feat(RandomContributor): Migrate Component #5378
Conversation
Co-authored-by: Manish Kumar ⛄ <[email protected]> Co-authored-by: Wai.Tung <[email protected]> Co-authored-by: Shanmughapriyan S <[email protected]> Co-authored-by: Michael Esteban <[email protected]> Co-authored-by: Claudio Wunder <[email protected]> Co-authored-by: Teja Sai Sandeep Reddy Konala <[email protected]> Co-authored-by: Claudio Wunder <[email protected]> Co-authored-by: vasanth9 <cheepurupalli.vasanthkumar.com> Co-authored-by: Aymen Naghmouchi <[email protected]> Co-authored-by: Teja Sai Sandeep Reddy Konala <[email protected]> Co-authored-by: Augustin Mauroy <[email protected]> Co-authored-by: Guilherme Araújo <[email protected]> Co-authored-by: Augustin Mauroy <[email protected]> Co-authored-by: HinataKah0 <[email protected]> Co-authored-by: Olaleye Blessing <[email protected]> Co-authored-by: ktssr <[email protected]> Co-authored-by: vasanthkumar <[email protected]> Co-authored-by: Floran Hachez <[email protected]> Co-authored-by: Jatin <[email protected]> fixed styleling misconfig and fixed storybooks (nodejs#5281) fix storybook styles, imports, typescript config and dependencies (nodejs#5319 fix(package.json) Lint command is missing slashes (nodejs#5321 fix storybook local development mode (nodejs#5335) fix(i18n): translation key (nodejs#5347)
… method (nodejs#5369) Add clarity to step 4 based on clone method Signed-off-by: Vessy Shestorkina <[email protected]>
* Migrate JsonLink component Signed-off-by: Vessy Shestorkina <[email protected]> * Add storybook snap and robot icon Signed-off-by: Vessy Shestorkina <[email protected]> * Remove IconContext provider Signed-off-by: Vessy Shestorkina <[email protected]> --------- Signed-off-by: Vessy Shestorkina <[email protected]> Signed-off-by: Claudio Wunder <[email protected]> Co-authored-by: Claudio Wunder <[email protected]>
…s#5376) * refactor(useDownloadLink): Move useDetectOs to useDownloadLink * refactor(useDownloadLink): rename file * refactor(useDownloadLink): rename file * Apply suggestions from code review Signed-off-by: Claudio Wunder <[email protected]> * refactor(useDownloadLink): undo deleted file --------- Signed-off-by: Claudio Wunder <[email protected]> Co-authored-by: Claudio Wunder <[email protected]>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @Harkunwar I super appreciate for taking the migration of that component :)
I left a lot of comments, just to raise the bar of the quality of the PR. Regardless, thank you so much for working on this!
@@ -0,0 +1,27 @@ | |||
.random-contributor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually use camelCase classnames
max-width: 400px; | ||
padding: var(--space-12); | ||
|
||
@media (max-width: 900px) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we somewhere added a mixin for the 900px max-wdith
parameters: { | ||
moduleMock: { | ||
mock: () => { | ||
const mock = createMock(hooks, 'useNodeJsContributorsApi'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call the hook useFetchNodeContributor
?
|
||
return ( | ||
<div ref={ref} className={styles.randomContributor}> | ||
{!contributor && isVisible && <AnimatedPlaceholder />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can leave the animated placeholder even when it's not visible, to reduce layout shift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{!contributor && isVisible && <AnimatedPlaceholder />} | |
{contributor || <AnimatedPlaceholder />} |
import { useOnScreen } from '../../../hooks/useOnScreen'; | ||
import { useNodeJsContributorsApi } from '../../../hooks/useNodeJsContributorsApi'; | ||
|
||
const DefaultImageSize = 75; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constants are usually uppercase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const DefaultImageSize = 75; | |
const DEFAULT_IMAGE_SIZE = 75; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole test feels overcomplicated imho, feels like we're testing things that do not need to be tested. But I'm not sure. This has a chance to become a flaky test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't think it's easy to test this one since we're basically mocking everything.
page: number; | ||
}; | ||
|
||
export type ContributorApiResponse = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need a type that covers the full JSON response, we can simply just leave what we want.
It is indeed a partial type that wouldn't reflect 100% on the extent of the object, but I rather doing that than keeping a bunch of types that have no value for me.
import { NodeJSContributorsApiKey } from '../constants/swr'; | ||
|
||
const LIMIT_CONTRIBUTORS = 5; | ||
const CONTRIBUTORS_API_URI = `https://api.github.com/repos/nodejs/node/contributors?per_page=${LIMIT_CONTRIBUTORS}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel we could have a dedicated constants file for all these sorts of constants, including API URL constants as we had on nodejs.dev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(To have a single point for all constants, which makes it easier to find)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I have a single word for this Hook. Megazord.
It is doing way way many things. A React Hook should never be this much convoluted and complicated.
- It is breaking the single responsibility pattern
- It mixes all sort of design patterns making it confusing
- It's convoluted and big
- Hard to heard
- Newcomer unfriendly
Let's, please simplify the logic, document what is possible to be documented, outsource actual utilities such as link parsing and etc, to somewhere (we want to be able to reuse these bits of code as much as possible in different places), and keep the Hook real and simple
@@ -68,6 +68,7 @@ | |||
"@storybook/addon-interactions": "^7.0.8", | |||
"@storybook/addon-links": "^7.0.8", | |||
"@storybook/blocks": "^7.0.8", | |||
"@storybook/jest": "^0.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How often is this module maintained?
I'm worried that we're needlessly more and more adding packages to our website. I think, for now, it's okay, but let's keep this in mind. We don't want to have too many packages accidentally by the end of the day...
Let's keep this on mind!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module seems to be actively maintained. The last version about a month old.
Thanks for the reviews @ovflowd . I tried migrating with minimal modifications to the original code. I'll address all the issues and bring it up to better standards. |
Thank you, @Harkunwar! 🙇 |
We should put on home component ? |
cb8c95e
to
9243764
Compare
FYI: We deleted the Thank you, and we apologise for the inconvenience! |
Description
Migrates RandomContributor from nodejs.dev
Related Issues
#5193
Check List
npx turbo lint
to ensure the code follows the style guide. And runnpx turbo lint:fix
to fix the style errors if necessary.npx turbo format
to ensure the code follows the style guide.npx turbo test
to check if all tests are passing, and/ornpx turbo test:snapshot
to update snapshots if I created and/or updated React Components.