Homepage Components
Homepage Components: Hero, InfoxBox, InfoBoxes, Footer
1. Create the Hero Component
a. Set Up the File
In your
components/
folder, create a file named Hero.jsx.Mark it as a React component (since it will display static content for now).
b. Extract and Convert the Markup
Open your index.html and locate the hero section (the section with a background, a heading, a paragraph, and a search form).
Copy the HTML markup for the hero section.
In Hero.jsx, paste the markup inside a functional component and update the attributes:
Replace all instances of
class
withclassName
.Adjust any other HTML-specific syntax (e.g., self-closing tags).
Example Structure:
2. Create Reusable InfoBox Component
a. Set Up the File
In the
components/
folder, create InfoBox.jsx.This component will accept props (like heading text, background color, text color, and button configuration) so it can be reused.
b. Build the Component Structure
Define a functional component that uses props to dynamically set its content and styling.
Example Structure:
Note: Customize default props as needed so that you can easily change backgrounds and text colors when using the component.
3. Create the InfoBoxes Container Component
a. Set Up the File
In the
components/
folder, create InfoBoxes.jsx.This component will serve as a grid/container that holds multiple InfoBox components.
b. Build the Component Structure
Import the InfoBox component and use it to display different information blocks side-by-side.
Example Structure:
4. Create the Footer component
a. Set Up the File
In the
components/
folder, create Footer.jsx.This component will serve as a Footer components.
b. Build the Component Structure
Copy the HTML markup for the footer section.
In Footer.jsx, paste the markup inside a functional component and update the attributes:
Replace all instances of
class
withclassName
.Adjust any other HTML-specific syntax (e.g., self-closing tags).
Example Structure:
5. Integrate Components into the Home Page
a. Update the Home Page File
In the
app/
folder, open page.jsx (your homepage component).
b. Import the Components
Import the Hero and InfoBoxes components:
c. Insert the Components in the Home Page Layout
Arrange your homepage by including the components. For example:
5. Test and Refine
a. Run the Development Server
Start your application with:
Navigate to http://localhost:3000 to see the home page with the Hero and InfoBoxes components.
b. Verify Responsiveness and Styling
Check that:
The Hero section appears as designed with the search form.
The InfoBoxes grid displays two boxes side-by-side on larger screens and stacks on mobile.
The InfoBox component correctly applies the dynamic styles (background and text colors) and displays button links as configured.
c. Adjust as Needed
Refine Tailwind CSS classes for spacing, responsiveness, and overall aesthetics.
Update props or component logic as your design or functionality evolves.
Recap
Hero.jsx:
Created by extracting and converting the hero section from the theme in index.html.
InfoBox.jsx:
A reusable component that accepts props for dynamic headings, colors, and button configuration.
InfoBoxes.jsx:
A container grid that holds multiple InfoBox components.
Footer.jsx
Homepage Integration:
Imported and arranged the Hero and InfoBoxes components on the home page (app/page.jsx) to drive user engagement.
Testing:
Ran the development server, verified the layout and responsiveness, and refined styling as needed.
Last updated