import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown' import Box from '@mui/material/Box' import Button from '@mui/material/Button' import ButtonGroup from '@mui/material/ButtonGroup' import ClickAwayListener from '@mui/material/ClickAwayListener' import Grow from '@mui/material/Grow' import MenuItem from '@mui/material/MenuItem' import MenuList from '@mui/material/MenuList' import Paper from '@mui/material/Paper' import Popper from '@mui/material/Popper' import type { ComponentMeta, ComponentStory } from '@storybook/react' import React from 'react' export default { title: 'Components/ButtonGroup', component: ButtonGroup, } as ComponentMeta export const Default: ComponentStory = () => ( ) export const VariantButtonGroup: ComponentStory = () => { return ( *': { m: 1, }, }} > ) } const buttons = [ , , , ] export function GroupSizesColors() { return ( *': { m: 1, }, }} > {buttons} {buttons} {buttons} ) } export function GroupOrientation() { return ( *': { m: 1, }, }} > {buttons} {buttons} {buttons} ) } const options = [ 'Create a merge commit', 'Squash and merge', 'Rebase and merge', ] export function SplitButton() { const [open, setOpen] = React.useState(false) const anchorRef = React.useRef(null) const [selectedIndex, setSelectedIndex] = React.useState(1) const handleClick = () => { console.info(`You clicked ${options[selectedIndex]}`) } const handleMenuItemClick = ( event: React.MouseEvent, index: number ) => { setSelectedIndex(index) setOpen(false) } const handleToggle = () => { setOpen((prevOpen) => !prevOpen) } const handleClose = (event: Event) => { if ( anchorRef.current && anchorRef.current.contains(event.target as HTMLElement) ) { return } setOpen(false) } return ( {({ TransitionProps, placement }) => ( {options.map((option, index) => ( handleMenuItemClick(event, index)} > {option} ))} )} ) } export function DisableElevation() { return ( ) }