UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

146 lines (120 loc) 5.73 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var React = _interopRequireWildcard(require("react")); var _styledComponents = _interopRequireWildcard(require("styled-components")); var _ChevronLeft = _interopRequireDefault(require("../../icons/ChevronLeft")); var _Heading = _interopRequireWildcard(require("../../Heading")); var _consts = require("../../Heading/consts"); var _Button = _interopRequireDefault(require("../../Button")); var _ButtonPrimitive = require("../../primitives/ButtonPrimitive"); var _consts2 = _interopRequireDefault(require("./consts")); var _defaultTheme = _interopRequireDefault(require("../../defaultTheme")); var _LazyImage = _interopRequireDefault(require("../../LazyImage")); var _mediaQuery = _interopRequireDefault(require("../../utils/mediaQuery")); var _useTranslate = _interopRequireDefault(require("../../hooks/useTranslate")); var StyledDestinationHeader = _styledComponents.default.div.withConfig({ displayName: "DestinationHeader__StyledDestinationHeader", componentId: "yh1o1c-0" })(["width:100%;height:80px;position:relative;box-sizing:border-box;border-radius:", ";overflow:hidden;", ";"], function (_ref) { var theme = _ref.theme; return theme.orbit.borderRadiusNormal; }, _mediaQuery.default.largeMobile((0, _styledComponents.css)(["height:120px;"]))); StyledDestinationHeader.defaultProps = { theme: _defaultTheme.default }; var StyledOverlay = _styledComponents.default.div.withConfig({ displayName: "DestinationHeader__StyledOverlay", componentId: "yh1o1c-1" })(["position:absolute;height:100%;width:100%;left:0;top:0;background-image:linear-gradient(to top,rgba(16,19,21,0.75),rgba(0,0,0,0));z-index:1;border-radius:", ";"], function (_ref2) { var theme = _ref2.theme; return theme.orbit.borderRadiusNormal; }); StyledOverlay.defaultProps = { theme: _defaultTheme.default }; var StyledContent = _styledComponents.default.div.withConfig({ displayName: "DestinationHeader__StyledContent", componentId: "yh1o1c-2" })(["position:relative;z-index:2;display:flex;height:100%;flex-direction:column;justify-content:space-between;", "{align-self:flex-start;background:none;}", ";"], _ButtonPrimitive.StyledButtonPrimitive, _mediaQuery.default.largeMobile((0, _styledComponents.css)(["", "{width:", ";height:", ";svg{width:", ";height:", ";}}"], _ButtonPrimitive.StyledButtonPrimitive, function (_ref3) { var theme = _ref3.theme; return theme.orbit.heightButtonNormal; }, function (_ref4) { var theme = _ref4.theme; return theme.orbit.heightButtonNormal; }, function (_ref5) { var theme = _ref5.theme; return theme.orbit.widthIconMedium; }, function (_ref6) { var theme = _ref6.theme; return theme.orbit.heightIconMedium; }))); StyledContent.defaultProps = { theme: _defaultTheme.default }; var StyledHeader = _styledComponents.default.div.withConfig({ displayName: "DestinationHeader__StyledHeader", componentId: "yh1o1c-3" })(["box-sizing:border-box;padding:", ";", ";"], function (_ref7) { var theme = _ref7.theme; return "".concat(theme.orbit.spaceXSmall, " ").concat(theme.orbit.spaceSmall); }, _mediaQuery.default.largeMobile((0, _styledComponents.css)(["padding:", ";", "{font-size:", ";font-weight:", ";}"], function (_ref8) { var theme = _ref8.theme; return "".concat(theme.orbit.spaceSmall, " ").concat(theme.orbit.spaceMedium); }, _Heading.StyledHeading, function (_ref9) { var theme = _ref9.theme; return (0, _Heading.getHeadingToken)(_consts.TOKENS.sizeHeading)({ theme: theme, type: _consts.TYPE_OPTIONS.TITLE1 }); }, function (_ref10) { var theme = _ref10.theme; return (0, _Heading.getHeadingToken)(_consts.TOKENS.weightHeading)({ theme: theme, type: _consts.TYPE_OPTIONS.TITLE1 }); }))); StyledHeader.defaultProps = { theme: _defaultTheme.default }; var DestinationHeaderGoBackButton = function DestinationHeaderGoBackButton(_ref11) { var onClick = _ref11.onClick; var translate = (0, _useTranslate.default)(); return /*#__PURE__*/React.createElement(_Button.default, { size: "small", iconLeft: /*#__PURE__*/React.createElement(_ChevronLeft.default, null), onClick: onClick, title: translate("breadcrumbs_back") }); }; var DestinationHeader = function DestinationHeader(_ref12) { var destinationName = _ref12.destinationName, goBack = _ref12.goBack, dataTest = _ref12.dataTest, image = _ref12.image; var destinationImage = image.toLowerCase(); return /*#__PURE__*/React.createElement(StyledDestinationHeader, { "data-test": dataTest }, /*#__PURE__*/React.createElement(_LazyImage.default, { original: { webp: "".concat(_consts2.default, "/photos/900x120/").concat(destinationImage, ".webp"), jpg: "".concat(_consts2.default, "/photos/900x120/").concat(destinationImage, ".jpg") }, placeholder: { webp: "".concat(_consts2.default, "/photos/225x30/").concat(destinationImage, ".webp"), jpg: "".concat(_consts2.default, "/photos/225x30/").concat(destinationImage, ".jpg") }, name: destinationName }), /*#__PURE__*/React.createElement(StyledOverlay, null), /*#__PURE__*/React.createElement(StyledContent, null, /*#__PURE__*/React.createElement(DestinationHeaderGoBackButton, { onClick: goBack }), /*#__PURE__*/React.createElement(StyledHeader, null, /*#__PURE__*/React.createElement(_Heading.default, { inverted: true, type: "title2" }, destinationName)))); }; var _default = DestinationHeader; exports.default = _default;