@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.
53 lines (51 loc) • 1.53 kB
JavaScript
import * as React from "react";
import styled from "styled-components";
import defaultTheme from "../../defaultTheme";
import ChevronDown from "../../icons/ChevronDown";
import Stack from "../../Stack";
import Heading from "../../Heading";
import Text from "../../Text";
const ChevronIcon = styled(ChevronDown).withConfig({
displayName: "Header__ChevronIcon",
componentId: "br01zv-0"
})(["transform:", ";transition:transform ", " ease-in-out;"], ({
expanded
}) => expanded && "rotate(-180deg)", ({
theme
}) => theme.orbit.durationFast);
ChevronIcon.defaultProps = {
theme: defaultTheme
};
const Header = ({
description,
icon,
title,
isSection,
actions,
dataA11ySection,
header,
expandable,
expanded
}) => React.createElement(Stack, {
align: actions && !header ? "start" : "center",
spacing: header ? "compact" : "none"
}, (title || description || icon) && !header && React.createElement(Stack, {
inline: true,
direction: "column",
spacing: isSection ? "none" : "tight"
}, React.createElement(Stack, {
inline: true,
spacing: "compact"
}, icon, title && React.createElement(Heading, {
type: "title3",
element: "h2",
dataA11ySection: dataA11ySection
}, title)), description && React.createElement(Text, null, description)), header && icon, header, expandable && !actions && React.createElement(ChevronIcon, {
expanded: expanded,
color: "secondary"
}), actions && React.createElement(Stack, {
inline: true,
grow: false,
justify: "end"
}, actions));
export default Header;