import React, { useState } from 'react'; import { connect } from 'react-redux'; import { withStyles } from '@material-ui/core/styles'; import { withRoomContext } from '../RoomContext'; import * as stateActions from '../actions/stateActions'; import PropTypes from 'prop-types'; import Dialog from '@material-ui/core/Dialog'; import Typography from '@material-ui/core/Typography'; import DialogActions from '@material-ui/core/DialogActions'; import Button from '@material-ui/core/Button'; import TextField from '@material-ui/core/TextField'; const styles = (theme) => ({ root : { display : 'flex', width : '100%', height : '100%', backgroundColor : 'var(--background-color)', backgroundImage : `url(${window.config.background})`, backgroundAttachment : 'fixed', backgroundPosition : 'center', backgroundSize : 'cover', backgroundRepeat : 'no-repeat' }, dialogPaper : { width : '20vw', padding : theme.spacing(2), [theme.breakpoints.down('lg')] : { width : '30vw' }, [theme.breakpoints.down('md')] : { width : '40vw' }, [theme.breakpoints.down('sm')] : { width : '60vw' }, [theme.breakpoints.down('xs')] : { width : '80vw' } }, logo : { display : 'block' } }); const JoinDialog = ({ roomClient, displayName, changeDisplayName, classes }) => { const [ localDisplayName, setLocalDisplayName ] = useState(displayName); const handleKeyDown = (event) => { const { key } = event; switch (key) { case 'Enter': case 'Escape': { if (localDisplayName !== '') // Don't allow empty displayName changeDisplayName(localDisplayName); else setLocalDisplayName(displayName); break; } default: break; } }; return (