2.0.3 • Published 10 months ago

reactjs-flip-card v2.0.3

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

ReactJsFlipCard

works with: React >= 16.8

important! Changed some props from version 2.x.x. Starting from version 2, there will be no CSS conflicts thanks to :where and module.css. More about Specificity, the :where exception and css modules

Getting Started

You can install the module via npm or yarn:

npm install reactjs-flip-card
yarn add reactjs-flip-card

Demo

Live Demo

Project Structure

The project includes a demo folder initialized with Create React App.

When you run the command build from reactjs-flip-card package.json, a dist and a lib folder will be generated.

The lib folder will be placed automatically into the demo project.

You can move into demo directory and start project from its own package.json script, just like any other Create React App.

Usage

You can pass style or CSS classes through props. Note that the style is the one that will have the highest priority. (Not true for version 2.x.x. You can pass your custom classNames and they will get higher priority).

Please do not pass background or backgroundColor property into flipCardStyle as it may cause unexpected behaviours on different browsers. Use the props frontStyle and backStyle and pass the same style. You could have also used frontCss and backCss passing your custom classes

import ReactFlipCard from 'reactjs-flip-card'

function App() {
    
    const styles = {
        card: {background: 'blue', color: 'white', borderRadius: 20,},
    }
    
    return (
        <ReactFlipCard
            frontStyle={styles.card}
            backStyle={styles.card}
            frontComponent={<div>Hover me!</div>}
            backComponent={<div>Back!</div>}
        />
    );
}

More examples on demo/src/App.js

Props V2.x.x

NameTypeDefaultDescription
containerStyleCSSProperties{}The style of the div container
containerCssstring''The additional className of the div container
flipCardStyleCSSProperties{}The style of the card itself. Important: please do not pass background or background color property here as it may cause unexpected behaviours on different browsers. Use the props frontStyle and backStyle and pass the same style there
flipCardCssstring''The additional className of the card itself. Important: please do not pass background or background-color property here as it may cause unexpected behaviours on different browsers. Use the props frontCss and backCss and pass the same css there
frontStyleCSSProperties{}The style of the front card
frontCssstring''The additional className of the front card
backStyleCSSProperties{}The style of the back card
backCssstring''The additional className of the back card
direction'vertical'|'horizontal'|'diagonal'horizontalThe direction of the flip card
flipTrigger'onClick'|'onHover'|'disabled'|'onHover'The event that trigger the flip
flipByPropboolean|undefinedundefinedEventually handle flip from boolean prop. Eventually you can set flipTrigger to 'disabled' if this prop is enabled
frontComponentReactNoderequiredAny JSX Component
backComponentReactNoderequiredAny JSX Component
onClickMouseEventHandler_=>un...edAny callback assigned to the onClick event. This event relates to the card container
onMouseEnterMouseEventHandler_=>un...edAny callback assigned to the onMouseEnter event. This event relates to the card container
onMouseLeaveMouseEventHandler_=>un...edAny callback assigned to the onMouseLeave event. This event relates to the card container

Props V1.x.x

width | height | cursor: removed in version 2. Optionally Pass them into containerStyle orcontainerCss for version 2. Same default values

flipCardContainerStyle : renamed as containerStyle in version 2

flipCardContainerCss : renamed as containerCss in version 2

transitionDuration : removed in version 2. Optionally Pass it into flipCardStyle or flipCardCss. Same default value

NameTypeDefaultDescription
widthCSSProperties'100px'The width of the div container
heightCSSProperties'100px'The height of the div container
cursorCSSProperties'default'The cursor type that appear when mouse hover the div container
transitionDurationCSSProperties'0.5s'The transition duration of the div container
flipCardContainerStyleCSSProperties{}The style of the div container
flipCardContainerCssstring''The additional className of the div container
flipCardStyleCSSProperties{}The style of the card itself. Important: please do not pass background or background color property here as it may cause unexpected behaviours on different browsers. Use the props frontStyle and backStyle and pass the same style there
flipCardCssstring''The additional className of the card itself. Important: please do not pass background or background-color property here as it may cause unexpected behaviours on different browsers. Use the props frontCss and backCss and pass the same css there
frontStyleCSSProperties{}The style of the front card
frontCssstring''The additional className of the front card
backStyleCSSProperties{}The style of the back card
backCssstring''The additional className of the back card
direction'vertical'|'horizontal'|'diagonal'horizontalThe direction of the flip card
flipTrigger'onClick'|'onHover'|'disabled'|'onHover'The event that trigger the flip
flipByPropboolean|undefinedundefinedEventually handle flip from boolean prop. Eventually you can set flipTrigger to 'disabled' if this prop is enabled
frontComponentReactNoderequiredAny JSX Component
backComponentReactNoderequiredAny JSX Component
onClickMouseEventHandler_=>un...edAny callback assigned to the onClick event. This event relates to the card container
onMouseEnterMouseEventHandler_=>un...edAny callback assigned to the onMouseEnter event. This event relates to the card container
onMouseLeaveMouseEventHandler_=>un...edAny callback assigned to the onMouseLeave event. This event relates to the card container

Contributing and Support

Contributions of any kind are welcome.

If this package was helpful to you, please consider putting a star on the GitHub project.

License

MIT

2.0.3

10 months ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.81

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago