Skip to content

Commit

Permalink
feat: add snowfall to website for fun (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
artmsilva committed Dec 19, 2023
1 parent 0edd183 commit 3f907e4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.washingtonpost.com/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"react-error-boundary": "^3.1.4",
"react-hook-form": "^7.41.0",
"react-phone-number-input": "^3.2.13",
"react-snowfall": "^1.2.1",
"react-svg": "^15.0.4",
"react-toastify": "^8.2.0",
"remark-gfm": "^3.0.1",
Expand Down
44 changes: 44 additions & 0 deletions build.washingtonpost.com/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,49 @@ import SEO from "../next-seo.config";
import "@washingtonpost/wpds-tokens/dist/styles.css";
import "../public/global.css";

import Snowfall from "react-snowfall";

const WinterWonderland = () => {
// client side check for christmas, off by default
const [showSnow, setShowSnow] = React.useState(false);

React.useEffect(() => {
// only run on client
if (typeof window === "undefined") {
return;
}

// check if it's after christmas
const today = new Date();
const christmas = new Date(today.getFullYear(), 11, 25);
if (today.getMonth() === 11 && today.getDate() > 25) {
christmas.setFullYear(christmas.getFullYear() + 1);
}

// if it's after christmas, don't show snow
if (today > christmas) {
return;
}

// if it's before christmas, show snow
setShowSnow(true);
}, []);

if (!showSnow) {
return null;
}

return (
<Snowfall
style={{
position: "fixed",
width: "100vw",
height: "100vh",
}}
/>
);
};

const globalTextStyles = globalCss({
body: {
color: "$accessible",
Expand Down Expand Up @@ -87,6 +130,7 @@ function App({ Component, pageProps }) {

return (
<>
<WinterWonderland />
<DefaultSeo {...SEO} />
<ThemeProvider
attribute="class"
Expand Down
4 changes: 2 additions & 2 deletions build.washingtonpost.com/services/getContributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export const getContributors = async () => {
.concat({
name: "baconjulie",
avatar: "https://avatars.githubusercontent.com/u/5865863?v=4",
url: "https://github.com/baconjulie"
url: "https://github.com/baconjulie",
})
.concat({
name: "erikreyna",
avatar: "https://avatars.githubusercontent.com/u/2431045?v=4",
url: "https://github.com/erikreyna"
url: "https://github.com/erikreyna",
})
// sort alphabetically
.sort((a, b) => (a.name > b.name ? 1 : -1))
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 comments on commit 3f907e4

@vercel
Copy link

@vercel vercel bot commented on 3f907e4 Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wpds-ui-kit – ./build.washingtonpost.com

build.washingtonpost.com
wpds-ui-kit-git-main.preview.now.washingtonpost.com
wpds-ui-kit.preview.now.washingtonpost.com

@vercel
Copy link

@vercel vercel bot commented on 3f907e4 Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wpds-ui-kit-storybook – ./

wpds-ui-kit-storybook-git-main.preview.now.washingtonpost.com
wpds-ui-kit-storybook.preview.now.washingtonpost.com

Please sign in to comment.