@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.
56 lines (52 loc) • 2.21 kB
JavaScript
import * as React from "react";
import styled from "styled-components";
import Button from "../../../Button";
import defaultTheme from "../../../defaultTheme";
import transition from "../../../utils/transition";
var Wrapper = styled.div.withConfig({
displayName: "SectionHeader__Wrapper",
componentId: "sc-1p5j5w5-0"
})(["display:flex;padding:", ";background-color:", ";align-items:center;min-height:", ";transition:", ";"], function (_ref) {
var theme = _ref.theme,
noPadding = _ref.noPadding;
return !noPadding && theme.orbit.spaceLarge;
}, function (_ref2) {
var theme = _ref2.theme;
return theme.orbit.paletteWhite;
}, function (_ref3) {
var expanded = _ref3.expanded;
return expanded ? "19px" : "44px";
}, transition(["min-height"], "fast", "ease-in-out"));
var HeaderContent = styled.div.withConfig({
displayName: "SectionHeader__HeaderContent",
componentId: "sc-1p5j5w5-1"
})(["display:flex;flex-grow:1;align-items:center;"]);
var HeaderActions = styled.div.withConfig({
displayName: "SectionHeader__HeaderActions",
componentId: "sc-1p5j5w5-2"
})(["display:flex;margin-left:", ";"], function (_ref4) {
var theme = _ref4.theme;
return theme.orbit.spaceLarge;
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
Wrapper.defaultProps = {
theme: defaultTheme
}; // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
HeaderActions.defaultProps = {
theme: defaultTheme
};
var AccordionSectionHeader = function AccordionSectionHeader(_ref5) {
var children = _ref5.children,
actions = _ref5.actions,
expanded = _ref5.expanded,
onExpand = _ref5.onExpand,
expandable = _ref5.expandable,
dataTest = _ref5.dataTest;
return /*#__PURE__*/React.createElement(Wrapper, {
expanded: expanded,
"data-test": dataTest && "".concat(dataTest, "Header")
}, /*#__PURE__*/React.createElement(HeaderContent, null, children), !expanded && /*#__PURE__*/React.createElement(HeaderActions, null, expandable && (actions || /*#__PURE__*/React.createElement(Button, {
onClick: onExpand,
type: "secondary"
}, "Open"))));
};
export default AccordionSectionHeader;