@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.
71 lines (66 loc) • 2.47 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,
isPrevHidden,
isHidden
}) => css(["display:flex;justify-content:center;z-index:1;svg{background:", ";overflow:hidden;}", " ", ";", ";"], last || index === 0 ? "transparent" : theme.orbit.paletteWhite, index > 0 && !last && css(["padding:", " 0;background:radial-gradient( farthest-side,", ",", ",", ",transparent );"], theme.orbit.spaceXXSmall, theme.orbit.paletteWhite, theme.orbit.paletteWhite, theme.orbit.paletteWhite), index > 0 && count > 0 && css(["&:before{top:", ";border:1px ", " ", ";", ";}"], last && isPrevHidden ? "-14px" : "-9px", isPrevHidden ? "dashed" : "solid", theme.orbit.paletteCloudNormalActive, lineMixin), !last && count > 0 && css(["&:after{bottom:", ";border:1px ", " ", ";", ";}"], isHidden ? "4px" : "-9px", isHidden ? "dashed" : "solid", theme.orbit.paletteCloudNormalActive, 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 === "neutral" ? "primary" : 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,
isPrevHidden,
isHidden,
count
} = usePart();
return /*#__PURE__*/React.createElement(IconStyled, {
index: index,
last: last,
isDetails: isDetails,
isPrevHidden: isPrevHidden,
isHidden: isHidden,
count: count
}, /*#__PURE__*/React.createElement(Icon, {
type: type,
isDetails: isDetails,
icon: children
}));
};
export default ItineraryIcon;