1.0.0 • Published 4 months ago

oiia v1.0.0

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

OiiaJS

A fun React component that renders animated cats with sound effects floating all over the screen. Perfect for adding some feline chaos to your React application as an easter egg or celebration effect!

OiiaJS Demo

Installation

npm install oiiajs
# or
yarn add oiiajs

Usage

Basic Usage

import React from 'react';
import { CatInvasion } from 'oiiajs';

function App() {
  return (
    <div className="App">
      <h1>My Awesome App</h1>
      {/* Add the cat invasion component */}
      <CatInvasion />
      
      {/* Your other content */}
    </div>
  );
}

export default App;

Customization

You can customize the cat invasion with various props:

import React, { useRef } from 'react';
import { CatInvasion } from 'oiiajs';

function App() {
  const catInvasionRef = useRef();
  
  const handleToggleCats = () => {
    // Access methods via ref
    catInvasionRef.current.toggle();
  };
  
  const handleAddMoreCats = () => {
    // Add 50 more cats
    catInvasionRef.current.addCats(50);
  };
  
  return (
    <div className="App">
      <h1>My Awesome App</h1>
      
      <button onClick={handleToggleCats}>Toggle Cats</button>
      <button onClick={handleAddMoreCats}>Add More Cats!</button>
      
      <CatInvasion 
        count={128} // Number of cats (default: 256)
        minSize={64} // Minimum cat size in pixels (default: 64)
        maxSize={300} // Maximum cat size in pixels (default: 600)
        autoStart={true} // Start automatically (default: true)
        playSound={true} // Play the "oiia" sound (default: true)
        enableBackgroundEffect={true} // Enable strobing gradient background (default: true)
        backgroundAnimationSpeed={10} // Speed of background animation (default: 10)
        defaultAnimationState="random" // Default animation state (default: "random")
        maxCats={512} // Maximum number of cats (default: 512)
        customImages={[
          // Optional: provide your own cat images
          'https://example.com/cat1.jpg',
          'https://example.com/cat2.jpg',
        ]}
        ref={catInvasionRef}
      />
    </div>
  );
}

export default App;

Props

PropTypeDefaultDescription
countnumber256Initial number of cats to display
minSizenumber64Minimum size of cats in pixels
maxSizenumber600Maximum size of cats in pixels
autoStartbooleantrueWhether to start the invasion automatically
customImagesstring[][]Array of custom image URLs to use instead of default cats
playSoundbooleantrueWhether to play the "oiia" sound
enableBackgroundEffectbooleantrueWhether to enable the strobing gradient background effect
backgroundAnimationSpeednumber10Speed of the background animation (1-20)
defaultAnimationStatestring"random"Default animation state for cats
maxCatsnumber512Maximum number of cats allowed

Animation States

The following animation states are available:

  • "floating" - Cats float around the screen
  • "stationary" - Cats stay in place
  • "spinning" - Cats spin around
  • "scaling" - Cats grow and shrink
  • "scaleFloat" - Cats float and scale
  • "pulse" - Cats pulse in and out
  • "bounce" - Cats bounce up and down while scaling
  • "wobble" - Cats wobble and rotate while scaling
  • "flip" - Cats flip around the Y-axis with 3D perspective
  • "random" - Randomly selects one of the above animations for each cat

Methods

The following methods are available via ref:

  • start() - Start the cat invasion
  • stop() - Stop the cat invasion
  • toggle() - Toggle the cat invasion on/off
  • addCats(count) - Add more cats to the invasion (default: 50)
  • isActive - Boolean indicating if the invasion is active

License

MIT