Skip to content

Client diversity piechart update#15251

Closed
LifeofDan-EL wants to merge 54 commits into
ethereum:devfrom
LifeofDan-EL:client-diversity
Closed

Client diversity piechart update#15251
LifeofDan-EL wants to merge 54 commits into
ethereum:devfrom
LifeofDan-EL:client-diversity

Conversation

@LifeofDan-EL
Copy link
Copy Markdown
Contributor

@LifeofDan-EL LifeofDan-EL commented Apr 7, 2025

Description

This PR is to create a new piechart that changes depending on the values, which is to be used to update the client diversity part of the website.

Preview link

https://deploy-preview-15251--ethereumorg.netlify.app/en/developers/docs/nodes-and-clients/client-diversity/

Related issue

@github-actions github-actions Bot added the content 🖋️ This involves copy additions or edits label Apr 7, 2025
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 7, 2025

Deploy Preview for ethereumorg failed.

Name Link
🔨 Latest commit a24736b
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/68ded3954474ed00083a300c

@github-actions github-actions Bot added the dependencies 📦 Changes related to project dependencies label Apr 7, 2025
@LifeofDan-EL
Copy link
Copy Markdown
Contributor Author

Deploy is failing, at first, I thought it was a lint error, so I fixed that with npx eslint ./src/components/MdComponents/index.tsx --fix but it is still failing.

Copy link
Copy Markdown
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

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

@LifeofDan-EL left a comment about the issue we have.

On the other hand, there are a few files in this PR that shouldn't be modified/added/deleted like yarn.lock, .env.example, and some yarn related ones that are not necessary. Can help you clean them up once we have a working preview.

sidebarDepth: 2
---

import { PieChart } from "@/components/PieChart"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This import is redundant now that we are injecting the component in the MdComponents file.

Also, next-mdx-remote (the mdx compiler that we use) doesn't support imports or exports, so we need to do something different to pass the below data to the component.

I think the easiest would be to pass the data array inline like this:

<PieChart data={[ { name: "Geth", value: 43 }, ... ]} title="Execution Clients" />

To clarify more, you can't use variables like executionData without exporting them in mdx. But since imports/exports are not supported, we can't use them either.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @pettinarip for the clarification, it was an oversight pushing the yarn file. Thanks again.

Copy link
Copy Markdown
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

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

@LifeofDan-EL good job. The implementation looks good and is functional. Left a comment about the styles to try to align it with our current design system.

