├── .babelrc
├── .editorconfig
├── .gitignore
├── .npmignore
├── README.md
├── demo
├── index.html
├── index.js
└── webpack.config.js
├── package.json
└── src
└── index.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "es2015",
4 | "react"
5 | ],
6 | "plugins": [
7 | "add-module-exports"
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | lib
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .babelrc
2 | src
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-fifteen-kilos
2 |
3 | Bring the magic of [fifteen-kilos](https://github.com/mxstbr/fifteen-kilos) to your entire React application.
4 |
5 | ```bash
6 | $ npm install --save react-fifteen-kilos
7 | ```
8 |
9 | ## Usage
10 |
11 | ```js
12 | import React from 'react';
13 |
14 | import fifteenKilos from 'react-fifteen-kilos';
15 | fifteenKilos(React);
16 | ```
17 |
18 | ## License
19 |
20 | [MIT](https://markdalgleish.mit-license.org/)
21 |
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/demo/index.js:
--------------------------------------------------------------------------------
1 | require('./index.html');
2 |
3 | import React from 'react';
4 |
5 | import fifteenKilos from '../src';
6 | fifteenKilos(React);
7 |
8 | import { render } from 'react-dom';
9 |
10 | const App = () => (
11 |
12 |
react-fifteen-kilos
13 |
14 |
Demo
15 |
16 |
By default, any text node in React can equal any size.
17 |
18 |
Thanks to fifteen-kilos, we can now ensure that all text nodes are exactly 15KB.
19 |
20 | );
21 |
22 | const outlet = document.getElementById('outlet');
23 | render(, outlet);
24 |
--------------------------------------------------------------------------------
/demo/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | context: __dirname,
3 |
4 | entry: './index.js',
5 |
6 | output: {
7 | path: 'dist',
8 | filename: 'script.js'
9 | },
10 |
11 | module: {
12 | loaders: [
13 | {
14 | test: /\.html$/,
15 | loader: 'file?name=[name].[ext]'
16 | },
17 | {
18 | test: /\.js$/,
19 | loader: 'babel'
20 | }
21 | ]
22 | }
23 | };
24 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-fifteen-kilos",
3 | "version": "1.0.0",
4 | "description": "Bring the magic of fifteen-kilos to your entire React application",
5 | "main": "lib/index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server --config demo/webpack.config.js",
8 | "test": "echo \"Error: no test specified\" && exit 1",
9 | "build": "rm -rf lib/ && babel -d lib/ src/",
10 | "prepublish": "npm run build"
11 | },
12 | "repository": {
13 | "type": "git",
14 | "url": "git+https://github.com/markdalgleish/react-fifteen-kilos.git"
15 | },
16 | "author": "Mark Dalgleish",
17 | "license": "MIT",
18 | "bugs": {
19 | "url": "https://github.com/markdalgleish/react-fifteen-kilos/issues"
20 | },
21 | "homepage": "https://github.com/markdalgleish/react-fifteen-kilos#readme",
22 | "dependencies": {
23 | "fifteen-kilos": "^2.0.0"
24 | },
25 | "peerDependencies": {
26 | "react": "^0.14.0 || ^15.0.0-0"
27 | },
28 | "devDependencies": {
29 | "babel-cli": "^6.11.4",
30 | "babel-core": "^6.13.2",
31 | "babel-loader": "^6.2.4",
32 | "babel-plugin-add-module-exports": "^0.2.1",
33 | "babel-preset-es2015": "^6.13.2",
34 | "babel-preset-react": "^6.11.1",
35 | "babel-register": "^6.11.6",
36 | "file-loader": "^0.9.0",
37 | "lodash.times": "^4.3.1",
38 | "react": "^15.3.0",
39 | "react-dom": "^15.3.0",
40 | "webpack": "^1.13.1",
41 | "webpack-dev-server": "^1.14.1"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import fifteen from 'fifteen-kilos';
2 |
3 | export default React => {
4 | const oldCreateElement = React.createElement;
5 |
6 | React.createElement = function(type, props, ...children) {
7 | return oldCreateElement.call(this, type, props, ...children.map(child => {
8 | return typeof child === 'string' ? fifteen : child;
9 | }));
10 | };
11 | };
12 |
--------------------------------------------------------------------------------