mirror of
https://github.com/zhigang1992/stateful.git
synced 2026-04-30 20:22:15 +08:00
init create-react-library@2.6.4
This commit is contained in:
9
.babelrc
Normal file
9
.babelrc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
["env", {
|
||||||
|
"modules": false
|
||||||
|
}],
|
||||||
|
"stage-0",
|
||||||
|
"react"
|
||||||
|
]
|
||||||
|
}
|
||||||
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
23
.eslintrc
Normal file
23
.eslintrc
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"parser": "babel-eslint",
|
||||||
|
"extends": [
|
||||||
|
"standard",
|
||||||
|
"standard-react"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"es6": true
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"react"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
// don't force es6 functions to include space before paren
|
||||||
|
"space-before-function-paren": 0,
|
||||||
|
|
||||||
|
// allow specifying true explicitly for boolean props
|
||||||
|
"react/jsx-boolean-value": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
21
.gitignore
vendored
Normal file
21
.gitignore
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# builds
|
||||||
|
build
|
||||||
|
dist
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
4
.travis.yml
Normal file
4
.travis.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- 9
|
||||||
|
- 8
|
||||||
31
README.md
Normal file
31
README.md
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# @zhigang1992/stateful
|
||||||
|
|
||||||
|
> Stateful Wrapper for not having to write react classes
|
||||||
|
|
||||||
|
[](https://www.npmjs.com/package/@zhigang1992/stateful) [](https://standardjs.com)
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install --save @zhigang1992/stateful
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import React, { Component } from 'react'
|
||||||
|
|
||||||
|
import MyComponent from '@zhigang1992/stateful'
|
||||||
|
|
||||||
|
class Example extends Component {
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<MyComponent />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT © [zhigang1992](https://github.com/zhigang1992)
|
||||||
2164
example/README.md
Normal file
2164
example/README.md
Normal file
File diff suppressed because it is too large
Load Diff
20
example/package.json
Normal file
20
example/package.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "@zhigang1992/stateful-example",
|
||||||
|
"homepage": "https://zhigang1992.github.io/@zhigang1992/stateful",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"license": "MIT",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"prop-types": "^15.6.2",
|
||||||
|
"react": "^16.4.1",
|
||||||
|
"react-dom": "^16.4.1",
|
||||||
|
"react-scripts": "^1.1.4",
|
||||||
|
"@zhigang1992/stateful": "link:.."
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "react-scripts start",
|
||||||
|
"build": "react-scripts build",
|
||||||
|
"test": "react-scripts test --env=jsdom",
|
||||||
|
"eject": "react-scripts eject"
|
||||||
|
}
|
||||||
|
}
|
||||||
20
example/public/index.html
Normal file
20
example/public/index.html
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<meta name="theme-color" content="#000000">
|
||||||
|
|
||||||
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
||||||
|
|
||||||
|
<title>@zhigang1992/stateful</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
You need to enable JavaScript to run this app.
|
||||||
|
</noscript>
|
||||||
|
|
||||||
|
<div id="root"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
8
example/public/manifest.json
Normal file
8
example/public/manifest.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"short_name": "@zhigang1992/stateful",
|
||||||
|
"name": "@zhigang1992/stateful",
|
||||||
|
"start_url": "./index.html",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#000000",
|
||||||
|
"background_color": "#ffffff"
|
||||||
|
}
|
||||||
13
example/src/App.js
Normal file
13
example/src/App.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import React, { Component } from 'react'
|
||||||
|
|
||||||
|
import ExampleComponent from '@zhigang1992/stateful'
|
||||||
|
|
||||||
|
export default class App extends Component {
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<ExampleComponent text='Modern React component module' />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
5
example/src/index.css
Normal file
5
example/src/index.css
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
7
example/src/index.js
Normal file
7
example/src/index.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import ReactDOM from 'react-dom'
|
||||||
|
|
||||||
|
import './index.css'
|
||||||
|
import App from './App'
|
||||||
|
|
||||||
|
ReactDOM.render(<App />, document.getElementById('root'))
|
||||||
7095
example/yarn.lock
Normal file
7095
example/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
60
package.json
Normal file
60
package.json
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
{
|
||||||
|
"name": "@zhigang1992/stateful",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Stateful Wrapper for not having to write react classes",
|
||||||
|
"author": "zhigang1992",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "zhigang1992/stateful",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"module": "dist/index.es.js",
|
||||||
|
"jsnext:main": "dist/index.es.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8",
|
||||||
|
"npm": ">=5"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "cross-env CI=1 react-scripts test --env=jsdom",
|
||||||
|
"test:watch": "react-scripts test --env=jsdom",
|
||||||
|
"build": "rollup -c",
|
||||||
|
"start": "rollup -c -w",
|
||||||
|
"prepare": "yarn run build",
|
||||||
|
"predeploy": "cd example && yarn install && yarn run build",
|
||||||
|
"deploy": "gh-pages -d example/build"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"prop-types": "^15.5.4",
|
||||||
|
"react": "^15.0.0 || ^16.0.0",
|
||||||
|
"react-dom": "^15.0.0 || ^16.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"babel-core": "^6.26.3",
|
||||||
|
"babel-eslint": "^8.2.5",
|
||||||
|
"babel-plugin-external-helpers": "^6.22.0",
|
||||||
|
"babel-preset-env": "^1.7.0",
|
||||||
|
"babel-preset-react": "^6.24.1",
|
||||||
|
"babel-preset-stage-0": "^6.24.1",
|
||||||
|
"cross-env": "^5.1.4",
|
||||||
|
"eslint": "^5.0.1",
|
||||||
|
"eslint-config-standard": "^11.0.0",
|
||||||
|
"eslint-config-standard-react": "^6.0.0",
|
||||||
|
"eslint-plugin-import": "^2.13.0",
|
||||||
|
"eslint-plugin-node": "^7.0.1",
|
||||||
|
"eslint-plugin-promise": "^4.0.0",
|
||||||
|
"eslint-plugin-react": "^7.10.0",
|
||||||
|
"eslint-plugin-standard": "^3.1.0",
|
||||||
|
"gh-pages": "^1.2.0",
|
||||||
|
"react": "^16.4.1",
|
||||||
|
"react-dom": "^16.4.1",
|
||||||
|
"react-scripts": "^1.1.4",
|
||||||
|
"rollup": "^0.64.1",
|
||||||
|
"rollup-plugin-babel": "^3.0.7",
|
||||||
|
"rollup-plugin-commonjs": "^9.1.3",
|
||||||
|
"rollup-plugin-node-resolve": "^3.3.0",
|
||||||
|
"rollup-plugin-peer-deps-external": "^2.2.0",
|
||||||
|
"rollup-plugin-postcss": "^1.6.2",
|
||||||
|
"rollup-plugin-url": "^1.4.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
]
|
||||||
|
}
|
||||||
37
rollup.config.js
Normal file
37
rollup.config.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import babel from 'rollup-plugin-babel'
|
||||||
|
import commonjs from 'rollup-plugin-commonjs'
|
||||||
|
import external from 'rollup-plugin-peer-deps-external'
|
||||||
|
import postcss from 'rollup-plugin-postcss'
|
||||||
|
import resolve from 'rollup-plugin-node-resolve'
|
||||||
|
import url from 'rollup-plugin-url'
|
||||||
|
|
||||||
|
import pkg from './package.json'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
input: 'src/index.js',
|
||||||
|
output: [
|
||||||
|
{
|
||||||
|
file: pkg.main,
|
||||||
|
format: 'cjs',
|
||||||
|
sourcemap: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: pkg.module,
|
||||||
|
format: 'es',
|
||||||
|
sourcemap: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
external(),
|
||||||
|
postcss({
|
||||||
|
modules: true
|
||||||
|
}),
|
||||||
|
url(),
|
||||||
|
babel({
|
||||||
|
exclude: 'node_modules/**',
|
||||||
|
plugins: [ 'external-helpers' ]
|
||||||
|
}),
|
||||||
|
resolve(),
|
||||||
|
commonjs()
|
||||||
|
]
|
||||||
|
}
|
||||||
5
src/.eslintrc
Normal file
5
src/.eslintrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"jest": true
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/index.js
Normal file
22
src/index.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import React, { Component } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
|
import styles from './styles.css'
|
||||||
|
|
||||||
|
export default class ExampleComponent extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
text: PropTypes.string
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
text
|
||||||
|
} = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.test}>
|
||||||
|
Example Component: {text}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
8
src/styles.css
Normal file
8
src/styles.css
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/* add css styles here (optional) */
|
||||||
|
|
||||||
|
.test {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 2em auto;
|
||||||
|
border: 2px solid #000;
|
||||||
|
font-size: 2em;
|
||||||
|
}
|
||||||
7
src/test.js
Normal file
7
src/test.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import ExampleComponent from './'
|
||||||
|
|
||||||
|
describe('ExampleComponent', () => {
|
||||||
|
it('is truthy', () => {
|
||||||
|
expect(ExampleComponent).toBeTruthy()
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user