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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@letele/playing-cards

v0.1.0

Published

react svg playing cards

Downloads

91

Readme

SVG Playing Cards Components for React Applications

This package offers a set of React SVG components for playing cards that have been converted from Adrian Kennard's classic SVG and print ready playing card designs. Each card is presented as an SVG element, simplifying its integration into any React application.

Usage

1. Using a specific card

To use a specific card, you can import the corresponding component from the package and render it within your component. The card's suit and rank are represented by the first and second letters of the component name respectively.

import { Sq } from '@letele/playing-cards';

//...

return (
  <div className='card-container'>
    <Sq style={{ height: '100%', width: '100%' }} />
  </div>
);

2. Using the whole deck

You can also import the entire deck of cards and access specific cards as needed. Import the deck object from the package and use the card components as properties of the deck object. This approach allows you to dynamically choose cards to render.

import * as deck from '@letele/playing-cards';

const Card = deck['Sq'];

//...

return (
  <div className='card-container'>
    <Card style={{ height: '100%', width: '100%' }} />
  </div>
);

Card Container Dimensions

The dimensions of the card container are fixed at a ratio of 5:7 (width:height). Therefore, to ensure the SVG card spans the entire height and width of the container, set the height and width of the card SVG to 100%.

return (
  <div className='card-container'>
    <Card style={{ height: '100%', width: '100%' }} />
  </div>
);

Supported Cards

The package provides SVG components for standard playing cards, including different ranks (A, 2-10, J, Q, K) and suits (Hearts, Diamonds, Clubs, Spades). Additionaly there are 2 joker cards (J1, J2) and 2 back side cards (B1,B2) that represent the backside of a card.

Card Naming Convention

The naming convention for card components is a combination of the suit and rank initials.

  • H:Hearts,D:Diamonds,C:Clubs,S:Spades
  • The ranks are: (a,2-10,j,q,k)
  • For instance, H2 represents the 2 of Hearts, and Sk represents the King of Spades.

License

This package is distributed under the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication license as from the original svg cards from Adrian Kennard.