Socket
Book a DemoInstallSign in
Socket

react-controlfacades

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-controlfacades

Style form controls but use their default behavior

1.1.4
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
4
Weekly downloads
 
Created
Source

react-controlfacades

This project gives you a way to easily customize control "facades"—what's presented to a user—while keeping the native browser functionality. For example, you can provide a custom component for displaying a <select>, but interacting with it will trigger the browser's dropdown, wheel (iOS), or other browser-appropriate view. It works by overlaying the original control with an opacity of 0 on top of your custom component.

In effect, this package gives you controllers and allows you to provide your own "dumb view" or "controlled" components for displaying state.

This is based on previous work on the jquery.icbiacontrol plugin.

Usage

import React from 'react';
import {checkbox} from 'react-controlfacades';

@checkbox()
class MyCheckbox extends React.Component {
  render() {
    const style = {
      display: 'inline-block',
      width: '30px',
      height: '30px',
      border: '2px solid black',
      backgroundColor: this.props.value ? 'black': 'white',
    };

    return (
      <div style={style}></div>
    );
  }
}

The facade will receive the following props:

namedescription
valueThe value of the control
labelFor select boxes, the option string that corresponds to the selected value.
checkedFor check boxes, a boolean the corresponds to whether or not the box has been checked
focusWhether or not the control has focus

The wrapped facade will also accept some props for managing behavior:

namedescription
autoFocusWhether or not to immediately focus the control on mount.
onFocusA callback for when the control receives focus. Receives the event as its only argument.
onBlurA callback for when the control loses focus. Receives the event as its only argument.

Keywords

react-component

FAQs

Package last updated on 16 Jun 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.