1
+ import { PhosphorIcon } from "@khanacademy/wonder-blocks-icon" ;
2
+ import eyeIcon from "@phosphor-icons/core/bold/eye-bold.svg" ;
3
+ import eyeSlashIcon from "@phosphor-icons/core/bold/eye-slash-bold.svg" ;
1
4
import { StyleSheet , css } from "aphrodite" ;
2
5
import * as React from "react" ;
3
6
4
7
import * as constants from "../styles/constants" ;
5
8
6
- // Displays a stylized open eye: lint warnings are visible
7
- const VisibleIcon = ( ) => (
8
- < svg
9
- width = "24"
10
- height = "24"
11
- viewBox = "0 0 24 24"
12
- className = { css ( styles . icon ) }
13
- >
14
- < defs >
15
- < path
16
- id = "a"
17
- d = {
18
- "M7.401 10.035c-1.424.748-2.599 1.905-3.544 " +
19
- "3.48a1 1 0 0 1-1.714-1.03C4.325 8.849 7.652 7 " +
20
- "12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 " +
21
- "1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-" +
22
- "3.48a5 5 0 1 1-9.198 0zM12 15a3 3 0 1 0 0-6 3 3 " +
23
- "0 0 0 0 6z"
24
- }
25
- />
26
- </ defs >
27
- < g fill = "none" fillRule = "evenodd" >
28
- < path fill = "none" d = "M0 0h24v24H0z" />
29
- < mask id = "b" fill = "#fff" >
30
- < use href = "#a" />
31
- </ mask >
32
- < use fill = "#fff" fillRule = "nonzero" href = "#a" />
33
- < g fill = "#fff" mask = "url(#b)" >
34
- < path d = "M0 0h24v24H0z" />
35
- </ g >
36
- </ g >
37
- </ svg >
38
- ) ;
39
-
40
- // Displays a stylized eye with a line through it: I don't want to see lint
41
- const HiddenIcon = ( ) => (
42
- < svg
43
- width = "24"
44
- height = "24"
45
- viewBox = "0 0 24 24"
46
- className = { css ( styles . icon ) }
47
- >
48
- < defs >
49
- < path
50
- id = "a"
51
- d = {
52
- "M8.794 7.38C9.791 7.127 10.86 7 12 7c4.348 0 " +
53
- "7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 " +
54
- "1.028c-.945-1.574-2.12-2.73-3.544-3.48.258." +
55
- "604.401 1.268.401 1.966 0 1.02-.305 " +
56
- "1.967-.828 2.757l2.535 2.536a1 1 0 0 " +
57
- "1-1.414 1.414l-12-12a1 1 0 0 1 " +
58
- "1.414-1.414L8.794 7.38zm5.914 5.913a3 3 0 0 " +
59
- "0-4.001-4.001l4 4.001zM6.072 8.486l2.976 " +
60
- "2.976a3 3 0 0 0 3.49 3.49l1.579 1.58A5 5 0 " +
61
- "0 1 7.4 10.035c-1.424.747-2.599 1.904-3.544 " +
62
- "3.478a1 1 0 0 1-1.714-1.028c1.049-1.75 " +
63
- "2.363-3.085 3.929-4z"
64
- }
65
- />
66
- </ defs >
67
- < g fill = "none" fillRule = "evenodd" >
68
- < path fill = "none" d = "M0 0h24v24H0z" />
69
- < mask id = "b" fill = "#fff" >
70
- < use href = "#a" />
71
- </ mask >
72
- < use fill = "#fff" fillRule = "nonzero" href = "#a" />
73
- < g fill = "#fff" mask = "url(#b)" >
74
- < path d = "M0 0h24v24H0z" />
75
- </ g >
76
- </ g >
77
- </ svg >
78
- ) ;
79
-
80
9
type Props = {
81
10
message : string ;
82
11
enabled : boolean ;
@@ -89,15 +18,9 @@ type Props = {
89
18
* used for linting errors). The indicator can be disabled.
90
19
*/
91
20
const HUD = ( { message, enabled, onClick, fixedPosition = true } : Props ) => {
92
- let state ;
93
- let icon ;
94
- if ( enabled ) {
95
- state = styles . enabled ;
96
- icon = < VisibleIcon /> ;
97
- } else {
98
- state = styles . disabled ;
99
- icon = < HiddenIcon /> ;
100
- }
21
+ const [ state , icon ] = enabled
22
+ ? [ styles . enabled , eyeIcon ]
23
+ : [ styles . disabled , eyeSlashIcon ] ;
101
24
102
25
return (
103
26
< button
@@ -110,7 +33,7 @@ const HUD = ({message, enabled, onClick, fixedPosition = true}: Props) => {
110
33
onClick ( ) ;
111
34
} }
112
35
>
113
- { icon }
36
+ < PhosphorIcon icon = { icon } style = { styles . icon } />
114
37
{ message }
115
38
</ button >
116
39
) ;
0 commit comments