UNPKG

@shopgate/engage

Version:
49 lines (48 loc) 1.17 kB
import React from 'react'; import PropTypes from 'prop-types'; import { Link, I18n } from '@shopgate/engage/components'; import styles from "./style"; /** * @param {Object} props component props. * @param {string} props.title Navigation title. * @param {Array} props.entries Navigation entries. * @param {Object} context The component context. * @returns {JSX} */ import { jsx as _jsx } from "react/jsx-runtime"; const Navigation = ({ title, entries }, context) => { const { __ } = context.i18n(); if (!entries || !entries.length) { return null; } return /*#__PURE__*/_jsx("nav", { "aria-label": title ? __(title) : null, children: /*#__PURE__*/_jsx("ul", { className: styles, children: entries.map(({ title: entryTitle, link }) => /*#__PURE__*/_jsx("li", { children: /*#__PURE__*/_jsx(Link, { href: link, children: /*#__PURE__*/_jsx(I18n.Text, { string: entryTitle }) }) }, link)) }) }); }; Navigation.defaultProps = { title: null, entries: [] }; Navigation.contextTypes = { i18n: PropTypes.func }; export default Navigation;