Skip to content

Commit

Permalink
button to turn the snow effect off...
Browse files Browse the repository at this point in the history
  • Loading branch information
bandinopla committed Dec 3, 2024
1 parent a40fd9a commit 04e8b49
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
3 changes: 3 additions & 0 deletions public/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- 2.34.4 : 2024-12-03
* requested by @Willem a way to turn off the snow effect because it made some browsers lag a lot.

- 2.34.3 : 2024-11-26
+ added total reps and total sets count on the journal's post.
* fixed/retouched the colors on dark mode because I know dark mode looked like shit...
Expand Down
28 changes: 26 additions & 2 deletions src/componentes/snow.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
// credit to: https://pajasevi.github.io/CSSnowflakes/

import { useEffect, useState } from "react";
import AcUnitIcon from '@material-ui/icons/AcUnit';

const now = new Date();
const isChristmasSeason = now.getMonth() === 11; // December only

export function Snowfall() {
const [on, setOn] = useState(false);

useEffect(()=>{

const state = window.localStorage?.getItem("snow") ?? "1";

setOn(state=="1");

},[]);

const toggleSnow = ()=>{
const newState = on? "0" : "1";
window.localStorage?.setItem("snow", newState);
setOn(!on);
}

if (!isChristmasSeason) return;

return <div class="snowflakes" aria-hidden="true">
return <>
<div onClick={()=>toggleSnow()} style={{ display:"flex", color:"red", alignItems:"center", border:"3px solid red", borderTop:"none", position:"fixed", top:0, left:"50%", background:"#eee", zIndex:9999, padding:"5px 10px", borderBottomLeftRadius:5, borderBottomRightRadius:5, cursor:"pointer" }}>
<AcUnitIcon/> Snow: <strong>{ on?"ON":"OFF"}</strong></div>

{ on && <div class="snowflakes" aria-hidden="true">
<div class="snowflake">
<div class="inner"></div>
</div>
Expand Down Expand Up @@ -44,7 +66,9 @@ export function Snowfall() {
<div class="snowflake">
<div class="inner"></div>
</div>
</div>;
</div> }

</>;
}

// CSS styles (include in your CSS file or add inline)
Expand Down
2 changes: 1 addition & 1 deletion src/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildMajor":"2","buildMinor":34,"buildRevision":3,"buildTag":"RELEASE","when":"Tue, 26 Nov 2024 12:03:48 GMT"}
{"buildMajor":"2","buildMinor":34,"buildRevision":4,"buildTag":"RELEASE","when":"Tue, 03 Dec 2024 20:44:50 GMT"}

0 comments on commit 04e8b49

Please sign in to comment.