import * as React from 'react';
import FormControl from '@mui/material/FormControl';
import FormLabel from '@mui/material/FormLabel';
import FormControlLabel from '@mui/material/FormControlLabel';
import RadioGroup from '@mui/material/RadioGroup';
import Radio from '@mui/material/Radio';
import Grid from '@mui/material/Grid';
import { green } from '@mui/material/colors';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import Popover from '@mui/material/Popover';
import Input from '@mui/material/Input';
import InputLabel from '@mui/material/InputLabel';
import { HighlightedCode } from '@mui/docs/HighlightedCode';
const inlineStyles = {
anchorVertical: {
top: {
top: -5,
},
center: {
top: 'calc(50% - 5px)',
},
bottom: {
bottom: -5,
},
},
anchorHorizontal: {
left: {
left: -5,
},
center: {
left: 'calc(50% - 5px)',
},
right: {
right: -5,
},
},
};
function AnchorPlayground() {
const anchorRef = React.useRef();
const [state, setState] = React.useState({
open: false,
anchorOriginVertical: 'top',
anchorOriginHorizontal: 'left',
transformOriginVertical: 'top',
transformOriginHorizontal: 'left',
positionTop: 200, // Just so the popover can be spotted more easily
positionLeft: 400, // Same as above
anchorReference: 'anchorEl',
});
const {
open,
anchorOriginVertical,
anchorOriginHorizontal,
transformOriginVertical,
transformOriginHorizontal,
positionTop,
positionLeft,
anchorReference,
} = state;
const handleChange = (event) => {
setState({
...state,
[event.target.name]: event.target.value,
});
};
const handleNumberInputChange = (key) => (event) => {
setState({
...state,
[key]: parseInt(event.target.value, 10),
});
};
const handleClickButton = () => {
setState({
...state,
open: true,
});
};
const handleClose = () => {
setState({
...state,
open: false,
});
};
let mode = '';
if (anchorReference === 'anchorPosition') {
mode = `
anchorReference="${anchorReference}"
anchorPosition={{ top: ${positionTop}, left: ${positionLeft} }}`;
}
const jsx = `