@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.
56 lines • 2.28 kB
JavaScript
import * as React from "react";
import cx from "clsx";
import { usePart } from "./context";
import AlertCircle from "../../icons/AlertCircle";
import StarFull from "../../icons/StarFull";
import CircleEmpty from "../../icons/CircleSmallEmpty";
import CircleSmall from "../../icons/CircleSmall";
const RenderedIcon = ({
isPrevHidden,
isLast,
isHidden,
children,
type
}) => {
if (type && children !== null) return /*#__PURE__*/React.createElement(AlertCircle, {
size: "small",
color: type === "neutral" ? "primary" : type,
ariaHidden: true
});
if (isHidden) return /*#__PURE__*/React.createElement(StarFull, {
color: "warning",
size: "small",
ariaHidden: true
});
if (isPrevHidden && isLast) return /*#__PURE__*/React.createElement(CircleEmpty, {
size: "small",
color: "tertiary",
ariaHidden: true
});
return /*#__PURE__*/React.createElement(React.Fragment, null, children || /*#__PURE__*/React.createElement(CircleSmall, {
size: "small",
color: "secondary",
ariaHidden: true
}));
};
const ItinerarySegmentStopIcon = ({
type,
children
}) => {
const {
index,
last,
isPrevHidden,
isHidden,
count
} = usePart();
return /*#__PURE__*/React.createElement("div", {
className: cx("z-default flex justify-center", "[&_svg]:overflow-hidden", last || index === 0 ? "[&_svg]:bg-transparent" : "[&_svg]:bg-white-normal", index > 0 && !last && ["py-100 px-0", "bg-[radial-gradient(farthest-side,theme(colors.white.normal),theme(colors.white.normal),theme(colors.white.normal),transparent)]"], index > 0 && count > 0 && ["before:-z-default before:border-cloud-normal-active before:absolute before:h-[calc(50%+9px)] before:border", last && isPrevHidden ? "before:top-[-14px]" : "before:top-[-9px]", isPrevHidden ? "before:border-dashed" : "before:border-solid"], !last && count > 0 && ["after:-z-default after:border-cloud-normal-active after:absolute after:h-[calc(50%+9px)] after:border", isHidden ? "after:bottom-100 after:border-dashed" : "after:bottom-[-9px] after:border-solid"])
}, /*#__PURE__*/React.createElement(RenderedIcon, {
type: type,
isPrevHidden: isPrevHidden,
isLast: last,
isHidden: isHidden
}, children));
};
export default ItinerarySegmentStopIcon;