/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import React, { useMemo } from "react";
import { observer } from "mobx-react";
import Link from "next/link";
import { Breadcrumbs } from "@plane/ui";
import { usePlatformOS } from "@/hooks/use-platform-os";
type Props = {
label?: string;
href?: string;
icon?: React.ReactNode;
disableTooltip?: boolean;
isLast?: boolean;
};
const IconWrapper = React.memo(function IconWrapper({ icon }: { icon: React.ReactNode }) {
return
{icon}
;
});
IconWrapper.displayName = "IconWrapper";
const LabelWrapper = React.memo(function LabelWrapper({ label }: { label: React.ReactNode }) {
return {label}
;
});
LabelWrapper.displayName = "LabelWrapper";
const BreadcrumbContent = React.memo(function BreadcrumbContent({
icon,
label,
}: {
icon?: React.ReactNode;
label?: React.ReactNode;
}) {
if (!icon && !label) return null;
return (
<>
{icon && }
{label && }
>
);
});
BreadcrumbContent.displayName = "BreadcrumbContent";
const ItemWrapper = React.memo(function ItemWrapper({
children,
...props
}: React.ComponentProps) {
return {children};
});
ItemWrapper.displayName = "ItemWrapper";
export const BreadcrumbLink = observer(function BreadcrumbLink(props: Props) {
const { href, label, icon, disableTooltip = false, isLast = false } = props;
const { isMobile } = usePlatformOS();
const itemWrapperProps = useMemo(
(): Omit, "children"> => ({
label: label?.toString(),
disableTooltip: isMobile || disableTooltip,
type: href && href !== "" ? "link" : "text",
isLast,
}),
[href, label, isMobile, disableTooltip, isLast]
);
const content = useMemo(() => , [icon, label]);
if (href) {
return (
{content}
);
}
return {content};
});