0.1.0 • Published 5 months ago

react-pokemon-card-effect v0.1.0

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

React Pokémon Card Effect

A React & TypeScript library for creating holographic Pokémon card effects.

Pokémon Card Effect Demo

Installation

npm install react-pokemon-card-effect

Usage

import { HoloCard, HoloEffectType } from 'react-pokemon-card-effect';
// Import the styles
import 'react-pokemon-card-effect/dist/assets/output-CMGRxOEV.css';

function MyComponent() {
  return (
    <HoloCard
      cardImage="https://assets.pokemon.com/assets/cms2/img/cards/web/SM12/SM12_EN_3.png"
      effectType={HoloEffectType.COSMOS}
      width={300}
      height={420}
      enableGyroscope={false}
    />
  );
}

Available Effects

The library provides several holographic effect types:

  • COSMOS - Colorful holographic effect with small stars
  • GALAXY - Deep space-like holographic effect
  • REVERSE - Silver/white reverse holographic effect
  • VINTAGE - Warm-toned vintage holographic effect
  • LEGENDARY - Gold-toned legendary holographic effect
  • RADIANT - Radiant holographic effect with a center glow
  • PRISM - Rainbow prism holographic effect
  • RAINBOW - Vibrant rainbow holographic effect
  • STANDARD - Standard holographic effect

Components

HoloCard

The main component for rendering a holographic Pokémon card.

Props

PropTypeDefaultDescription
cardImagestring(required)URL of the card image
effectTypeHoloEffectType(required)Type of holographic effect to apply
widthstring \| number300Width of the card
heightstring \| number420Height of the card
enableGyroscopebooleanfalseEnable gyroscope support for mobile devices
classNamestring''Additional CSS class name
styleReact.CSSProperties{}Additional inline styles
childrenReactNodeundefinedChildren elements to render inside the card
onClick() => voidundefinedCallback when the card is clicked

HoloEffect

A component for rendering just the holographic effect layer. This is used internally by HoloCard but can also be used independently.

Props

PropTypeDefaultDescription
effectTypeHoloEffectType(required)Type of holographic effect to apply
rotateXnumber(required)Rotation angle in degrees for the X axis
rotateYnumber(required)Rotation angle in degrees for the Y axis
classNamestring''Additional CSS class name

Hooks

useHoloEffect

A hook for handling the holographic effect interactions.

import { useHoloEffect } from 'react-pokemon-card-effect';

function MyComponent() {
  const { ref, rotateX, rotateY, isHovering } = useHoloEffect({
    maxRotation: 10,
    enableGyroscope: true,
    gyroscopeSensitivity: 5,
  });

  return (
    <div ref={ref} style={{ transform: `rotateX(${rotateX}deg) rotateY(${rotateY}deg)` }}>
      {/* Your content here */}
    </div>
  );
}

Options

OptionTypeDefaultDescription
maxRotationnumber10Maximum rotation angle in degrees
enableGyroscopebooleanfalseEnable gyroscope support for mobile devices
gyroscopeSensitivitynumber5Sensitivity of the gyroscope effect (1-10)

License

MIT

Author

Created by JeFaisLeCafé

Support My Work

If you find this library useful, consider supporting my work:

Credits

Inspired by poke-holo.simey.me

0.1.0

5 months ago