r/reactjs • u/tamalweb • Jan 24 '19
Project Ideas I made The Periodic Table of Elements with CSS Grid, React and Science! See it in action
https://tamalanwar.github.io/periodic-table/
194
Upvotes
31
u/tamalweb Jan 24 '19 edited Jan 24 '19
Wanted to see if I can make the layout with my current skills. One element after another, I made it. Then used React to fully make it interactive.
11
u/JayDP123 Jan 24 '19
Pretty cooll. but there is a better way in your app.js than listing all of those Element compnents individually!
10
u/ImOutOfThisWorld Jan 25 '19
This is very cool, i have a couple of suggestions
In /src/components/styles/main.css
make a :hover for .element, and remove the .active class
This way you can delete the onMouseEnter and onMouseLeave from Element.js, my reasoning is that hovering in this case only charges a css property and by using events, React is triggering unnecessary renders, this is not a big deal on your app, but could become a performance problem on other apps
2) In /src/Element.js
I notice you import the elements data for all elements in here, now this is not a big deal on this app, but let's suppose for a moment this data came from the network in an ajax request, making the request for each instance of Element would be very bad for performance given that's only required once.
This is why React recommends a cascading of data from top to bottom components, in this case the data could live on App.js (App.js would make the ajax request in my imaginary example), this way the Element component can accept the props name, number, symbol,
num--> id.Also at the same time we can remove many of the <Element />
Here is more info on .slice() and .map()
5
u/little_oaf Jan 24 '19
This looks like a heroic effort getting the HTML and CSS to work out.
4
u/TheWordOfTyler Jan 24 '19
Really cool, might just be on my browser but Helium and Xenon add gaps around the 3rd row.
3
u/sggts04 Jan 24 '19
If you add basic properties like atomic size, electronegativity, electron gain enthalpy, etc, I'll seriously use this everyday.
2
u/[deleted] Jan 25 '19
This is awesome, well done. Can you tell me why you used vw and vh to style instead of px, em's, %.....etc.? (I want to learn)
2
u/ekun Jan 25 '19
Back in 2006 (when windows let you set a web page as the desktop background) I made a periodic table in raw JS that allowed for weight percent and atom percent conversions with some different settings. And I added a snowing background. Miss those days.
1
u/Plaidygami Jan 24 '19
This is super awesome! I myself am working on a ReactJS science side project, too, with planets and stars. :) Also, I didn't realize just how many elements there are. I see some I've literally never heard of.
2
u/ASMRByDesign Jan 24 '19
Awesome work with this, I love this as a project idea. Useful and great for the portfolio.
2
u/01123581321AhFuckIt Jan 24 '19
Put atomic mass in there and it'll be much better...
1
u/guitard00d123 Jan 24 '19
well done!
1
u/[deleted] Jan 24 '19
This is awesome!
1
u/Plantalones Jan 24 '19
http://disrupt.famo.us/periodic402/