1.1.4 • Published 8 years ago

react-controlfacades v1.1.4

Weekly downloads
192
License
MIT
Repository
github
Last release
8 years ago

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.
1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.4.0

9 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago