0.2.0 • Published 8 months ago

react-halloween v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

react-halloween

This is a repo with some fun Halloween-themed components. It was made to support the Halloween section of patrickgillespie.com. If you scroll to the bottom of that page, you can see the Haunted and Eyes components in-action. You can see the LightsOut component on the Halloween Houses page, and the MagicalText component in the app's title bar.

Currently this library is still in a 0.* version, so its APIs may change. However, I feel pretty confident in what I have now, and I'm debating moving to version 1.0.0 in my next release.

Install

framer-motion is a peer-dependency.

  npm install framer-motion react-halloween

Demo

Storybook

To see a storybook, which contains demos of all of the components do the following: Clone the repo, install the deps, and then run the storybook.

  npm ci
  npm run storybook

Components

<Eyes />

A set of eyes which open and close and follow the cursor. This component accepts the following props:

NameTypeDefaultDescription
animationTimenumber0.75Time it takes for the eyes to open or close in seconds.
eyeBallColorstring"white"CSS color for the eyeball.
eyeLayoutstring or object'unfriendly'Defines the shape of the eye. Either a string representing a preset ("unfriendly", "menacing", "neutral"), or an object defining the details. See here for more info.
followbooleantrueIf the eyes should follow the cursor.
irisColorstring"#333"CSS color for the iris.
openbooleantrueIndicates if the eyes are open.
styleobject{}Style props to spread onto the container.
pupilColorstring"white"CSS color for the pupil.
pupilSizenumber1Number between 0 and 2, representing the pupil size.
widthnumber200The width of the component. The underlying SVGs will size themselves depending on this.

<Eye />

An eye which can open and close and can follow the cursor. This component accepts the following props:

NameTypeDefaultDescription
animationTimenumber0.75Time it takes the eye to open or close.
closedClipPathstring'M 0 4 C 3 4 7 4 10 4 C 7 4 3 4 0 4'Clip path for a closed eye.
eyeBallColorstring'white'CSS color of the eye.
followbooleantrueIf the eye should follow the cursor.
irisColorstring'#333'CSS color of the iris.
openbooleantrueIndicates if the eye is open.
openedClipPathstring'M 0 4 C 3 7 7 7 10 4 C 7 1 3 1 0 4'Clip path for an opened eye.
pupilColorstring'black'CSS color of the pupil.
pupilCoordsobject{cx:5,cy:4}The coordinates of the pupil.
pupilSizenumber1Pupil size. Should be a number between 0 and 2.
widthnumber50Width of the eye.

<Haunted />

A container which creatures (by default ghosts) will fly out of and which will glow when the cursor is hovered over it. This component accepts the following props:

NameTypeDefaultDescription
Creaturecomponentsee hereProp for overriding the creature that flies out of the container.
creatureOptionsobjectsee hereOptions for the creatures that fly out of the container.
creatureOptions.animationTimenumber1.5Fly-out time in seconds.
creatureOptions.numberOfnumber6Number of creatures/ghosts to fly out.
creatureOptions.distancenumber200Distance creature should travel in pixels.
creatureOptions.dimensionsobject{ width: 44, height: 44 }The height and width of the creature/ghost.
disableFunbooleanfalsetrue to turn off the effects.
glowOptionsobjectsee hereOptions for the glow effect.
glowOptions.animationTimenumber3Duration of glow in seconds.
glowOptions.boxShadowOffstring"0px 0px 0px rgba(255,0,0,0)"Box-shadow value when at glow lowest point.
glowOptions.boxShadowOnstring"0px 0px 40px rgba(255,0,0,1)"Box-shadow value when at glow highest point.
styleobject{}Style props to spread over the container.

<LightsOut />

Puts a website into darkness and creates a spotlight around the mouse. This should not be used for mobile/touch devices. This component accepts the following props:

NameTypeDefaultDescription
sizenumber300Size of the spotlight around the mouse.
darkColorstring'rgba(0,0,0,0.9)'Color of the backdrop.
clickToTurnOnLightsbooleanfalsetrue to turn off the effects.
zIndexnumber100000z-index of overlay

<MagicalText />

Not your granddaddy's color faded text, this component creates a gradient that moves and has (optional) sparkles or other adornments (such as ghosts or hearts). Initial idea was inspired by a Hyperplexed video. The adornments which appear around the text are simple SVG components. This library contains several which can be used with this component. You can see what these look like here.

This component accepts the following props:

NameTypeDefaultDescription
textstring''The text to display.
animationTimenumber10Length of the fade animation in seconds.
colorsArray'darkorange', 'purple'Array of CSS colors to fade.
fadeTextbooleantruetrue if text should be color faded, false otherwise.
disableFunbooleanfalsetrue to disable fade and adornment effects.
styleobject{}Style props to spread over the container.
AdornmentComponentStarCrossSVGComponent to use as the adornment. Several come from the library. See examples.
showAdornmentsbooleantrueIf the adornments/sparkles should be shown.
adornmentOptionsObjectOptions to customize the adornment.
adornmentOptions.animationTypeOne of: 'sparkle', 'scale''sparkle'How the adornment will be animated.
adornmentOptions.widthnumber16Width of adornment.
adornmentOptions.heightnumber16Height of adornment.
adornmentOptions.opacitynumber0.7Opacity of adornment.
adornmentOptions.durationnumber1Duration of adornment in seconds.
adornmentOptions.numberOfnumber3Number of adornments.
0.2.0

8 months ago

0.1.0

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago