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

Upgrades ProductCard component (adds subjects / GitHub info) [Closes #1782, Closes #1783] #1808

Merged
merged 50 commits into from
Nov 30, 2020
Merged

Conversation

wackerow
Copy link
Member

@wackerow wackerow commented Nov 13, 2020

Description

Adds pill-like component that pulls GitHub repo star count for projects listed on the site.
image
image

Only shows if gitAccount and gitRepo names are passed. Added these props to <ProductCard> components, and updated the data fed to them for sandboxes and frameworks.

Still need to update all of the /eth2/get-involved listings. --Update: done

Related Issue #1782

@wackerow wackerow marked this pull request as draft November 13, 2020 07:57
@ryancreatescopy
Copy link
Contributor

Should we add the GitHub icon to make it clearer we're pulling in github data?

@wackerow
Copy link
Member Author

@ryancreatescopy Any thoughts on where to put it? In the component? A separate indicator for each card? One larger indicator for these whole sections? My thought was squeezing more glyphs into a component like this would make it overly complicated (especially if you have both that and the star) and if someone doesn't know what the stars are, they probably don't care about them.

Just some thoughts, let me know what you think. Keep in mind I'm gonna work on a component with a horizontal/wrapping 'pill' list for each programming language... still trying to find the best way for it to all fit together nicely.

@samajammin
Copy link
Contributor

This is amazing!

Re: the GH icon / star layout, a couple options:

  • Keep as-is visually but have the component be a link to the GH repo, which would make it obvious where the data is coming from. Only potential issue I see with this is a link nested within a link, which is not technically valid HTML. Perhaps we add a button to the cards which act as the link to the project.
  • Display the GH icon with the word "stars", like this common widget:
    Image 2020-11-13 at 9 23 39 AM
    https://ghbtns.com/

Re: this approach to querying data:
Overall I think this is a valid v1 solution. One thing to consider is that this creates a network request on page load for every project we display, which is far from optimal. I think the ideal solution would be to query these project stars via GraphQL at build time (we already have the GH API available). In this case, the data would already be in the static HTML the user loads so we could avoid the delay & added load of all these network requests. The downside with this approach is that stars wouldn't dynamically update but given how often we deploy the site, I don't see this being a concern.

@wackerow
Copy link
Member Author

@samajammin Agree with everything, and you've iterated some of the issues I came across in v1. I originally made this a link until I realized it was already nested (at least when used in a ProductCard).
Had some small issues using the Icons component in the first draft because of the baked in hover-over coloring, but if we move this out of a nest link, it would no longer be an issue.... just not sure where to put it exactly, since it seems to belong right inside these product cards.
I'll peak at the ghbtns.com page and mull it over, but if anyone has any thoughts, all ears

Re: Querying
Good call, and I agree that at the rate this site gets rebuilt it shouldn't be an issue (stars don't add up that fast). I had mimicked the approach taken in the Roadmaps.js component, but that seems to just be one API call, not one call per item listed like this PR. Will look at this =)

@github-actions github-actions bot added the documentation 📖 Change or add documentation label Nov 14, 2020
@wackerow
Copy link
Member Author

image
@samajammin @ryancreatescopy Let me know what you think of this approach. The whole bar is clickable to go to github repo.

Note, links work but there is a nesting issue still which I will address (which will also address the small issue of the background highlighting going away when hovering over the project image). Also, this has not been refactored to use graphql for api calls, and there may be issues with rate limiting for-the-moment.

/developers/learning-tools/
removed redundant font-size style
added DEV boolean to test layout with this on top vs bottom. removed unneeded styling. increased padding by 50% and font size of star count from `xs` to `s`.
turquoise, yellow, mint, pink were all defined with hex strings lacking the leading "#", this corrects it
@ryancreatescopy
Copy link
Contributor

If we don't show the GitHub stars/button, we should avoid having so much margin above the title:
image

@wackerow
Copy link
Member Author

Updates:

  • No GitHub information on educational materials (which includes everything at /developers/learning-tools/)
  • Educational products contain hard-coded array of "subjects" they are designed to teach, placed as colored pills below product description
  • Other developer products (eth2 clients / local frameworks) do not have a 'subject array' but do have GitHub information, including API pulls for the top 1 or 2 programming languages used for the repo, and pulling repo star count
  • Star count shown in small upper-right widget with GitHub icon and star emoji
  • Hover over button links to GitHub and highlights entire button contents including Icon
  • GitHub repo languages populate below description as colored pills
  • Eth2 Clients restricted to only show primary language
  • Title of product has conditional margin to shift if github widget is present
  • GitHub widget aligns with edge of bottom button
  • Bottom button replaces the link previously placed on the entire product card (prevents nested links)
  • On card hover: Shadows reduced, and background highlighting removed
  • Fix mobile glitch where subject pills were collapsing and clipping

