@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.
54 lines (52 loc) • 1.72 kB
JavaScript
import * as React from "react";
import styled from "styled-components";
import defaultTokens from "../../defaultTokens";
import Heading from "../../Heading";
import Text from "../../Text";
export const StyledCardHeader = styled.div.withConfig({
displayName: "CardHeader__StyledCardHeader",
componentId: "lvjkay-0"
})(["position:relative;width:100%;padding:", ";box-sizing:border-box;color:", ";"], ({
theme
}) => theme.orbit.spaceLarge, ({
theme
}) => theme.orbit.colorHeading);
StyledCardHeader.defaultProps = {
theme: defaultTokens
};
const StyledHeadingWrapper = styled.div.withConfig({
displayName: "CardHeader__StyledHeadingWrapper",
componentId: "lvjkay-1"
})(["display:flex;"]);
const StyledSubTitle = styled.div.withConfig({
displayName: "CardHeader__StyledSubTitle",
componentId: "lvjkay-2"
})(["text-align:center;margin-top:", ";"], ({
theme
}) => theme.orbit.spaceXSmall);
StyledSubTitle.defaultProps = {
theme: defaultTokens
};
const StyledIcon = styled.div.withConfig({
displayName: "CardHeader__StyledIcon",
componentId: "lvjkay-3"
})(["color:", ";display:flex;align-items:center;margin-right:", ";"], ({
theme
}) => theme.orbit.colorHeading, ({
theme
}) => theme.orbit.spaceXSmall);
StyledIcon.defaultProps = {
theme: defaultTokens
};
const CardHeader = ({
icon,
title,
subTitle,
dataTest
}) => React.createElement(StyledCardHeader, {
"data-test": dataTest
}, React.createElement(StyledHeadingWrapper, null, icon && React.createElement(StyledIcon, null, icon), React.createElement(Heading, {
type: "title2",
element: "h2"
}, title)), subTitle && React.createElement(StyledSubTitle, null, React.createElement(Text, null, subTitle)));
export default CardHeader;