@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.
68 lines (63 loc) • 1.96 kB
JavaScript
import * as React from "react";
import styled, { css } from "styled-components";
import { usePart } from "./context";
import AirplaneDown from "../../icons/AirplaneDown";
import AlertCircle from "../../icons/AlertCircle";
import Circle from "../../icons/Circle";
import defaultTheme from "../../defaultTheme";
const lineMixin = css(["content:\"\";position:absolute;height:calc(50% + 9px);z-index:-1;"]); // TODO: Improve
const IconStyled = styled.div.withConfig({
displayName: "ItineraryIcon__IconStyled",
componentId: "sc-wz4151-0"
})(["", ""], ({
theme,
index,
last,
count,
isNextHidden
}) => css(["display:flex;justify-content:center;z-index:1;", ";", ";"], index > 0 && count > 0 && css(["&:before{top:-9px;border:1px solid ", ";", ";}"], theme.orbit.paletteCloudNormalHover, lineMixin), !last && count > 0 && css(["&:after{bottom:-7px;opacity:", ";border:1px solid ", ";", ";}"], isNextHidden ? `0.5` : `1`, theme.orbit.paletteCloudNormalHover, lineMixin))); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
IconStyled.defaultProps = {
theme: defaultTheme
};
const Icon = ({
type,
isDetails,
icon
}) => {
if (icon) return icon;
if (type) return /*#__PURE__*/React.createElement(AlertCircle, {
size: "small",
color: type
});
if (isDetails) return /*#__PURE__*/React.createElement(AirplaneDown, {
size: "small"
});
return /*#__PURE__*/React.createElement(Circle, {
size: "small",
color: "secondary"
});
};
const ItineraryIcon = ({
isDetails,
type,
children
}) => {
const {
index,
last,
isNextHidden,
count
} = usePart();
return /*#__PURE__*/React.createElement(IconStyled, {
index: index,
last: last,
isDetails: isDetails,
isNextHidden: isNextHidden,
count: count
}, /*#__PURE__*/React.createElement(Icon, {
type: type,
isDetails: isDetails,
icon: children
}));
};
export default ItineraryIcon;