Skip to content

Commit

Permalink
React side of reproduction of alexmingoia/purescript-pux#132
Browse files Browse the repository at this point in the history
  • Loading branch information
jmatsushita committed Jun 27, 2017
1 parent c67b8f3 commit 3ddd513
Show file tree
Hide file tree
Showing 8 changed files with 830 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"plugins": [
["module-resolver", {
"root": ["./src"],
"alias": {
"react": "preact-compat",
"react-dom": "preact-compat"
}
}]
],
"presets": ["es2015", "react", "stage-0"]
}
758 changes: 758 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "pux-todomvc",
"name": "pux-todomvc-react",
"version": "1.2.0",
"description": "Pux TodoMVC.",
"main": "support/index.js",
Expand All @@ -11,8 +11,10 @@
"scripts": {
"postinstall": "bower cache clean && bower install",
"clean": "rimraf static/dist",
"build": "npm run clean && webpack --config ./webpack.config.js --progress --profile --colors",
"watch": "npm run clean && webpack-dev-server --content-base static/ --hot --inline --config webpack.config.js",
"build": "npm run clean && npm run build:babel && webpack --config ./webpack.config.js --progress --profile --colors",
"build:babel": "babel --out-dir src/App/Component src/App/Component/React",
"watch:babel": "babel --watch --out-dir src/App/Component src/App/Component/React",
"watch": "npm run clean && webpack-dev-server --watch --content-base static/ --hot --inline --config webpack.config.js",
"serve": "npm run build && serve static",
"start": "npm run watch",
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down Expand Up @@ -41,5 +43,12 @@
"webpack-dev-server": "^2.4.5",
"webpack-node-externals": "^1.5.4",
"xhr2": "^0.1.3"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-plugin-module-resolver": "^2.7.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1"
}
}
23 changes: 23 additions & 0 deletions src/App/Component/List.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.listComponent = undefined;

var _preactCompat = require('preact-compat');

var _preactCompat2 = _interopRequireDefault(_preactCompat);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var listComponent = exports.listComponent = function listComponent(_ref) {
var children = _ref.children;

console.log('listSort.children', children);
return _preactCompat2.default.createElement(
'ul',
null,
children
);
};
11 changes: 11 additions & 0 deletions src/App/Component/List.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module App.Component where

import React (ReactClass)

import Pux.DOM.HTML (HTML)
import Pux.Renderer.React (reactClass)

foreign import listComponent :: props. ReactClass props

list :: ev. HTML ev -> HTML ev
list = reactClass listComponent "list"
10 changes: 10 additions & 0 deletions src/App/Component/React/List.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

export const listComponent = ({ children }) => {
console.log('listSort.children', children);
return (
<ul>
{children}
</ul>
);
};
2 changes: 1 addition & 1 deletion src/App/Events.purs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ foldp (Navigate url ev) state =
]

foldp (NewTodoInput ev) (State st) = noEffects $ State
if (eventToKeyPressed $ spy $ ev) == "Enter"
if (eventToKeyPressed ev) == "Enter"
then st
{ newTodo = ""
, todos = snoc st.todos $ Todo
Expand Down
4 changes: 3 additions & 1 deletion src/App/View/TodoList.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Prelude hiding (div)
import App.Routes (Route(..))
import App.State (State(..), Todo(..))
import App.Events (Event(..))
import App.Component (list)

import Data.Array (filter, length)
import Data.Foldable (for_)
import Data.Monoid (mempty)
Expand Down Expand Up @@ -58,7 +60,7 @@ view (State st) =
section ! className "main" $ do
input ! className "toggle-all" ! type' "checkbox"
label ! for "toggle-all" $ text "Mark all as complete"
ul ! className "todo-list" $ do
list ! className "todo-list" $ do
for_ filtered item
if ((length st.todos) == 0) then mempty else footer ! className "footer" $ do
span ! className "todo-count" $ do
Expand Down

0 comments on commit 3ddd513

Please sign in to comment.