UNPKG

@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.

99 lines (97 loc) 3.22 kB
"use client"; import * as React from "react"; import cx from "clsx"; import Text from "../ItineraryText"; import Stack from "../../Stack"; import { STATUS } from "./consts"; import AlertOctagon from "../../icons/AlertOctagon"; import Warning from "../../icons/AlertCircle"; import Info from "../../icons/InformationCircle"; import Check from "../../icons/CheckCircle"; import useTheme from "../../hooks/useTheme"; import { spaceAfterClasses } from "../../common/tailwind"; const borderColorClasses = { [STATUS.WARNING]: "border-s-orange-normal", [STATUS.CRITICAL]: "border-s-red-normal", [STATUS.INFO]: "border-s-blue-normal", [STATUS.SUCCESS]: "border-s-green-normal", [STATUS.NEUTRAL]: "border-s-ink-dark" }; const backgroundColor = { [STATUS.WARNING]: "bg-orange-light", [STATUS.CRITICAL]: "bg-red-light", [STATUS.INFO]: "bg-blue-light", [STATUS.SUCCESS]: "bg-green-light", [STATUS.NEUTRAL]: "bg-cloud-normal" }; // TODO: refactor this after designers will resolve status colors // https://skypicker.slack.com/archives/GSGN9BN6Q/p1674568716519889 const StatusIcon = ({ type, theme }) => { switch (type) { case "info": return /*#__PURE__*/React.createElement(Info, { size: "small", customColor: theme.orbit.paletteBlueDark, ariaHidden: true }); case "critical": return /*#__PURE__*/React.createElement(AlertOctagon, { size: "small", customColor: theme.orbit.paletteRedDark, ariaHidden: true }); case "success": return /*#__PURE__*/React.createElement(Check, { size: "small", customColor: theme.orbit.paletteGreenDark, ariaHidden: true }); case "neutral": return /*#__PURE__*/React.createElement(Info, { size: "small", customColor: "primary", ariaHidden: true }); default: return /*#__PURE__*/React.createElement(Warning, { size: "small", customColor: theme.orbit.paletteOrangeDark, ariaHidden: true }); } }; const ItineraryStatus = ({ type, label, spaceAfter = "medium", children, offset = 0, actionable = true }) => { const theme = useTheme(); return /*#__PURE__*/React.createElement("div", { className: cx("orbit-itinerary-status", "rounded-300 shadow-fixed box-border flex w-full flex-col border-0 border-s-[3px] border-solid", type && borderColorClasses[type], spaceAfter && spaceAfterClasses[spaceAfter], actionable && "hover:shadow-level2") }, /*#__PURE__*/React.createElement("div", { className: cx("px-200 min-h-800 rounded-t-300 flex items-center rounded-b-none py-0", type && backgroundColor[type]) }, /*#__PURE__*/React.createElement("div", { className: "z-[2]", style: { marginInlineStart: `${parseInt(theme.orbit.space300, 10) + offset}px` } }, /*#__PURE__*/React.createElement(Stack, { flex: true, spacing: "200", align: "center" }, /*#__PURE__*/React.createElement(StatusIcon, { type: type, theme: theme }), label && /*#__PURE__*/React.createElement(Text, { as: "div", type: type === "neutral" ? "primary" : type, weight: "medium" }, label)))), children); }; export default ItineraryStatus;