import React, { useEffect, useRef } from "react"; import { DraggableProvided } from "react-beautiful-dnd"; import Button from "@mui/material/Button"; import Tooltip from "@mui/material/Tooltip"; import SyncIcon from "@mui/icons-material/Sync"; import CloseIcon from "@mui/icons-material/Close"; import { Settings } from "../../Settings/Settings"; interface IProps { provided: DraggableProvided; title: string; isActive: boolean; isExternal: boolean; onClick: () => void; onClose: () => void; onUpdate: () => void; } const tabMargin = 5; const tabIconWidth = 25; const tabIconHeight = 38.5; export function Tab({ provided, title, isActive, isExternal, onClick, onClose, onUpdate }: IProps) { const colorProps = isActive ? { background: Settings.theme.button, borderColor: Settings.theme.button, color: Settings.theme.primary, } : { background: Settings.theme.backgroundsecondary, borderColor: Settings.theme.backgroundsecondary, color: Settings.theme.secondary, }; if (isExternal) { colorProps.color = Settings.theme.info; } const iconButtonStyle = { maxWidth: tabIconWidth, minWidth: tabIconWidth, minHeight: tabIconHeight, maxHeight: tabIconHeight, ...colorProps, }; const tabRef = useRef(null); useEffect(() => { if (tabRef.current && isActive) { tabRef.current?.scrollIntoView(); } }, [isActive]); return (
{ tabRef.current = element; provided.innerRef(element); }} {...provided.draggableProps} {...provided.dragHandleProps} style={{ ...provided.draggableProps.style, marginRight: tabMargin, flexShrink: 0, border: "1px solid " + Settings.theme.well, }} >
); }