@@ -4,42 +4,85 @@ import {
44 Popper ,
55 Fade ,
66 Paper ,
7- Typography ,
8- Box ,
97 makeStyles ,
8+ TextField ,
9+ Badge ,
10+ IconButton ,
1011} from "@material-ui/core" ;
1112import {
1213 usePopupState ,
1314 bindToggle ,
1415 bindPopper ,
1516} from "material-ui-popup-state/hooks" ;
17+ import { Comment } from "@material-ui/icons" ;
1618
1719const useStyles = makeStyles ( ( theme ) => ( {
1820 popperContainer : {
1921 zIndex : 1400 ,
2022 } ,
23+ contentContainer : {
24+ padding : theme . spacing ( 2 ) ,
25+ } ,
2126} ) ) ;
2227
23- export const CommentsPopper = ( ) => {
28+ interface IProps {
29+ text : string ;
30+ }
31+
32+ export const CommentsPopper : React . FunctionComponent < IProps > = ( { text } ) => {
2433 const classes = useStyles ( ) ;
2534 const popupState = usePopupState ( {
2635 variant : "popper" ,
27- popupId : "demoPopper " ,
36+ popupId : "commentPopper " ,
2837 } ) ;
38+ const [ comment , setComment ] = React . useState ( text ) ;
39+
2940 return (
3041 < React . Fragment >
31- < Button color = "primary" { ...bindToggle ( popupState ) } >
32- Comments
33- </ Button >
42+ < IconButton { ...bindToggle ( popupState ) } >
43+ < Badge
44+ color = "secondary"
45+ variant = "dot"
46+ invisible = { ! comment || comment === "" }
47+ >
48+ < Comment />
49+ </ Badge >
50+ </ IconButton >
3451 < Popper
3552 { ...bindPopper ( popupState ) }
3653 transition
54+ disablePortal
3755 className = { classes . popperContainer }
3856 >
3957 { ( { TransitionProps } ) => (
4058 < Fade { ...TransitionProps } timeout = { 350 } >
41- < Paper >
42- < Typography > The content of the Popper.</ Typography >
59+ < Paper className = { classes . contentContainer } >
60+ < React . Fragment >
61+ < TextField
62+ id = "comment"
63+ name = "comment"
64+ variant = "outlined"
65+ value = { comment }
66+ placeholder = { "Add any additional data here" }
67+ multiline
68+ rows = { 4 }
69+ rowsMax = { 10 }
70+ fullWidth
71+ onChange = { ( event ) =>
72+ setComment ( ( event . target as HTMLInputElement ) . value )
73+ }
74+ inputProps = { {
75+ "data-testid" : "comment" ,
76+ } }
77+ />
78+ < Button
79+ onClick = { ( ) => {
80+ popupState . close ( ) ;
81+ } }
82+ >
83+ Save
84+ </ Button >
85+ </ React . Fragment >
4386 </ Paper >
4487 </ Fade >
4588 ) }
0 commit comments