1.1.0 • Published 4 years ago

playing-card v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Vanilla Playing Card is a easy way to impleent playing cards on web pages.

Features

  • Simple interface to modify the component to your liking
  • Lightweight, since the component doesn't depend on any libraries
  • Framework agnostic

Demo

Link to demo

Install

npm install playing-card --save

Usage

<style>
    playing-card {
        --card-size: 5rem;
        background: linear-gradient(#e66465, #9198e5);
    }
</style>

<playing-card rank="10" suit="D" flippable></playing-card>

<script type="module">
    import 'playing-card';
</script>

Properties

NameTypeValuesDescription
StyleStringFlippable & PeekableDetermines the type of card and it's interactions
RankStringA, 2-10, J, Q or KDetermines the rank of the playing card
SuitStringD, H, C or SDetermines the suit of the playing card. Characters are short from Diamonds, Hearts, Clubs and Spades

API

NameDescription
flip()Flip the card
peek()Function called when a peekable card receives a mousedown -event. Use this is if you need to trigger the event virtually

Styling

Size

The size of the card can be easily modified with a css variable

playing-card {
    --card-size: 4rem;
}

Background

The background, or so called "Card back" can be whatever you want. It follows the regular background properties of a HTML element

playing-card {
    background: green center/50% no-repeat url('https://image.flaticon.com/icons/png/512/8/8817.png');
}

Contributing

Currently most of the development is being done by Matsuuu, but the following fields could use contributions:

  • A11y
  • Mobile-support
  • Optimizing the SVG's