-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathSnowfall.jsx
More file actions
79 lines (71 loc) · 2.03 KB
/
Snowfall.jsx
File metadata and controls
79 lines (71 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import Snowfall from "react-snowfall";
import {
christmasId,
funId,
christmasPeppermintHolidayId,
aSuperSpecialAutoThemeSettingsId,
feastOfSaintPatrickId,
} from "../../constants/themeIds";
import { useSelector } from "react-redux";
import GetTheme from "../../themes/ThemeProvider";
import GetAutoThemeId from "../../constants/themeDates";
import cloverSrc from "../../themes/festivities/stPatricksDay/clover.png";
import { useMemo } from "react";
export default function SnowfallWrapper() {
const currentThemeId = useSelector(
(state) => state.settings.config?.currentTheme || GetTheme().themeId
);
/* eslint-disable no-unused-vars */
//little hack to make snow reaminate when these states change
const currentTargetTemperature = useSelector(
(state) => state.deviceInteraction.targetTemperature
);
const currentTemperature = useSelector(
(state) => state.deviceInteraction.currentTemperature
);
/* eslint-enable no-unused-vars */
const snowColorOptions = [
"#FF0000",
"#FFA500",
"#FFFF00",
"#00FF00",
"#004efd",
"#7f00ff",
"#FFFFFF",
];
const snowColor =
snowColorOptions[Math.floor(Math.random() * snowColorOptions.length)];
const MemoClovers = useMemo(() => {
const clover = new Image();
clover.src = cloverSrc;
const images = [clover];
return <Snowfall images={images} radius={[40, 80]} snowflakeCount={20} />;
}, []);
const MemoDefaultSnow = useMemo(() => {
return <Snowfall />;
}, []);
switch (
currentThemeId === aSuperSpecialAutoThemeSettingsId
? GetAutoThemeId()
: currentThemeId
) {
case christmasId:
case christmasPeppermintHolidayId:
return MemoDefaultSnow;
case funId:
return (
<Snowfall color={snowColor} />
/*<Snowfall
color={snowColor}
wind={[-10, 10]}
changeFrequency={100}
snowflakeCount={200}
speed={[1.0, 9.0]}
/>*/
);
case feastOfSaintPatrickId:
return MemoClovers;
default:
return <></>;
}
}