Skip to content

Commit 6425501

Browse files
Merge pull request #9 from remarkablemark/feat/react-property
feat(react-property): create package for HTML and SVG DOM property configs
2 parents 85f1f70 + 2566764 commit 6425501

File tree

17 files changed

+421
-2
lines changed

17 files changed

+421
-2
lines changed

.commitlintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"scope-enum": [
55
2,
66
"always",
7-
["all", "react-15", "react-dom-core", "release", "root"]
7+
["all", "react-15", "react-dom-core", "react-property", "release", "root"]
88
],
99
"scope-empty": [2, "never"]
1010
}

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package.json

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ A monorepo containing the following packages:
44

55
- [react-15](https://github.com/remarkablemark/react-dom-core/tree/master/packages/react-15)
66
- [react-dom-core](https://github.com/remarkablemark/react-dom-core/tree/master/packages/react-dom-core)
7+
- [react-property](https://github.com/remarkablemark/react-dom-core/tree/master/packages/react-property)
78

89
## Prerequisites
910

lerna.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"allowBranch": "master"
1313
}
1414
},
15-
"packages": ["packages/*"]
15+
"packages": ["packages/*"],
16+
"hoist": true
1617
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"bootstrap": "lerna bootstrap",
55
"changed": "lerna changed",
66
"clean": "lerna clean",
7+
"lint": "lerna run lint",
8+
"lint:fix": "lerna run lint:fix",
79
"release": "lerna publish"
810
},
911
"devDependencies": {

packages/react-property/.eslintrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"env": {
3+
"commonjs": true,
4+
"node": true
5+
},
6+
"extends": "eslint:recommended",
7+
"parserOptions": {
8+
"ecmaVersion": 6
9+
},
10+
"plugins": ["prettier"],
11+
"rules": {
12+
"prettier/prettier": "error"
13+
}
14+
}

packages/react-property/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib/

packages/react-property/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# react-property
2+
3+
[![NPM](https://nodei.co/npm/react-property.png)](https://nodei.co/npm/react-property/)
4+
5+
[![NPM version](https://img.shields.io/npm/v/react-property.svg)](https://www.npmjs.com/package/react-property)
6+
7+
HTML and SVG DOM property configs used by React.
8+
9+
## Install
10+
11+
```sh
12+
# with npm
13+
$ npm install react-property --save
14+
15+
# with yarn
16+
$ yarn add react-property
17+
```
18+
19+
## Usage
20+
21+
Import main module:
22+
23+
```js
24+
// CommonJS
25+
const property = require('react-property');
26+
27+
// ES Modules
28+
import property from 'react-property';
29+
```
30+
31+
Object output:
32+
33+
```js
34+
{
35+
HTMLDOMPropertyConfig: {
36+
autofocus: {
37+
propertyName: "autoFocus",
38+
hasBooleanValue: true,
39+
hasOverloadedBooleanValue: false
40+
},
41+
// ...
42+
},
43+
SVGDOMPropertyConfig: {
44+
accentheight: {
45+
propertyName: 'accentHeight'
46+
},
47+
// ...
48+
},
49+
isCustomAttribute: [Function: bound test]
50+
}
51+
```
52+
53+
Instead of importing all of the property configs, you can also just import what you need:
54+
55+
```js
56+
const HTMLDOMPropertyConfig = require('react-property/lib/html');
57+
const SVGAttributeToProperty = require('react-property/lib/svg/attribute-to-property');
58+
const isCustomAttribute = require('react-property/lib/is-custom-attribute');
59+
```
60+
61+
## Layout
62+
63+
```
64+
.
65+
├── index.js
66+
└── lib
67+
   ├── html
68+
   │   ├── attribute-to-property.json
69+
   │   ├── attributes.json
70+
   │   ├── boolean-properties.json
71+
   │   ├── index.js
72+
   │   └── overloaded-boolean-properties.json
73+
   ├── is-custom-attribute.js
74+
   └── svg
75+
   ├── attribute-to-property.json
76+
   ├── attributes.json
77+
   └── index.js
78+
```
79+
80+
## License
81+
82+
MIT. See [license](https://github.com/facebook/react/blob/15-stable/LICENSE) from original project.

packages/react-property/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var HTMLDOMPropertyConfig = require('./lib/html');
2+
var SVGDOMPropertyConfig = require('./lib/svg');
3+
var isCustomAttribute = require('./lib/is-custom-attribute');
4+
5+
module.exports = {
6+
HTMLDOMPropertyConfig: HTMLDOMPropertyConfig,
7+
SVGDOMPropertyConfig: SVGDOMPropertyConfig,
8+
isCustomAttribute: isCustomAttribute
9+
};

0 commit comments

Comments
 (0)