Design comparison
Solution retrospective
Any constructive feedback is welcome :)
Technologies used
- ReactJS, Vite, React Router Dom, Jest(https://www.npmjs.com/package/jest)
- Custom CSS
- Google fonts
What I learned
Using props for CSS
- To avoid rewriting code, I learned to use props for CSS, for example:
<div className={props.anyClassNameHere}> </div>
Scaling SVGs
- During this I have learned to scale SVGs with the transform property, by taking the width and height of the SVG and adapting that.
- For example, if the SVG was 'width: 450' the css property would be:
.svg-image { transform: scale(0.45); }
- You can then use this and adapt it for different screen sizes, for example I added 10 for tablets and small screens and an extra 30 for desktops.
Nested routes in react router dom
-
In react router dom, they have nested routes so that you can have multiple navigations on one page.
-
For example in the main App/Routes component you can have:
<Route path='/mercury' element={<Components.MercuryNav/>}> <Route index element={<Pages.MercuryOverview/>}/> <Route path='structure' element={<Pages.MercuryStructure/>} /> <Route path='surface' element={<Pages.MercurySurface/>} /> </Route>
- Then in the component you would Links or NavLinks like:
<NavLink to='/mercury' end><span>01</span> Overview </NavLink> <NavLink to='/mercury/structure'><span>02</span> Structure </NavLink> <NavLink to='/mercury/surface'><span>03</span> Surface </NavLink>
- Note: NavLink comes with an isActive/.active class to easily style the links, whilst Link does not.
Useful resources
-
React Router Dom - Nestest Routes - This article helped to understand nested routes in react router dom, I'd recommend it to anyone still learning this concept.
-
React Router Docs - This is the react router documentation - Read it, documentation is good!
-
Scaling SVGS - CSS-Tricks helps with any CSS needs, this article explains SVGS in detail.
Community feedback
- @sankalpsinghaPosted about 1 year ago
Good work! I like the README.md its well structured and also states all the things that you learnt. I think you can add them to your description as well here? Also, the references to the links is a nice touch. And the micro info about the things that you learnt.
Perhaps the next step is to move to TS instead of the standard JS? And also writing Jest or E2E in Cypress tests as well?
How long did it take for this project?
1@Beckibuzz93Posted about 1 year ago@sankalpsingha Thanks for your feedback :) This is my first solution here, I'll check out how to add that info here too.
The next step for me is to learn TS. I've looked into E2E before as well, it looks very useful, will check out Cypress thanks for the suggestions.
From start to finish, this project took a month, this was not working on it everyday, so in days coding, it took around 2 weeks.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord