@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.
94 lines (91 loc) • 3.48 kB
JavaScript
import * as React from "react";
import styled, { css } from "styled-components";
import transition from "../../../utils/transition";
import mq from "../../../utils/mediaQuery";
import { getSize } from "../../../Icon";
import { ICON_SIZES } from "../../../Icon/consts";
import defaultTheme from "../../../defaultTheme";
import Header from "../../components/Header";
var SpacingMobile = css(["", "px;"], function (_ref) {
var theme = _ref.theme;
return String(parseInt(theme.orbit.spaceMedium, 10) + 1);
});
var SpacingDesktop = css(["", "px;"], function (_ref2) {
var theme = _ref2.theme;
return String(parseInt(theme.orbit.spaceLarge, 10) + 1);
});
var StyledCardSectionHeader = styled.div.withConfig({
displayName: "SectionHeader__StyledCardSectionHeader",
componentId: "sc-1win3x-0"
})(["transition:", ";cursor:", ";position:relative;padding:", ";margin:-", ";margin-bottom:", ";min-height:", ";", " &:hover{background:", ";}&:focus{background:", ";outline:none;}"], transition(["margin"], "fast", "linear"), function (_ref3) {
var expandable = _ref3.expandable;
return expandable && "pointer";
}, function (_ref4) {
var theme = _ref4.theme;
return theme.orbit.spaceMedium;
}, SpacingMobile, function (_ref5) {
var expanded = _ref5.expanded,
isContent = _ref5.isContent;
return expanded && isContent && 0;
}, function (_ref6) {
var expandable = _ref6.expandable;
return expandable && getSize(ICON_SIZES.MEDIUM);
}, mq.largeMobile(css(["margin:-", ";padding:", ";margin-bottom:", ";"], SpacingDesktop, function (_ref7) {
var theme = _ref7.theme;
return theme.orbit.spaceLarge;
}, function (_ref8) {
var expanded = _ref8.expanded,
isContent = _ref8.isContent;
return expanded && isContent && 0;
})), function (_ref9) {
var theme = _ref9.theme,
expandable = _ref9.expandable;
return expandable && theme.orbit.paletteWhiteHover;
}, function (_ref10) {
var theme = _ref10.theme,
expandable = _ref10.expandable;
return expandable && theme.orbit.paletteWhiteHover;
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledCardSectionHeader.defaultProps = {
theme: defaultTheme
};
var CardSectionHeader = function CardSectionHeader(_ref11) {
var title = _ref11.title,
titleAs = _ref11.titleAs,
description = _ref11.description,
icon = _ref11.icon,
isContent = _ref11.isContent,
expandable = _ref11.expandable,
expanded = _ref11.expanded,
onClick = _ref11.onClick,
slideID = _ref11.slideID,
labelID = _ref11.labelID,
actions = _ref11.actions,
handleKeyDown = _ref11.handleKeyDown,
header = _ref11.header,
dataA11ySection = _ref11.dataA11ySection;
return /*#__PURE__*/React.createElement(StyledCardSectionHeader, {
expandable: expandable,
expanded: expanded,
onClick: onClick,
"aria-expanded": expandable ? expanded : undefined,
"aria-controls": expandable ? slideID : undefined,
id: labelID,
role: expandable ? "button" : undefined,
onKeyDown: handleKeyDown,
tabIndex: expandable ? "0" : undefined,
isContent: isContent
}, /*#__PURE__*/React.createElement(Header, {
title: title,
titleAs: titleAs,
description: description,
icon: icon,
expandable: expandable,
header: header,
expanded: expanded,
actions: actions,
isSection: true,
dataA11ySection: dataA11ySection
}));
};
export default CardSectionHeader;