Space Tourism Website with HTML, CSS & JS

Solution retrospective
I am most proud of putting together a multipage page website that is responsive, and fuctional. I organized the project with separate pages for Destinations, Crew, and Technology, each with its own JavaScript file for managing interactivity. However, looking back at my code, if I were to tackle this challenge all over again, I would:
1. Use DRY (Don't Repeat Yourself) code principle: I noticed that my JavaScript files has code duplication across main.js, destination.js, crew.js, and tech.js. Next time, I'd create a single utility function that handles menu toggling and import it across all pages. This would reduce maintenance burden and follow the DRY principle.
2. Leverage a framework: I'd consider using React to create reusable components instead of managing separate HTML files. This would eliminate duplication in the HTML structure across pages and make updates much more efficient. React would also help with state management to remember user preferences.
3. Test and document: I'd add unit tests for JavaScript functions and more inline code comments to make the project easier for other developers to understand and contribute to.
What challenges did you encounter, and how did you overcome them?Among the many challenges I faced, here are a few significant ones:
Challenge 1: Responsiveness
Creating a website that looks great on mobile (560px), tablet (1024px), and desktop required careful planning of multiple layouts. The navigation bar had to transform from a horizontal desktop layout to a hidden hamburger menu on mobile, while the main content had to reflow between grid and flex layouts.
So,
- I used CSS media queries at 560px and 1024px breakpoints to adapt layouts
- Leveraged CSS Grid for desktop layout and Flexbox for mobile/tablet layouts
- Tested extensively on different device sizes to ensure smooth transitions between breakpoints
Challenge 2: Managing Duplication across multiple pages
With separate HTML files for each destination (Moon, Mars, Europa, Titan), crew member (4 pages), and technology (3 pages), I faced massive code duplication. Every page had the same header, navigation, and footer structure, making updates tedious and error-prone.
To overcome this challenge, I
- Created a shared
header.cssfile that all pages reference, ensuring consistent styling across the site - Used consistent HTML structure across all component pages (destination-moon.html, destination-mars.html, etc.)
- Committed to a strict file naming convention (e.g.,
destination-*.html,crew-*.html,technology-*.html)
Key Takeaway
I recognize this is where a framework like React would shine. I could create reusable components, for example <DestinationPage /> component that accepts props and dynamically renders different destinations without HTML duplication.
There are three key areas I would need help with. These include:
1. Refactoring for Code Reusability: I have a lot of duplicate code across my JavaScript files and HTML pages. I'd love help consolidating the repetitive structures into more reusable components or modules. I know I could make this DRY-er, and I'd like to learn the best approach for that.
2. Converting to a Framework: I'm interested in exploring how to migrate this project to React. I have the data structure ready in JSON, so I'm wondering about the best way to convert these static HTML pages into dynamic components without losing any functionality.
3. Performance Optimization: I want to make sure my site is as optimized as possible. I'd like help with:
- Image optimization and lazy loading
- Minifying CSS and JavaScript
- Improving overall load times
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on Caleb Abuul’s solution.
Join 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