New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-polymorph

Package Overview
Dependencies
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-polymorph

React components with highly customizable logic, markup and styles.

  • 0.2.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
46
decreased by-42.5%
Maintainers
1
Weekly downloads
 
Created
Source

react-polymorph

React Polymorph is a UI framework for React, that separates logic, markup and theming of components. It's powered by CSS Modules and harmoniously integrates with your webpack workflow, although you can use any other module bundler.

Why?

  • Existing React UI frameworks are too hard to customize.
  • Overriding css styles is not enough for complex components.
  • You need multiple variations of a component with shared logic.
  • You need multiple, completely unique themes for your components.

How:

Separate monolithic React components into:

  1. Component (logic) - Only handle UI logic, do not render markup.
  2. Skin (markup) - Only render the markup, delegate to component.
  3. Theme (styling) - Only concerned about styling your skin.

Basic Example

You need standard Input components for text and a NumericInput for floating point numbers. The only difference is the logic of the component, in both cases it is "just" an input field showing some text:

Standard Input

The standard input is as simple as possible and does not much logic.

import React from 'react';
import Input from 'react-polymorph/lib/components/Input';
import InputSkin from 'react-polymorph/lib/skins/simple/InputSkin';

// Standard input component:
const MyStandardInput = (props) => (
  <Input 
    skin={InputSkin}
    label="Input with max. 5 Characters"
    maxLength={5}
  />
);

Standard Input

Numeric Input

The numeric input however is heavily specialized in guiding the user to enter correct floating point numbers.

import React from 'react';
import NumericInput from 'react-polymorph/lib/components/NumericInput';
import InputSkin from 'react-polymorph/lib/skins/simple/InputSkin';

const MyNumericInput = (props) => (
  <NumericInput
    skin={InputSkin}
    label="Amount"
    placeholder="0.000000"
    maxBeforeDot={5}
    maxAfterDot={6}
    maxValue={30000}
    minValue={0.000001}
  />
);

Standard Input

This is a simple example that shows how you can make/use specialized versions of basic components by composition - a core idea of react-polymorph!

more documentation coming soon …

Keywords

FAQs

Package last updated on 08 Jun 2017

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc