Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | 11019x 1251x 1251x 1251x 1002x 1002x 1002x 1002x 1002x 1002x 1002x 10x 348x 3000x 1002x 1002x 1002x 1002x 1002x 1002x 999x 999x 14x 3000x 1002x 1002x 999x 5010x 277x 3000x 1002x 1002x 2004x 6x 3000x 1002x 1002x 1002x 2004x 61x 19269x 3255x 12273x 3255x 103x 10017x 10017x 10017x 10017x 10017x 70119x 30051x | import React from "react";
import {
ToggleGroup,
ToggleGroupItem,
} from "@/ahuora-design-system/ui/toggle-group";
import { ToolTipCover } from "@/ahuora-design-system/ui/tooltip";
import { FlowsheetTemplateTypeEnum } from "@/api/apiStore.gen";
import { useFlowsheet } from "@/hooks/project";
import { useSearchParam } from "../../../../hooks/searchParams";
import { ContentTypes, TABS, TabPositions } from "./LeftSideBarTabDefinitions";
function LeftSideBarTabs() {
const [content, setContent] = useSearchParam("content");
const flowsheet = useFlowsheet();
const isTemplateFlowsheet =
flowsheet?.flowsheet_template_type ===
FlowsheetTemplateTypeEnum.PrivateTemplate ||
flowsheet?.flowsheet_template_type ===
FlowsheetTemplateTypeEnum.PublicTemplate;
const visibleTabs = isTemplateFlowsheet
? TABS.filter((tabItem) => tabItem.id !== ContentTypes.project)
: TABS;
const selectedContent =
isTemplateFlowsheet && content === ContentTypes.project
? ContentTypes.flowsheet
: content;
const topTabs = visibleTabs.filter(
(tabItem) => tabItem.position === TabPositions.top,
);
const secondTabs = visibleTabs.filter(
(tabItem) => tabItem.position === TabPositions.second,
);
const thirdTabs = visibleTabs.filter(
(tabItem) => tabItem.position === TabPositions.third,
);
const bottomTabs = visibleTabs.filter(
(tabItem) => tabItem.position === TabPositions.bottom,
);
const switchTab = (tab: ContentTypes) => {
if (selectedContent === tab) {
setContent(ContentTypes.flowsheet);
} else {
setContent(tab);
}
};
return (
<nav className="w-[55px] bg-card h-full flex flex-col">
<ToggleGroup
type="single"
className="w-full flex flex-col items-center h-full"
value={selectedContent || ContentTypes.unitOps}
>
<div className="w-full flex flex-col items-center">
{topTabs.map((tabItem) => (
<TabItem
key={tabItem.id}
open={selectedContent === tabItem.id}
icon={<ClonedIcon originalIcon={tabItem.icon} />}
onClick={() => switchTab(tabItem.id)}
label={tabItem.tooltipContent}
value={tabItem.id}
/>
))}
</div>
{topTabs.length > 0 && (
<div className="w-10 mx-auto my-1 border-t border-border"></div>
)}
<div className="w-full flex flex-col items-center">
{secondTabs.map((tabItem) => (
<TabItem
key={tabItem.id}
open={selectedContent === tabItem.id}
icon={<ClonedIcon originalIcon={tabItem.icon} />}
onClick={() => switchTab(tabItem.id)}
label={tabItem.tooltipContent}
value={tabItem.id}
/>
))}
</div>
<div className="w-10 mx-auto my-1 border-t border-border"></div>
{thirdTabs.map((tabItem) => (
<TabItem
key={tabItem.id}
open={selectedContent === tabItem.id}
icon={<ClonedIcon originalIcon={tabItem.icon} />}
onClick={() => switchTab(tabItem.id)}
label={tabItem.tooltipContent}
value={tabItem.id}
/>
))}
<div className="w-full flex flex-col items-center"></div>
<div className="w-full pt-2 mt-auto flex flex-col items-center">
{bottomTabs.map((tabItem) => (
<TabItem
key={tabItem.id}
open={selectedContent === tabItem.id}
icon={<ClonedIcon originalIcon={tabItem.icon} />}
onClick={() => switchTab(tabItem.id)}
label={tabItem.tooltipContent}
value={tabItem.id}
/>
))}
</div>
</ToggleGroup>
</nav>
);
}
const ClonedIcon = ({ originalIcon }) =>
React.cloneElement(originalIcon, {
...originalIcon.props,
className: "icon-large",
});
const TabItem = ({
open,
icon,
onClick,
label,
value,
disabled,
}) => (
<ToolTipCover asChild content={label} side="right" delay={0}>
<ToggleGroupItem
value={value}
aria-label={label}
className="w-11 h-11 m-1 flex justify-center items-center"
data-state={open ? "on" : "off"}
onClick={onClick}
disabled={disabled}
>
{icon}
</ToggleGroupItem>
</ToolTipCover>
);
export default LeftSideBarTabs;
|