@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.
51 lines (47 loc) • 1.83 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";
const Wrapper = styled.div.withConfig({
displayName: "SectionHeader__Wrapper",
componentId: "sc-p376qt-0"
})(["display:flex;padding:", ";background-color:", ";align-items:center;min-height:", ";transition:", ";"], ({
theme,
noPadding
}) => !noPadding && theme.orbit.spaceLarge, ({
theme
}) => theme.orbit.paletteWhite, ({
expanded
}) => expanded ? "19px" : "44px", transition(["min-height"], "fast", "ease-in-out"));
const HeaderContent = styled.div.withConfig({
displayName: "SectionHeader__HeaderContent",
componentId: "sc-p376qt-1"
})(["display:flex;flex-grow:1;align-items:center;"]);
const HeaderActions = styled.div.withConfig({
displayName: "SectionHeader__HeaderActions",
componentId: "sc-p376qt-2"
})(["display:flex;margin-left:", ";"], ({
theme
}) => 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
};
const AccordionSectionHeader = ({
children,
actions,
expanded,
onExpand,
expandable,
dataTest
}) => /*#__PURE__*/React.createElement(Wrapper, {
expanded: expanded,
"data-test": dataTest && `${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;