Skip to content

A React application featuring a "Cosmic Encyclopedia" that leverages React Router v6 for dynamic navigation between various celestial objects (planets, stars, galaxies, nebulae). Demonstrates route setup, dynamic content loading based on parameters, and enhanced navigation with a back button.

Notifications You must be signed in to change notification settings

Laruschkaj/cosmic-encyclopedia-

Repository files navigation

Cosmic Encyclopedia 🌌

A React application designed to help users explore the vast wonders of space. This project leverages React Router v6 to provide efficient navigation and a seamless user experience across different "pages" dedicated to planets, stars, nebulae, and galaxies, showcasing fascinating facts about each celestial object.

Features

  • Dynamic Navigation: Seamlessly navigate between different categories of celestial objects (Planets, Stars, Galaxies, Nebulae) using React Router.
  • Dynamic Content Pages: Each celestial object has its own dedicated URL and page, with content loaded dynamically based on route parameters (e.g., /planets/earth).
  • Intuitive Navigation Bar: A NavBar component provides clear links for smooth transitions between main categories.
  • Informative Homepage: An initial HomePage introduces users to the Cosmic Encyclopedia.
  • Enhanced Navigation: A NavigateBackButton utility component allows users to easily return to previous pages in their browsing history.
  • Structured Data: Utilizes a local dataset of celestial objects, complete with IDs, titles, and detailed content.

Component Architecture

The application is built with a clear, component-based structure to manage functionality and navigation:

  • App: The root component, responsible for orchestrating the main layout and setting up the React Router configuration.
  • NavBar: Provides the primary navigation links for different celestial object categories.
  • HomePage: The initial landing page, offering an introduction to the encyclopedia.
  • ContentPage: A dynamic component that displays specific celestial object content. It adapts to show different information based on the current route parameters (e.g., the ID of a planet or star).
  • NavigateBackButton: A reusable utility component that allows users to go back in their browser history.

Technologies Used

  • React: Frontend JavaScript library for building user interfaces.
  • React Router DOM v6: Powerful library for declarative routing in React applications, utilizing createBrowserRouter, RouterProvider, Outlet, useParams, and Navigate.
  • Vite: Fast build tool and development server for modern web projects.
  • JavaScript (ES6+)
  • HTML5
  • CSS3

How to Run Locally

Follow these steps to get the Cosmic Encyclopedia running on your local machine:

  1. Clone the repository:

    git clone [https://github.com/YOUR_USERNAME/cosmic-encyclopedia.git](https://github.com/YOUR_USERNAME/cosmic-encyclopedia.git)

    (Replace YOUR_USERNAME with your actual GitHub username)

  2. Navigate into the project directory:

    cd cosmic-encyclopedia
  3. Install dependencies:

    npm install
  4. Start the development server:

    npm run dev

    The application should open in your browser, typically at http://localhost:5173/.

Key React Concepts Applied

This project serves as a comprehensive demonstration of advanced React and React Router concepts:

  • React Router v6 Setup: Implemented the modern routing setup using createBrowserRouter and RouterProvider.
  • Nested Routes & Layouts: Organized routes into logical hierarchies, potentially utilizing shared layouts (e.g., a common layout for all celestial object pages).
  • Route Parameters (:id): Dynamically loaded content for ContentPage by extracting IDs from the URL using the useParams hook.
  • Data Fetching with Loaders (Conceptual): While using local static data for simplicity, the project structure is prepared for data fetching via React Router loader functions, simulating API interactions.
  • Programmatic Navigation (Navigate Component): Used the Navigate component to handle conditional redirects or back navigation.
  • Component-Based Architecture: Breaking down the UI into modular and reusable components.
  • State Management: Managing UI state within components.
  • User Experience: Enhancing navigation with a dedicated back button.

Happy exploring the cosmos!

About

A React application featuring a "Cosmic Encyclopedia" that leverages React Router v6 for dynamic navigation between various celestial objects (planets, stars, galaxies, nebulae). Demonstrates route setup, dynamic content loading based on parameters, and enhanced navigation with a back button.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published