Update IconButtonWithMenu to support label prop
This commit is contained in:
parent
1b7751c5d1
commit
da85caf684
1 changed files with 32 additions and 13 deletions
|
@ -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 IconButton from '@mui/joy/IconButton'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { getTextColorFromBackgroundColor } from '../../utils/Colors.jsx'
|
import { getTextColorFromBackgroundColor } from '../../utils/Colors.jsx'
|
||||||
|
|
||||||
const IconButtonWithMenu = ({
|
const IconButtonWithMenu = ({
|
||||||
|
label,
|
||||||
key,
|
key,
|
||||||
icon,
|
icon,
|
||||||
options,
|
options,
|
||||||
|
@ -39,6 +40,7 @@ const IconButtonWithMenu = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{!label && (
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={handleMenuOpen}
|
onClick={handleMenuOpen}
|
||||||
variant='outlined'
|
variant='outlined'
|
||||||
|
@ -50,7 +52,24 @@ const IconButtonWithMenu = ({
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{icon}
|
{icon}
|
||||||
|
{label ? label : null}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
)}
|
||||||
|
{label && (
|
||||||
|
<Button
|
||||||
|
onClick={handleMenuOpen}
|
||||||
|
variant='outlined'
|
||||||
|
color={isActive ? 'primary' : 'neutral'}
|
||||||
|
size='sm'
|
||||||
|
startDecorator={icon}
|
||||||
|
sx={{
|
||||||
|
height: 24,
|
||||||
|
borderRadius: 24,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
<Menu
|
<Menu
|
||||||
key={key}
|
key={key}
|
||||||
|
|
Loading…
Add table
Reference in a new issue