🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

react-tap-to-reveal-options

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-tap-to-reveal-options

React component to flip items in list and reveal options

latest
Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
22
46.67%
Maintainers
1
Weekly downloads
 
Created
Source

React Tap To Reveal Options

A simple react component intended for use on mobile.

Demo

Usage

npm install react-tap-to-reveal-options

Code

import Flippable from 'react-tap-to-reveal-options';

const options = ['One', 'Two', 'Three'];
// or
const options = [
  {label: 'One', key: 'first'},
  {label: 'Two', key: 'second'},
  {label: 'Three', key: 'last'}
];

<Flippable options={options} onSelect={cb} selected={'first'}>
  <div>
    Your content for front side
  </div>
  <div className="myclass">
    Supports multiple children
  </div>
</Flippable>

function cb(selectedOption) {
  console.log(selectedOption);
  // "One" | "Two" | "Three" if you passed an array of strings
  // "first" | "second" | "last" if you passed an array of objects
}

Style

.ttro-front {
  height: 50px; /* mandatory */
  /* Your styles for front side */
}

.ttro-back {
  /* Your styles for back side */
}

.ttro-item {
  /* Your styles for all options */
}

.ttro-item:active {
  /* Your styles for pressed option */
}

/* Your styles for individual options, based on index if you passed an array */
.ttro-item-One {background-color: #613DC1;}
.ttro-item-Two {background-color: #542280;}
.ttro-item-Three {background-color: #2B3A67;}

/* Your styles for individual options, based on keys if you passed an object */
.ttro-item-first {background-color: #613DC1;}
.ttro-item-second {background-color: #542280;}
.ttro-item-last {background-color: #2B3A67;}

How to flip other items back to default state

See the example.

Keywords

react

FAQs

Package last updated on 14 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts