Update IconButtonWithMenu to support label prop

This commit is contained in:
Mo Tarbin 2025-01-15 01:54:07 -05:00
parent 1b7751c5d1
commit da85caf684

View file

@ -1,9 +1,10 @@
import { Chip, Menu, MenuItem, Typography } from '@mui/joy'
import { Button, Chip, Menu, MenuItem, Typography } from '@mui/joy'
import IconButton from '@mui/joy/IconButton'
import React, { useEffect, useRef, useState } from 'react'
import { getTextColorFromBackgroundColor } from '../../utils/Colors.jsx'
const IconButtonWithMenu = ({
label,
key,
icon,
options,
@ -39,6 +40,7 @@ const IconButtonWithMenu = ({
return (
<>
{!label && (
<IconButton
onClick={handleMenuOpen}
variant='outlined'
@ -50,7 +52,24 @@ const IconButtonWithMenu = ({
}}
>
{icon}
{label ? label : null}
</IconButton>
)}
{label && (
<Button
onClick={handleMenuOpen}
variant='outlined'
color={isActive ? 'primary' : 'neutral'}
size='sm'
startDecorator={icon}
sx={{
height: 24,
borderRadius: 24,
}}
>
{label}
</Button>
)}
<Menu
key={key}