@massds/mayflower-react
Version:
React versions of Mayflower design system UI components
120 lines (111 loc) • 5.4 kB
JavaScript
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
/**
* Footer module.
* @module @massds/mayflower-react/Footer
* @requires module:@massds/mayflower-assets/scss/03-organisms/footer
* @requires module:@massds/mayflower-assets/scss/02-molecules/footer-links
* @requires module:@massds/mayflower-assets/scss/01-atoms/sidebar-heading
* @requires module:@massds/mayflower-assets/scss/02-molecules/social-links
*/
import React from "react";
import PropTypes from "prop-types";
import FooterLinks from "../FooterLinks/index.mjs";
import SocialLinks from "../SocialLinks/index.mjs"; // eslint-disable-next-line import/no-unresolved
import IconArrow from "../Icon/IconArrow.mjs";
const today = new Date();
const year = today.getFullYear();
const Footer = (_ref) => {
let footerLinks = _ref.footerLinks,
socialLinks = _ref.socialLinks,
_ref$footerText = _ref.footerText,
_ref$footerText$copyr = _ref$footerText.copyright,
copyright = _ref$footerText$copyr === void 0 ? year + " Commonwealth of Massachusetts." : _ref$footerText$copyr,
_ref$footerText$descr = _ref$footerText.description,
description = _ref$footerText$descr === void 0 ? 'Mass.gov® is a registered service mark of the Commonwealth of Massachusetts.' : _ref$footerText$descr,
_ref$footerText$priva = _ref$footerText.privacyPolicy,
privacyPolicy = _ref$footerText$priva === void 0 ? {
text: 'Mass.gov Privacy Policy',
url: 'https://www.mass.gov/privacypolicy'
} : _ref$footerText$priva,
_ref$footerLogo = _ref.footerLogo,
_ref$footerLogo$domai = _ref$footerLogo.domain,
domain = _ref$footerLogo$domai === void 0 ? '/' : _ref$footerLogo$domai,
_ref$footerLogo$title = _ref$footerLogo.title,
title = _ref$footerLogo$title === void 0 ? 'Mass.gov homepage' : _ref$footerLogo$title,
src = _ref$footerLogo.src,
_ref$showNavHeading = _ref.showNavHeading,
showNavHeading = _ref$showNavHeading === void 0 ? false : _ref$showNavHeading,
_ref$backToTopButton = _ref.backToTopButton,
backToTopButton = _ref$backToTopButton === void 0 ? false : _ref$backToTopButton;
return /*#__PURE__*/React.createElement("footer", {
className: "ma__footer js-footer",
id: "footer"
}, /*#__PURE__*/React.createElement("div", {
className: "ma__footer__container"
}, /*#__PURE__*/React.createElement("section", {
className: "ma__footer__info"
}, /*#__PURE__*/React.createElement("div", {
className: "ma__footer__logo"
}, /*#__PURE__*/React.createElement("a", {
href: domain,
title: title
}, /*#__PURE__*/React.createElement("img", {
src: src,
alt: "",
width: "100",
height: "100"
}))), /*#__PURE__*/React.createElement("div", {
className: "ma__footer__social"
}, /*#__PURE__*/React.createElement(SocialLinks, socialLinks)), /*#__PURE__*/React.createElement("div", {
className: "ma__footer__copyright"
}, /*#__PURE__*/React.createElement("p", {
className: "ma__footer__copyright--date"
}, "\xA9", ' ', copyright), /*#__PURE__*/React.createElement("p", null, description), /*#__PURE__*/React.createElement("a", {
href: privacyPolicy.url
}, privacyPolicy.text))), /*#__PURE__*/React.createElement("div", {
className: "ma__footer__nav"
}, /*#__PURE__*/React.createElement(FooterLinks, _extends({}, footerLinks, {
showNavHeading: showNavHeading
})))), backToTopButton && /*#__PURE__*/React.createElement("button", {
type: "button",
className: "ma__footer__back2top js-back2top is-hidden"
}, /*#__PURE__*/React.createElement(IconArrow, null), /*#__PURE__*/React.createElement("span", {
"aria-hidden": "true"
}, "Top"), /*#__PURE__*/React.createElement("span", {
className: "visually-hidden"
}, "Go to the top of the page")));
};
Footer.propTypes = process.env.NODE_ENV !== "production" ? {
/** `@molecules/FooterLinks` */
footerLinks: PropTypes.shape(FooterLinks.propTypes).isRequired,
/** Whether to display or visually hiding footer nav headings */
showNavHeading: PropTypes.bool,
/** `@molecules/SocialLinks` */
socialLinks: PropTypes.shape(SocialLinks.propTypes).isRequired,
/** A floating button on the lower right corner which onClick takes user to the top of the page. */
backToTopButton: PropTypes.bool,
/** Adds footer logo. (Defaults to matching Mass.gov) <br />
* `src:` logo image source url <br />
* `domain:` The URL for the site root <br />
* `title:` The title of the logo link
*/
footerLogo: PropTypes.shape({
src: PropTypes.string.isRequired,
domain: PropTypes.string,
title: PropTypes.string
}),
/** Adds footer info section. (Defaults to matching Mass.gov) <br />
* `copyright:` Bolded copyright info starting with © <br />
* `description:` Descriptive info below copyright <br />
* `privacyPolicy:` A link to the privacy policy page of the site
*/
footerText: PropTypes.shape({
copyright: PropTypes.string,
description: PropTypes.string,
privacyPolicy: PropTypes.shape({
text: PropTypes.string,
url: PropTypes.string
})
})
} : {};
export default Footer;