Skip to content

Commit da4076f

Browse files
committed
Move out example to separate repository
1 parent 0106a98 commit da4076f

File tree

11 files changed

+40
-209
lines changed

11 files changed

+40
-209
lines changed

README.md

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
purescript-react
2-
================
1+
# purescript-react
32

43
[![Maintainer: paf31](https://img.shields.io/badge/maintainer-paf31-lightgrey.svg)](http://github.com/paf31) ![React: 0.13.3](https://img.shields.io/badge/react-0.13.3-lightgrey.svg)
54

@@ -9,63 +8,12 @@ For a more high-level set of bindings, you might like to look at `purescript-the
98

109
- [Module Documentation](docs/)
1110

12-
## Building
11+
## Installation
1312

14-
The library and example can be built with Pulp as follows:
15-
16-
pulp dep update
17-
pulp build
18-
19-
pulp test -r cat > example/index.js
20-
open example/index.html
13+
```
14+
bower install purescript-react
15+
```
2116

2217
## Example
2318

24-
```purescript
25-
module Main where
26-
27-
import Prelude
28-
29-
import Control.Monad.Eff
30-
31-
import Data.Maybe.Unsafe (fromJust)
32-
import Data.Nullable (toMaybe)
33-
34-
import DOM (DOM())
35-
import DOM.HTML (window)
36-
import DOM.HTML.Document (body)
37-
import DOM.HTML.Types (htmlElementToElement)
38-
import DOM.HTML.Window (document)
39-
40-
import DOM.Node.Types (Element())
41-
42-
import React
43-
44-
import qualified React.DOM as D
45-
import qualified React.DOM.Props as P
46-
47-
incrementCounter ctx e = do
48-
val <- readState ctx
49-
writeState ctx (val + 1)
50-
51-
counter = createClass $ spec 0 \ctx -> do
52-
val <- readState ctx
53-
return $ D.p [ P.className "Counter"
54-
, P.onClick (incrementCounter ctx)
55-
]
56-
[ D.text (show val)
57-
, D.text " Click me to increment!"
58-
]
59-
60-
main = container >>= render ui
61-
where
62-
ui :: ReactElement
63-
ui = D.div [] [ createFactory counter {} ]
64-
65-
container :: forall eff. Eff (dom :: DOM | eff) Element
66-
container = do
67-
win <- window
68-
doc <- document win
69-
elm <- fromJust <$> toMaybe <$> body doc
70-
return $ htmlElementToElement elm
71-
```
19+
Please refer to [purescript-react-example](https://github.com/purescript-contrib/purescript-react)

bower.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
{
22
"name": "purescript-react",
33
"homepage": "https://github.com/purescript-contrib/purescript-react",
4-
"description": "Purescript bindings for React.js",
4+
"description": "PureScript bindings for react",
5+
"main": "",
56
"keywords": [
67
"purescript",
78
"react"
89
],
910
"license": "MIT",
1011
"ignore": [
11-
"**/.*",
12-
"node_modules",
13-
"bower_components",
14-
"test",
15-
"tests"
12+
"*",
13+
"!src/**/*"
1614
],
1715
"repository": {
1816
"type": "git",
1917
"url": "git://github.com/purescript-contrib/purescript-react.git"
2018
},
21-
"devDependencies": {
22-
"purescript-console": "~0.1.1"
23-
},
2419
"dependencies": {
2520
"purescript-eff": "~0.1.2",
2621
"purescript-unsafe-coerce": "~0.1.0"

example/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/index.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/React.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ function createClass(spec) {
6060
return spec.render(this)();
6161
},
6262
getInitialState: function(){
63-
return spec.getInitialState(this)();
63+
return {
64+
state: spec.getInitialState(this)()
65+
};
6466
},
6567
componentWillMount: function(){
6668
return spec.componentWillMount(this)();

src/React.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module React
5151
, handle
5252

5353
, createClass
54+
, createClassStateless
5455
, createElement
5556
, createFactory
5657
) where

src/React/DOM.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
// module React.DOM
55

6+
var React = require('react');
7+
68
function mkProps(props) {
79
var result = {};
810

src/React/DOM/Props.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,30 @@
33

44
// module React.DOM.Props
55

6-
exports.unsafeMkProps = function(key) {
7-
return function(value) {
8-
var result = {};
9-
result[key] = value;
10-
return result;
11-
};
12-
};
6+
var React = require('react');
137

14-
exports.unsafeUnfoldProps = function(key) {
15-
return function(value) {
16-
var result = {};
17-
var props = {};
18-
props[key] = result;
8+
function unsafeMkProps(key) {
9+
return function(value){
10+
var result = {};
11+
result[key] = value;
12+
return result;
13+
};
14+
}
15+
exports.unsafeMkProps = unsafeMkProps;
1916

20-
for (var subprop in value) {
21-
if (value.hasOwnProperty(subprop)) {
22-
result[subprop] = value[subprop];
23-
}
24-
}
17+
function unsafeUnfoldProps(key) {
18+
return function(value){
19+
var result = {};
20+
var props = {};
21+
props[key] = result;
2522

26-
return props;
27-
};
28-
};
23+
for (var subprop in value) {
24+
if (value.hasOwnProperty(subprop)) {
25+
result[subprop] = value[subprop];
26+
}
27+
}
28+
29+
return props;
30+
};
31+
}
32+
exports.unsafeUnfoldProps = unsafeUnfoldProps;

test/Container.purs

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/Main.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/Main.purs

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)