@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.
72 lines • 2.7 kB
JavaScript
import * as React from "react";
import styled, { css } from "styled-components";
import { usePart } from "./context";
import AlertCircle from "../../icons/AlertCircle";
import defaultTheme from "../../defaultTheme";
import StarFull from "../../icons/StarFull";
import CircleEmpty from "../../icons/CircleSmallEmpty";
import CircleSmall from "../../icons/CircleSmall";
const lineMixin = css(["content:\"\";position:absolute;height:calc(50% + 9px);z-index:-1;"]);
const IconStyled = styled.div.withConfig({
displayName: "ItineraryIcon__IconStyled",
componentId: "sc-bazp3h-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)));
IconStyled.defaultProps = {
theme: defaultTheme
};
const RenderedIcon = ({
isPrevHidden,
isLast,
isHidden,
children,
type
}) => {
if (type && children !== null) return /*#__PURE__*/React.createElement(AlertCircle, {
size: "small",
color: type === "neutral" ? "primary" : type
});
if (isHidden) return /*#__PURE__*/React.createElement(StarFull, {
color: "warning",
size: "small"
});
if (isPrevHidden && isLast) return /*#__PURE__*/React.createElement(CircleEmpty, {
size: "small",
color: "tertiary"
});
return /*#__PURE__*/React.createElement(React.Fragment, null, children || /*#__PURE__*/React.createElement(CircleSmall, {
size: "small",
color: "secondary"
}));
};
const ItinerarySegmentStopIcon = ({
type,
children
}) => {
const {
index,
last,
isPrevHidden,
isHidden,
count
} = usePart();
return /*#__PURE__*/React.createElement(IconStyled, {
index: index,
last: last,
isPrevHidden: isPrevHidden,
isHidden: isHidden,
count: count
}, /*#__PURE__*/React.createElement(RenderedIcon, {
type: type,
isPrevHidden: isPrevHidden,
isLast: last,
isHidden: isHidden
}, children));
};
export default ItinerarySegmentStopIcon;