1.0.1 • Published 5 years ago

@dragonza/react-flip-card v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Introduction

Simple FlipCard React Component

npm i @dragonza/react-flip-card --save

Demo

Usage

FlipCard required a prop flipped to flip the card when users click on the card.

import React from 'react';
import FlipCard from 'react-flip';
import './App.css';

const BackCardContent = () => (
  <div>
    <h2>This is the back card component</h2>
  </div>
);

class App extends React.Component {
  state = {
    flipped: false
  };

  handleCardClick = () => {
    this.setState(prevState => ({
      flipped: !prevState.flipped
    }));
  };

  render() {
    return (
      <div className="App">
        <FlipCard
          cardContainerStyle={{ color: 'white', padding: '10px' }}
          flipped={this.state.flipped}
          onCardClick={this.handleCardClick}
          backContent={<BackCardContent />}
          frontContent="This is the front card"
        />
      </div>
    );
  }
}

export default App;

#Props

NametypeDefaultisRequiredDescription
flippedBoolfalseYesprops to know when to flip card
onCardClickFuncNoYescallback func when users click on the card
frontContentString or React ComponentNoYesfront card content
backContentString or React ComponentNoYesback card content
widthString200pxNowidth of the card
heightString260pxNoheight of the card
horizontalBoolfalseNomake the card flip horizontally, default is vertical flip
frontCardStyleObject{ background: '#d41f42' }Nofront card styling
backCardStyleObject{ background: '#2e508b' }Noback card styling
perspectiveString1000pxNoperspective given on the container that would make 3D space