npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

flip-frame

v2.1.1

Published

Flip Frame game template

Readme

Flip Frame

Flip Frame is a React-based library for creating dynamic flip frame games. It provides reusable components like Grid and Tile to build interactive grid-based games with customizable tiles and flipping logic.


Installation

Install the package using npm or yarn:

npm install flip-frame

Usage

Here’s how you can use the Grid and Tile components to create a flip frame game:

Example

import React from "react";
import { Grid } from "flip-frame";

const App = () => {
  return (
    <div className="container">
      <h1>Flip Frame Game</h1>
      <Grid
        gridSize={5}
        imageSrc="https://upload.wikimedia.org/wikipedia/commons/2/28/JPG_Test.jpg"
      />
    </div>
  );
};

export default App;

Components

Grid

The Grid component renders a dynamic grid of tiles and handles flipping logic.

Props

| Prop Name | Type | Default Value | Description | | ----------- | ----------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------- | | gridSize | number | 5 | The size of the grid (e.g., 5 for a 5x5 grid). Should be between 2 to 10. | | tile | React.Component | Tile | The Tile component to render each tile. | | reset | React.Component | ResetButton | The Reset Button component to reset the Flip Frame tiles. | | imageSrc | string | https://upload.wikimedia.org/wikipedia/commons/2/28/JPG_Test.jpg | The background image URL or local file for the tiles. | | tileColor | string | #ccc | The tile color when not flipped. Should be in hex color format |

Example

<Grid gridSize={4} imageSrc="https://example.com/my-image.png" />

Tile

The Tile component represents a single tile in the grid. It supports flipping and displays a background image.

Props

| Prop Name | Type | Description | | -------------------- | ---------- | --------------------------------------------------------------------------- | | flipped | boolean | Whether the tile is flipped or not. | | onClick | function | The function to call when the tile is clicked. | | backgroundImage | string | The URL or local file path of the background image for the tile. | | backgroundPosition | string | The position of the background image for the tile (e.g., center center). | | gridSize | number | The size of the grid (e.g., 5 for a 5x5 grid). Should be between 2 to 10. | | tileColor | string | The tile color when not flipped. Should be in hex color format. |

Example

<Tile
  flipped={true}
  onClick={() => console.log("Tile clicked!")}
  backgroundImage="https://example.com/my-image.jpg"
  backgroundPosition="center center"
/>

TurnCounter

The TurnCounter component displays the number of turns taken in the game.

Props

| Prop Name | Type | Description | | ----------- | -------- | -------------------------------------- | | turns | number | The current number of turns taken. | | className | string | Optional CSS class for custom styling. |

Example

<TurnCounter turns={10} className="turn-counter" />

SuccessModal

The SuccessModal component displays a congratulatory message when the game is completed.

Props

| Prop Name | Type | Description | | ------------- | ---------- | ----------------------------------------------------------------------------- | | isVisible | boolean | Whether the modal is visible or not. | | turns | number | The number of turns it took to solve the puzzle. | | message | string | The success message to display. | | renderTurns | function | Function to customize the rendering of the turns message. You can input HTML. | | onClose | function | The function to call when the modal is closed. |

Example

<SuccessModal
  isVisible={true}
  onClose={() => console.log("Modal closed!")}
  message="Congratulations! You completed the game!"
/>

Utilities

flipSplashArea

The flipSplashArea utility function flips the selected tile and its adjacent tiles (left, right, top, bottom) in a grid.

Parameters

| Parameter | Type | Description | | ---------- | ----------- | ------------------------------------------------------- | | newTiles | boolean[] | A copy of the tiles array representing the grid state. | | gridSize | number | The size of the square grid (e.g., 5 for a 5x5 grid). | | index | number | The index of the tile to flip. |

Example

import { flipSplashArea } from "flip-frame";

const tiles = [false, false, false, false, false, false, false, false, false];
flipSplashArea(tiles, 3, 4);
console.log(tiles);

validateImage

The validateImage utility function checks if the provided image is a valid JPG, PNG, or resolves to an actual image.

Parameters

| Parameter | Type | Description | | ---------- | -------- | --------------------------------- | | imageUrl | string | The URL of the image to validate. |

Returns

  • A Promise<boolean> that resolves to true if the image is valid, otherwise false.

Example

import { validateImage } from "flip-frame";

const isValid = await validateImage("https://example.com/my-image.jpg");
console.log(isValid); // true or false

Features

  • Dynamic Grid: Create grids of any size with customizable tiles.
  • Flipping Logic: Built-in logic to flip tiles and their neighbors.
  • Customizable Tiles: Use your own Tile component for custom designs.
  • Image Validation: Ensure valid images are used for tiles.

Contributing

Contributions are welcome! If you’d like to contribute, please fork the repository and submit a pull request.


License

This project is licensed under the MIT License. See the LICENSE file for details.