UNPKG

@vectara/vectara-ui

Version:

Vectara's design system, codified as a React and Sass component library

27 lines (26 loc) 1.96 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import classNames from "classnames"; import { VuiFlexContainer } from "../../flex/FlexContainer"; import { VuiFlexItem } from "../../flex/FlexItem"; import { VuiIcon } from "../../icon/Icon"; import { useVuiContext } from "../../context/Context"; export const VuiAppSideNavLink = (_a) => { var { path, name, iconBefore, iconAfter, isActive, className } = _a, rest = __rest(_a, ["path", "name", "iconBefore", "iconAfter", "isActive", "className"]); const { createLink, getPath } = useVuiContext(); const classes = classNames("vuiAppSideNavLink", { "vuiAppSideNavLink--active": isActive !== null && isActive !== void 0 ? isActive : path === getPath() }, className); const content = iconBefore || iconAfter ? (_jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xxs" }, { children: [iconBefore && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "s" }, { children: iconBefore })) }))), _jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: name })), iconAfter && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "s" }, { children: iconAfter })) })))] }))) : (name); return createLink(Object.assign({ className: classes, children: content, href: path !== null && path !== void 0 ? path : "/" }, rest)); };