Comment thread src/components/PieChart/index.tsx Outdated
* Color palette for blue shades, ordered from deep blue (largest share) to light blue (smallest share).
* Ensure your data is sorted from largest to smallest for this to work as intended.
*/
const COLORS = [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are a few issues with these colors:

  • there is not enough contrast in dark mode
  • these are not part of our current color palette

This is the current colors that we have https://dev--63b7ea99632763723c7f4d6b.chromatic.com/?path=/story/design-system-colors--primitives

@konopkja what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I looked at the preview after deployment and I agree there isn't enough contrast. Let me use values from the colour palette.

Comment thread .yarn/install-state.gz
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file is not needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Resolved.

Comment thread .yarnrc.yml
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file is not needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Resolved.

@konopkja
Copy link
Copy Markdown
Contributor

Screenshot 2025-04-11 at 17 08 25 Screenshot 2025-04-11 at 17 08 36

seems like dark mode / light mode have some contrast issues, on dark mode its the upper part , on light mode its the opposite part

@konopkja
Copy link
Copy Markdown
Contributor

lets use accent colors here

@pettinarip
Copy link
Copy Markdown
Member

lets use accent colors here

here is the list of accent colors in our tw config

Copy link
Copy Markdown
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

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

@LifeofDan-EL looking good. I think there is one thing we should polish with the chart implementation before we can get this in.

Comment thread src/components/PieChart/index.tsx Outdated

import { PieChart } from "./PieChart";

const PieChartContainer = () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PieChartContainer component is tightly coupled to the client diversity use case making it hard to reuse.

We have different options to fix this. One could be to create a new component called ClientDiversityChart with the current layout and copy, making it clearer that this is for the client diversity page.

  // current implementaiton
  <PieChartContainer />

  // proposal: data lives in the md file and is wrapped with the new `ClientDiversityChart` component
  // PieChart is already reusable +1
  <ClientDiversityChart>
    <PieChart data={[...]} title="Client Diversity" />
    <PieChart data={[...]} title="Client Diversity" />
  </ClientDiversityChart>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, you're correct. Let me get to work on this.

@github-actions
Copy link
Copy Markdown
Contributor

This issue is stale because it has been open 30 days with no activity.

@github-actions github-actions Bot added the Status: Stale This issue is stale because it has been open 30 days with no activity. label Aug 17, 2025
@LifeofDan-EL LifeofDan-EL requested a review from asanso as a code owner October 2, 2025 15:45
@github-actions github-actions Bot added documentation 📖 Change or add documentation event 📅 This issue or pull request is related to an event listing tooling 🔧 Changes related to tooling of the project translation 🌍 This is related to our Translation Program labels Oct 2, 2025
@LifeofDan-EL
Copy link
Copy Markdown
Contributor Author

I had to make sure things were in sync with the current dev before continuing.

@wackerow
Copy link
Copy Markdown
Member

wackerow commented Oct 2, 2025

Thanks @LifeofDan-EL! Will take a look shortly

@LifeofDan-EL
Copy link
Copy Markdown
Contributor Author

Thanks @LifeofDan-EL! Will take a look shortly

Thanks, it is compiling but, the build is failing weirdly and I have no clue how to fix that. I would appreciate the help. Thanks.

@wackerow wackerow added feature ✨ This is enhancing something existing or creating something new and removed Status: Stale This issue is stale because it has been open 30 days with no activity. abandoned This has been abandoned or will not be implemented content 🖋️ This involves copy additions or edits translation 🌍 This is related to our Translation Program dependencies 📦 Changes related to project dependencies tooling 🔧 Changes related to tooling of the project event 📅 This issue or pull request is related to an event listing config ⚙️ Changes to configuration files labels Oct 2, 2025
Copy link
Copy Markdown
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

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

Phew! 😮‍💨... first of all, appreciate the work you've put into this @LifeofDan-EL! Handful of stuff to address, but it's still a lot of progress and I think we can get through this...

First, there are some extraneous updates in this PR that need to be reverted, and are causing issues:

  1. The .prettierrc file has been deleted—this must be reverted
  2. That deletion led to auto-formatting updates that must also be reverted, e.g., the addition of trailing semi-colons, which the prettier config would normally prevent
  3. The MdComponents/index.tsx should only include the addition of the new component we're building, but everything else should remain unchanged
  4. We use pnpm for package management, so nothing yarn-related should be in here

Second, file naming and re-usability... This PieChart component looks decent in terms of reusability at this point, but we should rename the file to PieChart/index.tsx... I have some suggestions to clean up the errors we're getting, but it was done quickly and I think we need a couple small layout adjustments still, and with those we should be careful to pay attention to how this component will work with any set of data we feed it on any page we place it. Techniques here can include making sure className is passed properly as a prop, and merged with the base classes using cn("base classes", className) syntax imported from @/lib/utils/cn. This lets us customize on a case-by-case bases when we consume this component from a parent page or other component.

Third... typing. We should not ignore the eslint rules, including the bypassing of the no-explicit-any rules. There are ways we can make the typing robust to avoid needing to do this.

https://gist.github.com/wackerow/ced8f9db60cdebfe5720234227d24198

Locally I made some adjustments and saved them to this gist which you should be able to view. The exact layout adjustments should be taken with a grain of salt here, but more importantly are the updates to the typing, which eliminates the usage of any or even unknown, since we do indeed know the types we'll need.

import type { Formatter } from "recharts/types/component/DefaultLegendContent"

See line 148 for example of how this is used, and the next line for how we can make sure the payload value is indeed a number before proceeding.

It also demonstrates a few other things such as:

  • Usage of guard clauses to return early if certain conditions aren't met (Line 170, line 174)
  • Usage of tailwind class names instead of style props where possible
  • Updates the stroke color on the pie chart to use full digit-character hex codes—the three character shorthand form wasn't working for me
  • Removes the angular gap which made things look goofy

Lastly is the custom wrapper component, ClientDiversityChart/index.tsx... overall this looks decent but a couple notes:

  • Our component will automatically parse the href and apply the target and rel for any external links, so these additions are redundant and can be removed... Also we should use standard styling, so can also remove the className="underline" here.
  • A slightly more challenging step which is a nice-to-have for this PR, would be setting these English strings up for translation. The markdown file works a bit differently, where that entire file will be translated and separately translation-specific copies will be imported through a separate work stream, but for React pages/components such as the few English strings in here it works a bit differently. Honestly, I wouldn't worry about this for the sake of this PR, but we'll need to make sure that when this is completed that we tee-up a follow-up task to extract these strings into a JSON file within src/intl/en/**.json where they can then be references via a unique key identifier, instead of hard-coded. Just noting for your understanding.

For the sake of this PR, you may want to consider simply closing this branch out and starting fresh by:

  1. branching off of an up-to-date dev branch
  2. creating the new ClientDiversityChart/index.tsx and PieChart/index.ts components fresh
  3. Importing what is necessary into MdComponents/indes.tsx
  4. Updating the index.md file where the chart will be used (that part shouldn't need to change at all from what I can tell)

This will help clean up the rest of the regressions and make things easier to review, and should help the build pass successfully.

Again, thanks so much for the help here... hopefully that gist link helps provide the guidance needed to get this patched up so we can get it over the line. Let us know if you have any other issues!

@LifeofDan-EL
Copy link
Copy Markdown
Contributor Author

Thanks so much @wackerow for the detailed eye. I will close this PR and work on it afresh, incorporating the feedback with a new branch.

@wackerow
Copy link
Copy Markdown
Member

wackerow commented Oct 3, 2025

@LifeofDan-EL Sounds great! Appreciate that, should help tidy things up =)... going to close this one out for now, looking forward to the update

@wackerow wackerow closed this Oct 3, 2025
@github-actions github-actions Bot added the abandoned This has been abandoned or will not be implemented label Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

abandoned This has been abandoned or will not be implemented documentation 📖 Change or add documentation feature ✨ This is enhancing something existing or creating something new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update or revamp client diversity

4 participants