Skip to content

Commit c9b4efa

Browse files
committed
Change color settings levels
1 parent 16dde76 commit c9b4efa

File tree

13 files changed

+156
-119
lines changed

13 files changed

+156
-119
lines changed

src/components/ColorSettingsLevel/ColorSettingsLevel.tsx

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import React, { useEffect } from "react";
2-
import { ChromePicker } from "react-color";
2+
import { CirclePicker } from "react-color";
33
import { Box } from "@material-ui/core";
4+
import { VisibilityOff } from "@material-ui/icons";
45
import Typist from "react-typist";
56
import styles from "../Levels.module.scss";
67
import { RGBColor } from "../../contexts/SettingsContext";
7-
import useColorInverter from "../../hooks/useColorInverter/useColorInverter";
88
import "../TypistCursor.scss";
99
import useGlobalColors from "../../hooks/useGlobalColors/useGlobalColors";
1010
// eslint-disable-next-line import/no-cycle
1111
import useNavigation from "../../hooks/useNavigation/useNavigation";
12+
import COLORS from "./colors";
1213

1314
/**
1415
* Lense color settings level props
@@ -26,26 +27,16 @@ export type ColorSettingsLevelProps = {
2627
* @param hint - to be provided for a user
2728
*/
2829
const ColorSettingsLevel: React.FC<ColorSettingsLevelProps> = ({ color, changeColor, hint }) => {
29-
const [invertColor] = useColorInverter();
3030
const [, , , , , currentLevelCounter] = useNavigation();
31-
3231
const [
3332
[, setGlobalBackground, resetGlobalBackground],
3433
[, setGlobalColor, resetGlobalColor],
3534
] = useGlobalColors();
3635

37-
const hintRGBColor: RGBColor = invertColor(color);
38-
const bgRGBColor: RGBColor = color;
39-
const hintStyleColor = `rgb(${hintRGBColor.r}, ${hintRGBColor.g}, ${hintRGBColor.b})`;
40-
const bgStyleColor = `rgb(${bgRGBColor.r}, ${bgRGBColor.g}, ${bgRGBColor.b})`;
41-
4236
useEffect(() => {
43-
setGlobalBackground(bgRGBColor);
44-
setGlobalColor(hintRGBColor);
45-
// eslint-disable-next-line react-hooks/exhaustive-deps
46-
}, [setGlobalColor, setGlobalBackground, hintStyleColor, bgStyleColor]);
37+
setGlobalColor({ r: 255, g: 255, b: 255 });
38+
setGlobalBackground({ r: 0, g: 0, b: 0 });
4739

48-
useEffect(() => {
4940
return () => {
5041
resetGlobalBackground();
5142
resetGlobalColor();
@@ -55,18 +46,19 @@ const ColorSettingsLevel: React.FC<ColorSettingsLevelProps> = ({ color, changeCo
5546

5647
return (
5748
<Box className={styles.level__container}>
49+
<VisibilityOff fontSize="large" htmlColor={`rgb(${color.r}, ${color.g}, ${color.b})`} />
5850
<h1
5951
style={{
60-
color: hintStyleColor,
52+
color: "white",
6153
}}
6254
className={styles.level__hint_top}
6355
data-testid="color-settings-level-hint"
6456
>
6557
<Typist key={currentLevelCounter}>{hint}</Typist>
6658
</h1>
6759
<Box data-testid="color-settings-level-picker" className={styles.level__picker}>
68-
<ChromePicker
69-
disableAlpha
60+
<CirclePicker
61+
colors={COLORS}
7062
color={color}
7163
onChange={(newColor) => {
7264
changeColor(newColor.rgb);

src/components/ColorSettingsLevel/__tests__/ColorSettingsLevel.test.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import React from "react";
22
import { ReactWrapper, mount } from "enzyme";
33
import { render, waitFor } from "@testing-library/react";
44
import Typist from "react-typist";
5-
import { ChromePicker } from "react-color";
5+
import { CirclePicker } from "react-color";
66
import ColorSettingsLevel, { ColorSettingsLevelProps } from "../ColorSettingsLevel";
7-
import useColorInverter from "../../../hooks/useColorInverter/useColorInverter";
87
import useNavigation from "../../../hooks/useNavigation/useNavigation";
98
import useGlobalColors from "../../../hooks/useGlobalColors/useGlobalColors";
109

11-
jest.mock("../../../hooks/useColorInverter/useColorInverter");
1210
jest.mock("../../../hooks/useNavigation/useNavigation");
1311
jest.mock("../../../hooks/useGlobalColors/useGlobalColors");
1412

@@ -36,10 +34,6 @@ describe("ColorSettingsLevel component", () => {
3634
jest.clearAllMocks();
3735
});
3836

39-
it("uses color inverter", () => {
40-
expect(useColorInverter).toBeCalledTimes(1);
41-
});
42-
4337
it("uses navigation", () => {
4438
expect(useNavigation).toBeCalledTimes(1);
4539
});
@@ -56,8 +50,8 @@ describe("ColorSettingsLevel component", () => {
5650
expect(wrapper.find(Typist).length).toEqual(1);
5751
});
5852

59-
it("renders ChromePicker", () => {
60-
expect(wrapper.find(ChromePicker).length).toEqual(1);
53+
it("renders CirclePicker", () => {
54+
expect(wrapper.find(CirclePicker).length).toEqual(1);
6155
});
6256
});
6357

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import COLORS from "../colors";
2+
3+
describe("Color settings colorpicker colors", () => {
4+
it("should be set to specific list of colors", () => {
5+
expect(COLORS).toEqual([
6+
"#00FFFF",
7+
"#3FE0D0",
8+
"#0080FF",
9+
"#0F52BA",
10+
"#000080",
11+
"#111E6C",
12+
"#1D2951",
13+
"#003152",
14+
"#152238",
15+
"#1C2E4A",
16+
"#03002E",
17+
"#010048",
18+
"#FF0000",
19+
"#FF0800",
20+
"#FF2400",
21+
"#FF2800",
22+
"#C21807",
23+
"#B80F0A",
24+
"#960018",
25+
"#7C0A02",
26+
"#800000",
27+
"#420D09",
28+
"#1C0000",
29+
"#0E0000",
30+
]);
31+
});
32+
33+
it("should has length divisible by 6 to create a full lines for circle picker", () => {
34+
expect(COLORS.length % 6).toEqual(0);
35+
});
36+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Available colors to choose on color picker
3+
*/
4+
const COLORS = [
5+
"#00FFFF",
6+
"#3FE0D0",
7+
"#0080FF",
8+
"#0F52BA",
9+
"#000080",
10+
"#111E6C",
11+
"#1D2951",
12+
"#003152",
13+
"#152238",
14+
"#1C2E4A",
15+
"#03002E",
16+
"#010048",
17+
"#FF0000",
18+
"#FF0800",
19+
"#FF2400",
20+
"#FF2800",
21+
"#C21807",
22+
"#B80F0A",
23+
"#960018",
24+
"#7C0A02",
25+
"#800000",
26+
"#420D09",
27+
"#1C0000",
28+
"#0E0000",
29+
];
30+
31+
export default COLORS;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"main": ""
2+
"main": "ColorSettingsLevel.tsx"
33
}

src/components/IntroLevel/__tests__/introLevels.test.tsx

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,36 @@ describe("list of intro levels", () => {
88
{
99
hint: "this application serves as a try to restore binocular vision",
1010
},
11+
{
12+
hint: "please, be aware that this is not an official medical treatment",
13+
},
14+
{
15+
hint: (
16+
<span>
17+
be aware that it is <b>strongly recommended to treat strabismus or amblyopia</b> if you
18+
have it
19+
</span>
20+
),
21+
},
22+
{
23+
hint: "because it might be not possible for you to see the right picture",
24+
},
25+
{
26+
hint: (
27+
<span>
28+
and yet again, <b>if you have strabismus or amblyopia</b>, please <b>at least</b> do as
29+
many{" "}
30+
<a
31+
href="https://www.webmd.com/eye-health/eye-exercises-strabismus"
32+
rel="noreferrer"
33+
target="_blank"
34+
>
35+
eye muscle exercises
36+
</a>{" "}
37+
as you can every day
38+
</span>
39+
),
40+
},
1141
{
1242
hint: "in order to start it you need so called anaglyph red-cyan (red-blue) 3D glasses",
1343
},
@@ -20,12 +50,12 @@ describe("list of intro levels", () => {
2050
),
2151
},
2252
{
23-
hint: (
53+
hint:
54+
/* prettier-ignore */
2455
<span>
25-
you can also try to add this application to the <b>home screen</b>{" "}
56+
you can also try to add this application to the <b>home screen</b>{" "}
2657
<Typist.Delay ms={700} /> and use it on your phone
27-
</span>
28-
),
58+
</span>,
2959
},
3060
{
3161
hint: "yet it is still recommended to exercise on bigger screens",

src/components/IntroLevel/introLevels.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,35 @@ const introLevels: IntroLevel[] = [
99
{
1010
hint: "this application serves as a try to restore binocular vision",
1111
},
12+
{
13+
hint: "please, be aware that this is not an official medical treatment",
14+
},
15+
{
16+
hint: (
17+
<span>
18+
be aware that it is <b>strongly recommended to treat strabismus or amblyopia</b> if you have
19+
it
20+
</span>
21+
),
22+
},
23+
{
24+
hint: "because it might be not possible for you to see the right picture",
25+
},
26+
{
27+
hint: (
28+
<span>
29+
and yet again, <b>if you have strabismus or amblyopia</b>, please <b>at least</b> do as many{" "}
30+
<a
31+
href="https://www.webmd.com/eye-health/eye-exercises-strabismus"
32+
rel="noreferrer"
33+
target="_blank"
34+
>
35+
eye muscle exercises
36+
</a>{" "}
37+
as you can every day
38+
</span>
39+
),
40+
},
1241
{
1342
hint: "in order to start it you need so called anaglyph red-cyan (red-blue) 3D glasses",
1443
},

src/components/Navigation/Navigation.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ import { ArrowBack, ArrowForward, Cached, Settings } from "@material-ui/icons";
44
import styles from "./Navigation.module.scss";
55
import useNavigation from "../../hooks/useNavigation/useNavigation";
66

7+
/**
8+
* Navigation component props type
9+
*/
710
export type NavigationProps = {
811
bgColor: string;
912
color: string;
1013
};
1114

15+
/**
16+
* Navigation component
17+
* @param bgColor - to be set to navigation
18+
* @param color - to be set to navigation buttons
19+
*/
1220
const Navigation: React.FC<NavigationProps> = ({ bgColor, color }) => {
1321
const [, nextLevel, previousLevel, resetLevels, goToSettings] = useNavigation();
1422

src/hooks/useColorInverter/__mocks__/useColorInverter.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/hooks/useColorInverter/__tests__/useColorInverter.test.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)