Skip to content

Commit 761364d

Browse files
committed
CommentsPopper added
1 parent a138d3e commit 761364d

File tree

4 files changed

+56
-11
lines changed

4 files changed

+56
-11
lines changed

src/components/CommentsPopper.tsx

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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";
1112
import {
1213
usePopupState,
1314
bindToggle,
1415
bindPopper,
1516
} from "material-ui-popup-state/hooks";
17+
import { Comment } from "@material-ui/icons";
1618

1719
const 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
)}

src/components/TestDetailsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ const TestDetailsModal: React.FunctionComponent<{
204204
</Button>
205205
</Grid>
206206
<Grid item>
207-
<CommentsPopper />
207+
<CommentsPopper text={testRun.comment}/>
208208
</Grid>
209209
<Grid item>
210210
<Paper variant="outlined">

src/types/testRun.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ export interface TestRun {
1616
viewport: string;
1717
device: string;
1818
ignoreAreas: string;
19+
comment: string;
1920
}

src/types/testVariation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export interface TestVariation {
1010
device: string;
1111
ignoreAreas: string;
1212
projectId: string;
13-
baselines: Baseline[]
13+
baselines: Baseline[];
14+
comment: string;
1415
}

0 commit comments

Comments
 (0)