Skip to content

Commit 8e1db2e

Browse files
committed
Remove ad-hoc SVG's in favour of phosphor icons in HUD
1 parent 302e0ed commit 8e1db2e

File tree

1 file changed

+7
-84
lines changed
  • packages/perseus/src/components

1 file changed

+7
-84
lines changed

packages/perseus/src/components/hud.tsx

Lines changed: 7 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,11 @@
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";
14
import {StyleSheet, css} from "aphrodite";
25
import * as React from "react";
36

47
import * as constants from "../styles/constants";
58

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-
809
type Props = {
8110
message: string;
8211
enabled: boolean;
@@ -89,15 +18,9 @@ type Props = {
8918
* used for linting errors). The indicator can be disabled.
9019
*/
9120
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];
10124

10225
return (
10326
<button
@@ -110,7 +33,7 @@ const HUD = ({message, enabled, onClick, fixedPosition = true}: Props) => {
11033
onClick();
11134
}}
11235
>
113-
{icon}
36+
<PhosphorIcon icon={icon} style={styles.icon} />
11437
{message}
11538
</button>
11639
);

0 commit comments

Comments
 (0)