UNPKG

@kinvolk/headlamp-plugin

Version:

The needed infrastructure for building Headlamp plugins.

34 lines (33 loc) 1.8 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /* * Copyright 2025 The Kubernetes Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { Icon } from '@iconify/react'; import IconButton from '@mui/material/IconButton'; import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; import MenuItem from '@mui/material/MenuItem'; import Tooltip from '@mui/material/Tooltip'; /** * To be used for our Action buttons. * * So we implement them consistently and encapsulate the implementation. */ export default function ActionButton({ description, longDescription, icon, onClick, color, width, edge, iconButtonProps, iconProps, buttonStyle = 'action', }) { if (buttonStyle === 'menu') { return (_jsxs(MenuItem, { onClick: onClick, children: [_jsx(ListItemIcon, { children: _jsx(Icon, { icon: icon, color: color, width: width, ...iconProps }) }), _jsx(ListItemText, { children: longDescription || description })] })); } return (_jsx(Tooltip, { title: longDescription || description, children: _jsx(IconButton, { "aria-label": description, onClick: onClick, edge: edge, size: "medium", ...iconButtonProps, children: _jsx(Icon, { icon: icon, color: color, width: width, ...iconProps }) }) })); }