-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 40c14c4
Showing
8 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"stage": 0, | ||
"loose": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. | ||
# Requires EditorConfig JetBrains Plugin - http://github.com/editorconfig/editorconfig-jetbrains | ||
|
||
# Set this file as the topmost .editorconfig | ||
# (multiple files can be used, and are applied starting from current document location) | ||
root = true | ||
|
||
[{package.json}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# Use bracketed regexp to target specific file types or file locations | ||
[*.{js,json}] | ||
|
||
# Use hard or soft tabs ["tab", "space"] | ||
indent_style = space | ||
|
||
# Size of a single indent [an integer, "tab"] | ||
indent_size = tab | ||
|
||
# Number of columns representing a tab character [an integer] | ||
tab_width = 4 | ||
|
||
# Line breaks representation ["lf", "cr", "crlf"] | ||
end_of_line = lf | ||
|
||
# ["latin1", "utf-8", "utf-16be", "utf-16le"] | ||
charset = utf-8 | ||
|
||
# Remove any whitespace characters preceding newline characters ["true", "false"] | ||
trim_trailing_whitespace = true | ||
|
||
# Ensure file ends with a newline when saving ["true", "false"] | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "vgno", | ||
|
||
"parser": "babel-eslint", | ||
|
||
"env": { | ||
"es6": true | ||
}, | ||
|
||
"ecmaFeatures": { | ||
"modules": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
*.log | ||
.DS_Store | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# react-server-status | ||
|
||
Based on https://github.com/gaearon/react-side-effect | ||
|
||
## Example | ||
|
||
### React View | ||
```javascript | ||
import { Component } from 'react'; | ||
|
||
import ServerStatus from 'react-server-status'; | ||
|
||
export default class GenericView extends Component { | ||
render() { | ||
return ( | ||
<ServerStatus status={ 500 }> | ||
<div>Some content</div> | ||
</ServerStatus> | ||
); | ||
} | ||
} | ||
``` | ||
|
||
### Server | ||
```javascript | ||
// … | ||
import React from 'react'; | ||
import { renderToString } from 'react-dom/server'; | ||
import ServerStatus from 'server-status'; | ||
// … | ||
const page = renderToString(<App />); | ||
this.status = ServerStatus.rewind() || 200; | ||
/// … | ||
``` | ||
|
||
## TODO | ||
* [ ] Publish on NPM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "react-server-status", | ||
"version": "1.0.0", | ||
"description": "A declarative way to set server status", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "babel src --out-dir lib", | ||
"clean": "rimraf lib", | ||
"test": "npm run lint", | ||
"lint": "eslint .", | ||
"check": "ncu", | ||
"prepublish": "npm test && npm run clean && npm run build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:vg/react-server-status.git" | ||
}, | ||
"author": "Gustaf Dalemar", | ||
"license": "UNLICENSED", | ||
"dependencies": { | ||
"react-side-effect": "~1.0.2" | ||
}, | ||
"devDependencies": { | ||
"babel": "~5.8.21", | ||
"babel-eslint": "~4.1.1", | ||
"eslint": "~1.6.0", | ||
"eslint-config-vgno": "~3.0.0", | ||
"eslint-plugin-react": "~3.5.1", | ||
"npm-check-updates": "~2.3.0", | ||
"rimraf": "~2.4.3" | ||
}, | ||
"peerDependencies": { | ||
"react": "^0.13.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import withSideEffect from 'react-side-effect'; | ||
|
||
function reducePropsToState(propsList) { | ||
const innermostProps = propsList[propsList.length - 1]; | ||
if (innermostProps) { | ||
return innermostProps.status; | ||
} | ||
} | ||
|
||
@withSideEffect(reducePropsToState, Function.prototype) | ||
export default class ServerStatus extends React.Component { | ||
|
||
static propTypes = { | ||
status: React.PropTypes.number.isRequired | ||
} | ||
|
||
render() { | ||
return React.Children.only(this.props.children); | ||
} | ||
} |