Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
92 lines
3.1 KiB
TypeScript
92 lines
3.1 KiB
TypeScript
import * as React from 'react';
|
|
import Box from '@mui/joy/Box';
|
|
import Button from '@mui/joy/Button';
|
|
import FormControl from '@mui/joy/FormControl';
|
|
import FormLabel from '@mui/joy/FormLabel';
|
|
import Textarea from '@mui/joy/Textarea';
|
|
import IconButton from '@mui/joy/IconButton';
|
|
import Menu from '@mui/joy/Menu';
|
|
import MenuItem from '@mui/joy/MenuItem';
|
|
import ListItemDecorator from '@mui/joy/ListItemDecorator';
|
|
import FormatBold from '@mui/icons-material/FormatBold';
|
|
import FormatItalic from '@mui/icons-material/FormatItalic';
|
|
import KeyboardArrowDown from '@mui/icons-material/KeyboardArrowDown';
|
|
import Check from '@mui/icons-material/Check';
|
|
|
|
export default function ExampleTextareaComment() {
|
|
const [italic, setItalic] = React.useState(false);
|
|
const [fontWeight, setFontWeight] = React.useState('normal');
|
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
return (
|
|
<FormControl>
|
|
<FormLabel>Your comment</FormLabel>
|
|
<Textarea
|
|
placeholder="Type something here…"
|
|
minRows={3}
|
|
endDecorator={
|
|
<Box
|
|
sx={{
|
|
display: 'flex',
|
|
gap: 'var(--Textarea-paddingBlock)',
|
|
pt: 'var(--Textarea-paddingBlock)',
|
|
borderTop: '1px solid',
|
|
borderColor: 'divider',
|
|
flex: 'auto',
|
|
}}
|
|
>
|
|
<IconButton
|
|
variant="plain"
|
|
color="neutral"
|
|
onClick={(event) => setAnchorEl(event.currentTarget)}
|
|
>
|
|
<FormatBold />
|
|
<KeyboardArrowDown fontSize="md" />
|
|
</IconButton>
|
|
<Menu
|
|
anchorEl={anchorEl}
|
|
open={Boolean(anchorEl)}
|
|
onClose={() => setAnchorEl(null)}
|
|
size="sm"
|
|
placement="bottom-start"
|
|
sx={{ '--ListItemDecorator-size': '24px' }}
|
|
>
|
|
{['200', 'normal', 'bold'].map((weight) => (
|
|
<MenuItem
|
|
key={weight}
|
|
selected={fontWeight === weight}
|
|
onClick={() => {
|
|
setFontWeight(weight);
|
|
setAnchorEl(null);
|
|
}}
|
|
sx={{ fontWeight: weight }}
|
|
>
|
|
<ListItemDecorator>
|
|
{fontWeight === weight && <Check fontSize="sm" />}
|
|
</ListItemDecorator>
|
|
{weight === '200' ? 'lighter' : weight}
|
|
</MenuItem>
|
|
))}
|
|
</Menu>
|
|
<IconButton
|
|
variant={italic ? 'soft' : 'plain'}
|
|
color={italic ? 'primary' : 'neutral'}
|
|
aria-pressed={italic}
|
|
onClick={() => setItalic((bool) => !bool)}
|
|
>
|
|
<FormatItalic />
|
|
</IconButton>
|
|
<Button sx={{ ml: 'auto' }}>Send</Button>
|
|
</Box>
|
|
}
|
|
sx={[
|
|
{
|
|
minWidth: 300,
|
|
fontWeight,
|
|
},
|
|
italic ? { fontStyle: 'italic' } : { fontStyle: 'initial' },
|
|
]}
|
|
/>
|
|
</FormControl>
|
|
);
|
|
}
|