UNPKG

@xgovformbuilder/govuk-react-jsx

Version:

> This package is no longer maintained and will not receive updates bringing it beyond govuk-frontend 4.0.1. If you are using this in your project the simplest way forward is to copy and paste the components from here into your project allowing you to kee

54 lines (49 loc) 2.48 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["className", "messages"], _excluded2 = ["headingChildren", "children", "actions", "className"], _excluded3 = ["className"]; import React from 'react'; import { Button } from '../button'; import { Link } from '../../../utils/Link'; function CookieBanner(props) { var className = props.className, messages = props.messages, attributes = _objectWithoutProperties(props, _excluded); return /*#__PURE__*/React.createElement("div", _extends({ className: "govuk-cookie-banner ".concat(className || ''), "data-nosnippet": true, role: "region" }, attributes), messages.map(function (message) { var headingChildren = message.headingChildren, children = message.children, actions = message.actions, messageClassName = message.className, messageAttributes = _objectWithoutProperties(message, _excluded2); return /*#__PURE__*/React.createElement("div", _extends({ className: "govuk-cookie-banner__message govuk-width-container ".concat(messageClassName || '') }, messageAttributes), /*#__PURE__*/React.createElement("div", { className: "govuk-grid-row" }, /*#__PURE__*/React.createElement("div", { className: "govuk-grid-column-two-thirds" }, headingChildren ? /*#__PURE__*/React.createElement("h2", { className: "govuk-cookie-banner__heading govuk-heading-m" }, headingChildren) : null, /*#__PURE__*/React.createElement("div", { className: "govuk-cookie-banner__content" }, children ? typeof children === 'string' ? /*#__PURE__*/React.createElement("p", { className: "govuk-body" }, children) : children : null))), actions ? /*#__PURE__*/React.createElement("div", { className: "govuk-button-group" }, actions.map(function (action) { var actionClassName = action.className, actionAttributes = _objectWithoutProperties(action, _excluded3); return action.href || action.to ? action.type === 'button' ? /*#__PURE__*/React.createElement(Button, action) : /*#__PURE__*/React.createElement(Link, _extends({}, actionAttributes, { className: "govuk-link ".concat(actionClassName || '') })) : /*#__PURE__*/React.createElement(Button, action); })) : null); })); } CookieBanner.defaultProps = { 'aria-label': 'Cookie banner' }; export { CookieBanner };