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

@kennethormandy/react-flipcard

v0.4.3

Published

Another React Flipcard, based on [@mzabriskie](https://github.com/mzabriskie)’s [react-flipcard](https://github.com/mzabriskie/react-flipcard), but with support for React v16, and some other considerations for the [Mort Modern](http://mort-modern.losttype

Downloads

237

Readme

Flipcard

Another React Flipcard, based on @mzabriskie’s react-flipcard, but with support for React v16, and some other considerations for the Mort Modern type specimen site.

Installation

npm install --save @kennethormandy/react-flipcard

Example

import React from 'react'
import { render } from 'react-dom'
import Flipcard from '@kennethormandy/react-flipcard'

// Import minimal required styles however you’d like
import '@kennethormandy/react-flipcard/dist/Flipcard.css'

class App extends React.Component {
  constructor() {
    super()

    this.state = {
      flipped: false,
    }
  }

  render() {
    return (
      <div>
        <button onClick={e => this.setState({ flipped: !this.state.flipped })}>
          Flip
        </button>
        <Flipcard flipped={this.state.flipped}>
          <h1>One</h1>
          <h1>Two</h1>
        </Flipcard>
      </div>
    )
  }
}

render(<App />, document.getElementById('target'))

Transition Type

Horizontal

<Flipcard type="horizontal">
  <h1>One</h1>
  <h1>Two</h1>
</Flipcard>

Revolving Door

<Flipcard type="revolving-door">
  <h1>One</h1>
  <h1>Two</h1>
</Flipcard>

Conditional two-column example

Gif showing the two-column layout turning into a Flipcard below a certain breakpoint.

Like in the Mort Modern type specimen site, it’s possible to change or disable the minimal Flipcard styles at certain breakpoints. This can be done entirely through CSS, but you might also want to use matchMedia to change some other part of your user interface (ex. disabling the button).

<Flipcard>
  <Card>
    <div>
      <h2>Column 1</h2>
      <p>The main column on small viewports.</p>
    </div>
  </Card>
  <Card>
    <div>
      <h2>Column 2</h2>
      <p>Flip to see me on smaller viewports.</p>
    </div>
  </Card>
</Flipcard>

Within your CSS, you might do something like this:

/* If the viewport is wide enough: */
@media (min-width: 750px) {

  /* Use the flipper as a Flexbox container: */
  .Flipcard-flipper {
    display: flex;
    transform: none !important;
  }

  /* Show both cards and remove the transitions: */
  .Flipcard-front, 
  .Flipcard-back {
    position: relative;
    transform: none !important;
    opacity: 1 !important;
  }
}

Importing styles

People have a lot of different opinions about how to manage styles alongside React. The guideline I have decided to follow is that my approach should work with a fresh Create React App setup, and not impose another dependency.

If you’d like the styles already minified and autoprefixed, import the CSS from dist:

import '@kennethormandy/react-flipcard/dist/Flipcard.css'

If you’re already running things through your own CSS build process that’s going to do those things anyway, you might want to import the styles from src instead. Then, the source maps will map back to your CSS before minification, too:

import '@kennethormandy/react-flipcard/src/Flipcard.css'

You can also path to these files from Sass, PostCSS, or another CSS build process. The styles are also quite minimal and you might want to change them, so there’s nothing wrong with copying and building on the CSS partial yourself rather than using the provided styles directly.

Credits

License

The MIT License (MIT)

Copyright © 2017–2018 Kenneth Ormandy Inc.