JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q51788F
  • License MIT

Custom SVG prop types for React.

Package Exports

  • svg-prop-types

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (svg-prop-types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

svg-prop-types

Build Status

Custom SVG prop types for React.

SVG content type:

...

SVG and HTML attributes sets:

  • shape contains common shapes attributes
  • conditionalProcessing
  • core contains core HTML attributes
  • graphicalEvent contains graphical events attributes
  • documentEvent contains document events attributes
  • presentation contains presentational attributes

...

SVG elements:

  • SVG
  • circle
  • line

...

Usage

import React, { Component } from 'react';
import { circle as circlePropType } from 'svg-prop-types';

class Circle extends Component {
  static propTypes = circlePropType;

  render() {
    return (
      <circle
        {...this.props}
      />
    );
  }
}

export default Circle;

Production

Build pipeline is borrowed from https://github.com/airbnb/prop-types

Since PropTypes are typically not included in production builds of React, this library’s functionality serves no useful purpose. As such, when the NODE_ENV environment variable is "production", instead of exporting the implementations of all these prop types, we export mock functions - in other words, something that ensures that no exceptions are thrown, but does no validation. When environment variables are inlined (via a browserify transform or webpack plugin), then tools like webpack or uglify are able to determine that only the mocks will be imported - and can avoid including the entire implementations in the final bundle that is sent to the browser. This allows for a much smaller ultimate file size, and faster in-browser performance, without sacrificing the benefits of PropTypes themselves.

Tests

Simply clone the repo, npm install, and run npm test