@@ -14,10 +14,10 @@ import {
14
14
Icon ,
15
15
Name ,
16
16
NameValue ,
17
+ useHotkeys ,
17
18
Value ,
18
19
} from "@keybr/widget" ;
19
- import { mdiFileImage , mdiSkipNext } from "@mdi/js" ;
20
- import { captureElementToImage } from "@sosimple/dom-to-image" ;
20
+ import { mdiSkipNext } from "@mdi/js" ;
21
21
import { memo , type ReactNode } from "react" ;
22
22
import * as styles from "./Report.module.less" ;
23
23
@@ -29,27 +29,14 @@ export const Report = memo(function Report({
29
29
readonly onNext : ( ) => void ;
30
30
} ) : ReactNode {
31
31
const { formatNumber, formatPercents } = useIntlNumbers ( ) ;
32
+
33
+ useHotkeys ( [ "Enter" , onNext ] ) ;
34
+
32
35
const dSpeed = makeSpeedDistribution ( ) ;
33
36
const dAccuracy = makeAccuracyDistribution ( ) ;
34
37
const pSpeed = dSpeed . cdf ( speed ) ;
35
38
const pAccuracy = dAccuracy . cdf ( dAccuracy . scale ( accuracy ) ) ;
36
39
37
- const handleClickNext = ( ) => {
38
- onNext ( ) ;
39
- } ;
40
-
41
- const handleClickScreenshot = ( ) => {
42
- const selector = `.${ styles . printable } ` ;
43
- const { backgroundColor } = getComputedStyle ( document . body ) ;
44
- captureElementToImage ( selector , { backgroundColor } )
45
- . then ( ( blob ) => {
46
- window . open ( URL . createObjectURL ( blob ) , "_blank" ) ;
47
- } )
48
- . catch ( ( error ) => {
49
- console . error ( error ) ;
50
- } ) ;
51
- } ;
52
-
53
40
return (
54
41
< div className = { styles . report } >
55
42
< div className = { styles . printable } >
@@ -121,23 +108,20 @@ export const Report = memo(function Report({
121
108
122
109
< div className = { styles . controlsLine } >
123
110
< FieldList >
111
+ < Field . Filler />
124
112
< Field >
125
113
< Button
126
114
label = "Next test"
127
115
icon = { < Icon shape = { mdiSkipNext } /> }
128
116
title = "Try another test."
129
- onClick = { handleClickNext }
130
- />
131
- </ Field >
132
- < Field >
133
- < Button
134
- label = "Screenshot"
135
- icon = { < Icon shape = { mdiFileImage } /> }
136
- title = "Take a screenshot."
137
- onClick = { handleClickScreenshot }
117
+ onClick = { onNext }
138
118
/>
139
119
</ Field >
120
+ < Field . Filler />
140
121
</ FieldList >
122
+ < p >
123
+ Press the < kbd > Enter</ kbd > key to start a new test.
124
+ </ p >
141
125
</ div >
142
126
</ div >
143
127
) ;
0 commit comments