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.

85 lines (82 loc) 2.63 kB
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"; const SpacingMobile = css(["", "px;"], ({ theme }) => String(parseInt(theme.orbit.spaceMedium, 10) + 1)); const SpacingDesktop = css(["", "px;"], ({ theme }) => String(parseInt(theme.orbit.spaceLarge, 10) + 1)); const StyledCardSectionHeader = styled.div.withConfig({ displayName: "SectionHeader__StyledCardSectionHeader", componentId: "sc-o1z9hg-0" })(["transition:", ";cursor:", ";position:relative;padding:", ";margin:-", ";margin-bottom:", ";min-height:", ";", " &:hover{background:", ";}&:focus{background:", ";outline:none;}"], transition(["margin"], "fast", "linear"), ({ expandable }) => expandable && "pointer", ({ theme }) => theme.orbit.spaceMedium, SpacingMobile, ({ expanded, isContent }) => expanded && isContent && 0, ({ expandable }) => expandable && getSize(ICON_SIZES.MEDIUM), mq.largeMobile(css(["margin:-", ";padding:", ";margin-bottom:", ";"], SpacingDesktop, ({ theme }) => theme.orbit.spaceLarge, ({ expanded, isContent }) => expanded && isContent && 0)), ({ theme, expandable }) => expandable && theme.orbit.paletteWhiteHover, ({ theme, expandable }) => expandable && theme.orbit.paletteWhiteHover); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledCardSectionHeader.defaultProps = { theme: defaultTheme }; const CardSectionHeader = ({ title, titleAs, description, icon, isContent, expandable, expanded, onClick, slideID, labelID, actions, handleKeyDown, header, 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;