@samajammin @ryancreatescopy ... I think this is just about everything discussed. I'd say it's ready for review.

@wackerow
Copy link
Member Author

One last note: I know it was commented about the use of 'web3' as a subject (ie. Consensys bootcamp). This can obviously be changed, but my reasoning for keeping it in at the moment is because, yes, this is truly javascript or typescript, but if someone knows javascript and they are looking to learn about Ethereum, they may not be interested in just seeing "JavaScript" since it's not obvious by that label alone that it's something new to them.
I haven't taken this Concensys course, but my assumption is they are not teaching vanilla javascript, but instead are teaching web3 which utilizes JS/TS.

Options:
1- Switch it to JavaScript and/or TypeScript
2- Perhaps change to something like web3 / JS
3- Leave as web3 subject matter and adjust with future PR if needed

@wackerow wackerow changed the title Adds GitHub bar to ProductCard component [Closes #1782, Closes #1783] Upgrades ProductCard component (adds subjects / GitHub info) [Closes #1782, Closes #1783] Nov 18, 2020
reverts `display` back to inline for SubjectContainer to allow native wrapping of tags if list is longer, and removes negative margin-top on pill (adjusted container margin) and adds margin-bottom in case of multiple rows
eliminates need for hard-coding in a color for each subject tag, improving flexibility to add new subjects, and no subjects default to gray. Offset can be used to adjust theme coloring.
Copy link
Contributor

@samajammin samajammin left a comment

Choose a reason for hiding this comment

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

This looks really solid! Left a handful of comments, then I think this is ready to merge. Awesome work.

I think there's still some polishing we may want to do re: the programming language tags but I think we wait to tweak that later if needed in a separate PR.

@wackerow just a note for future PRs: whenever possible let's try to isolate changes into individual PRs. I can understand including the programming language tags in this PR since those are also fed from the GitHub API but I would've liked to see that separated. I think keeping this PR focused solely on the GitHub stars widget would have keep the conversation more focused & would have allowed this contribution to get merged faster.

Thanks again!

import Link from "./Link"

const Container = styled(Link)`
margin-right: -0.5rem;
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally I'm not a fan of negative margin - why is this needed here? If we want these components to be aligned further right, I suggest we reduct the padding of the card content.


const GlyphPill = styled(Pill)`
display: flex;
flex-direection: row;
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo here, but you can just remove this line (flex-direction defaults to row)

openzeppelin: file(relativePath: { eq: "devtools/openzeppelin.png" }) {
...devtoolImage
}
openzeppelinGitHub: github {
repository(owner: "OpenZeppelin", name: "openzeppelin-contracts") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
repository(owner: "OpenZeppelin", name: "openzeppelin-contracts") {
repository(owner: "OpenZeppelin", name: "openzeppelin-sdk") {

Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong repo 😄

@@ -274,6 +274,7 @@ const frameworksList = [
name: "Waffle",
description:
"The most advanced testing lib for smart contracts. Use alone or with Scafold-eth or Hardhat.",
gitHubUrl: "https://github.com/EthWorks/waffle",
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're already using the GitHub API to pull in star counts, we could also use the API to pull in GitHub URL. See example code in my comment below.

src/pages-conditional/developers/local-environment.js Outdated Show resolved Hide resolved
@wackerow
Copy link
Member Author

Sorry for delay here, after rebasing the sizing broke. Found what had changed and cleaned up an unnecessary nested div that was causing issues, it now lays out the way it had been, with slight tweaks to align tags after talking with @ryancreatescopy

image
image
image

Copy link
Contributor

@samajammin samajammin left a comment

Choose a reason for hiding this comment

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

This is great! Thanks for your persistence on this 💪

@samajammin samajammin merged commit 9b22fbb into ethereum:dev Nov 30, 2020
@wackerow
Copy link
Member Author

Hooray! haha no problem =)

@wackerow wackerow deleted the w/gitstars#1782 branch November 30, 2020 22:07
@samajammin samajammin mentioned this pull request Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content 🖋️ This involves copy additions or edits documentation 📖 Change or add documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants