Skip to content

Commit

Permalink
feat: add duration option, closes #4 (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Benedicte Raae <raae@raae.codes>
  • Loading branch information
olavea and raae authored Dec 3, 2021
1 parent a5a9b1c commit e9478fa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ Default value if non given: "regular"
},
```

### Duration

You can configure the duration of the snowfall (as seconds).
Default value if non given: 15

```
{
resolve: "@raae/gatsby-plugin-let-it-snow",
options: {
duration: 10,
},
},
```

### Season

You can pass a `start` and `end` date to determine when the snow will start and end.
Expand Down
1 change: 1 addition & 0 deletions demo/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
resolve: "@raae/gatsby-plugin-let-it-snow",
options: {
colors: ["#fff", "#ffb6c1"],
duration: 18,
season: {
start: new Date("December 2, 2023"),
end: new Date("January 11, 2024"),
Expand Down
3 changes: 1 addition & 2 deletions plugin/gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ const isSeason = ({ start, end }) => {

export const onInitialClientRender = (_, options) => {
const { colors, intensity, season } = options;
const duration = options.duration * 1000;

if (!isSeason(season)) {
return;
}

const duration = 15 * 1000;

const animationEnd = Date.now() + duration;
let skew = 1;

Expand Down
5 changes: 5 additions & 0 deletions plugin/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ exports.pluginOptionsSchema = ({ Joi }) => {
intensity: Joi.string()
.valid("regular", "light", "blizzard")
.default("regular"),
duration: Joi.number()
.min(5)
.integer()
.default(15)
.description("Duration of snowfall in seconds"),
season: Joi.object()
.keys({
start: Joi.date().required(),
Expand Down

0 comments on commit e9478fa

Please sign in to comment.