Footer

The footer is an area at the bottom of a document page containing data common to other pages.

Preview

Usage

npm i react-hartan
import { Footer } from "react-hartan"

function App() {

  return (
    <>
      <Footer></Footer>
    </>
  )
}

export default App

Customization With Props

  • footerList -> Required to be sent by the user, accepts an array of objects, where each element is an object of the structure:

{
    footerLinkHeading: "", 
    footerLinks: [
        {
            footerLinkName: "", 
            footerLinkSrc: "", 
        }
    ]
}

// footerLinks is an array of objects with above structure

NOTE: Keep the name of the keys same as above.

  • copyrightYear -> Accepts a string value, a year which is shown in the footer.

  • copyrightName -> Accepts a string value, a name to be shown in the footer.

  • id -> The id prop is similar to the id attribute in HTML. It allows to provide overall component id.

  • userFooterStyle -> Custom styling prop for the full footer section.

  • userLinksStyle -> Custom styling prop for full links container.

  • userFooterLinksStyle -> Custom styling prop for each link container inside the full links container.

  • userLinksDataStyle -> Custom styling prop for link data container.

  • userCopyrightStyle -> Custom styling prop for the copyright container.

import { Footer } from "react-hartan"

function App() {

  return (
    <>
      <Footer></Footer>
    </>
  )
}

export default App

Component Code

This is the code for Footer component.

import footerStyles from "./Footer.module.css"
import PropTypes from "prop-types"


export const footerLinksArray = [
  {
    footerLinkHeading: "Follow Us",
    footerLinks: [
      {
        footerLinkName: "GitHub",
        footerLinkSrc: "https://github.com/akkshayTandon/react-hartan-js"
      },
      {
        footerLinkName: "LinkedIn",
        footerLinkSrc: ""
      },
      {
        footerLinkName: "Instagram",
        footerLinkSrc: ""
      },
      {
        footerLinkName: "YouTube",
        footerLinkSrc: ""
      }
    ]
  },
  {
    footerLinkHeading: "Support",
    footerLinks: [
      {
        footerLinkName: "Gomtinagar and Daliganj, Lucknow",
        footerLinkSrc: ""
      },
      {
        footerLinkName: "hartanlibrary@gmail.com",
        footerLinkSrc: "mailto:hartanlibrary@gmail.com"
      },
      {
        footerLinkName: "9999999999",
        footerLinkSrc: ""
      },
      {
        footerLinkName: "9999999999",
        footerLinkSrc: ""
      }
    ]
  }
];

export default function Footer({ footerList = footerLinksArray, copyrightYear = "2024", copyrightName = "Hartan Library", id, userFooterStyle, userLinksStyle, userFooterLinksStyle, userLinksDataStyle, userCopyrightStyle }) {

  return (
    <footer id="" className={`${userFooterStyle}`}>

      <div className={`${footerStyles.links} ${userLinksStyle}`}>
        {footerList.map((footerLink, id) => {
          return (
            <div className={`${userFooterLinksStyle}`} key={id}>
              <h2>
                {footerLink.footerLinkHeading}
              </h2>
              <div className={`${footerStyles.linksdata} ${userLinksDataStyle}`}>
                {footerLink.footerLinks.map((link, id) => {
                  return (
                    <li key={id}>
                      <a href={link.footerLinkSrc}>
                        {link.footerLinkName}
                      </a>
                    </li>
                  );
                })}
              </div>
            </div>
          );
        })}
      </div>

      <div className={`${footerStyles.copyright} ${userCopyrightStyle}`}>
        <p>
          Copyright © {copyrightYear} {copyrightName} — All rights reserved by
          <strong> {copyrightName} </strong>
        </p>
      </div>

    </footer>
  );
}

Footer.propTypes = {
  footerList: PropTypes.arrayOf(PropTypes.shape({
    footerLinkHeading: PropTypes.node,
    footerLinks: PropTypes.arrayOf(PropTypes.shape({
      footerLinkName: PropTypes.node,
      footerLinksrc: PropTypes.string
    }))
  })),
  copyrightYear: PropTypes.string,
  copyrightName: PropTypes.string,
  id: PropTypes.string,
  userFooterStyle: PropTypes.string,
  userLinksStyle: PropTypes.string,
  userFooterLinksStyle: PropTypes.string,
  userLinksDataStyle: PropTypes.string,
  userCopyrightStyle: PropTypes.string
};

Last updated