@@ -7,17 +7,19 @@ import DialogContent from '@material-ui/core/DialogContent';
77import  DialogContentText  from  '@material-ui/core/DialogContentText' ; 
88import  DialogTitle  from  '@material-ui/core/DialogTitle' ; 
99import  {  ValidatorForm ,  TextValidator }  from  'react-material-ui-form-validator' ; 
10+ import  'emoji-mart/css/emoji-mart.css' 
11+ import  {  Picker  }  from  'emoji-mart' 
1012
1113class  PaletteMataForm  extends  Component { 
1214	constructor ( props ) { 
1315		super ( props ) ; 
1416		this . state  =  { 
15- 			open :  true , 
17+ 			stage :  "paletteForm" , 
1618			newPaletteName : "" 
1719		} 
18- 		this . handleClickOpen  =  this . handleClickOpen . bind ( this ) ; 
19- 		this . handleClose  =  this . handleClose . bind ( this ) ; 
2020		this . handleNameChange  =  this . handleNameChange . bind ( this ) ; 
21+     this . showEmojiPicker  =  this . showEmojiPicker . bind ( this ) ; 
22+     this . savePalette  =  this . savePalette . bind ( this ) ; 
2123	} 
2224	componentDidMount ( ) { 
2325		 ValidatorForm . addValidationRule ( 'isPaletteNameUnique' ,  ( value )  =>  { 
@@ -31,29 +33,35 @@ class PaletteMataForm extends Component{
3133		this . setState ( { newPaletteName : evt . target . value } ) 
3234	} 
3335
34-   	handleClickOpen ( ) { 
35-     	this . setState ( {  open : true  } ) ; 
36-   	} ; 
37- 
38-   	handleClose ( ) { 
39-    	 this . setState ( {  open : false  } ) ; 
40-   	} ; 
36+   showEmojiPicker ( ) { 
37+     this . setState ( { stage : "emoji" } ) 
38+   } 
4139
40+   savePalette ( emoji ) { 
41+     const  newPalette  =  { paletteName : this . state . newPaletteName ,  emoji : emoji . native } 
42+     this . props . savePalette ( newPalette ) ; 
43+   } 
4244  render ( )  { 
43-   	const  { newPaletteName}  =  this . state ; 
44-   	const  { savePalette }  =  this . props ; 
45+   	const  { newPaletteName,  stage }  =  this . state ; 
46+   	const  { hideForm }  =  this . props ; 
4547    return  ( 
48+       < div > 
49+         < Dialog  open = { stage  ===  'emoji' } > 
50+            < DialogTitle  id = "form-dialog-title" > Choose a Palette Emoji</ DialogTitle > 
51+           < Picker  onSelect = { this . savePalette }  title = 'Pick an emoji '  emoji = 'point_up' /> 
52+         </ Dialog > 
4653        < Dialog 
47-           open = { this . state . open } 
48-           onClose = { this . handleClose } 
54+           open = { stage   ===   'paletteForm' } 
55+           onClose = { hideForm } 
4956          aria-labelledby = "form-dialog-title" 
5057        > 
5158          < DialogTitle  id = "form-dialog-title" > Choose a Palette Name</ DialogTitle > 
52-           < ValidatorForm  onSubmit = { ( )   =>   savePalette ( newPaletteName ) } > 
59+           < ValidatorForm  onSubmit = { this . showEmojiPicker } > 
5360          < DialogContent > 
5461            < DialogContentText > 
5562              Please enter a name for your customised Palette. Make sure it's unique!
5663            </ DialogContentText > 
64+             
5765	            < TextValidator  
5866	            	label = "Palette Name"   
5967	            	value = { newPaletteName } 
@@ -66,7 +74,7 @@ class PaletteMataForm extends Component{
6674	            /> 
6775          </ DialogContent > 
6876          < DialogActions > 
69-             < Button  onClick = { this . handleClose }  color = "primary" > 
77+             < Button  onClick = { hideForm }  color = "primary" > 
7078              Cancel
7179            </ Button > 
7280            < Button  variant = "contained"  color = "primary"  type = "submit" > 
@@ -75,6 +83,7 @@ class PaletteMataForm extends Component{
7583          </ DialogActions > 
7684          </ ValidatorForm > 
7785        </ Dialog > 
86+       </ div > 
7887    ) ; 
7988  } 
8089} 
0 commit comments