Hands-on Practice II

Step-by-step Walkthrough to Build the AppTravel.jsx React Application

Step 1. Create the React App Structure

  1. Open your terminal and run the following commands to create and navigate to the project directory:

  2. Open visual studio code and open terminal

  1. Install Bootstrap for styling:

  1. Import Bootstrap in the App.jsx file:


Step 2. Set Up the Components Folder

  1. Inside the src folder, create a new folder named components.

  2. Add the following files inside the components folder:

    • Header.jsx

    • TravelEntry.jsx

    • travelData.js


Step 3. Add the travelData.js File

  1. Add the provided travel data as an array of objects. Example:


Layout Design

  1. APP.jsx Layout

  1. TravelEntry.jsx Layout

Step 4. Create the Header.jsx Component

  1. This component will display a header with a globe icon and a title.

  2. Structure:

    • Use a div with Bootstrap classes for a responsive design.

    • Include a globe icon (use an online icon or Font Awesome).

  3. Example:

    • Use the d-flex justify-content-center align-items-center Bootstrap classes for alignment.

    • Set a background color and padding using Bootstrap utility classes.


Step 5. Create the TravelEntry.jsx Component

  1. This component will display individual travel entries within an article container.

  2. Structure:

    • Use a two-column layout:

      • Left Column: Display the main image.

      • Right Column: Include:

        • Map marker icon, country name, and Google Maps link.

        • Title, dates, and description text.

    • Use Bootstrap’s grid system for the layout.

  3. Suggested Bootstrap Classes:

    • row for the flex-row layout.

    • col-md-4 for the image column.

    • col-md-8 for the content column.

    • Use spacing utilities like mb-3, p-2, etc.


Step 6. Update App.jsx

  1. Import Header, TravelEntry, and travelData.

  2. Map over the travelData array to dynamically render a TravelEntry component for each item.

  3. Pass the travel entry data as props to TravelEntry.


Step 7. Applying Bootstrap Styling

  1. Header.jsx:

    • Add a background color with bg-warning or a custom class.

    • Use text alignment utilities (text-center) for centering the title.

  2. TravelEntry.jsx:

    • Use the grid system (row, col) for layout.

    • Add spacing with utilities (mt-3, p-3, etc.).

    • Style the map marker and Google Maps link for better visibility.


Step 8. Final Steps

  1. Save all files and start the development server:

  2. Check the following:

    • The header appears at the top with a globe icon and title.

    • Each travel entry is displayed in a two-column layout with the provided data.

    • The application is styled using Bootstrap.


Step 9. Additional Notes

  • Adjust column widths using Bootstrap’s responsive grid classes (col-sm, col-md, col-lg) for different screen sizes.

  • Test the links to ensure that they redirect to Google Maps correctly.

  • Enhance accessibility by adding alt attributes to images and meaningful aria-labels to links.

This procedure ensures you build the application with proper styling using Bootstrap and dynamic rendering using React components. Let me know if you need clarification on any step!

Last updated