Skip to content

Commit

Permalink
Merge 4f5d1e7 into ed1a8a4
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Nov 23, 2018
2 parents ed1a8a4 + 4f5d1e7 commit 6d2ae1d
Show file tree
Hide file tree
Showing 20 changed files with 20,562 additions and 21,849 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
yarn-error.log
coverage
node_modules
build
7,263 changes: 0 additions & 7,263 deletions package-lock.json

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -40,14 +40,14 @@
"babel-jest": "23.6.0",
"coveralls": "3.0.2",
"jest": "23.6.0",
"microstates": "0.10.1",
"microstates": "0.12.1",
"rollup": "0.66.4",
"rollup-plugin-babel": "4.0.3",
"rollup-plugin-filesize": "4.0.1",
"rollup-plugin-node-resolve": "3.4.0"
},
"peerDependencies": {
"microstates": "^0.9.6 || ^0.10.0"
"microstates": "0.11.0 || 0.12.0"
},
"jest": {
"testRegex": "(/tests/.*|(\\.|/)(test|spec))\\.jsx?$"
Expand Down
112 changes: 0 additions & 112 deletions sandboxes/react/App.js

This file was deleted.

15 changes: 0 additions & 15 deletions sandboxes/react/index.js

This file was deleted.

24 changes: 14 additions & 10 deletions sandboxes/react/package.json
Expand Up @@ -4,22 +4,26 @@
"version": "1.0.0",
"description": "",
"keywords": [],
"main": "index.js",
"main": "src/index.js",
"dependencies": {
"@microstates/react": "0.9.0",
"@microstates/todomvc": "1.0.0-beta.0",
"classnames": "latest",
"microstates": "0.10.1",
"classnames": "2.2.6",
"microstates": "0.12.1",
"prop-types": "15.6.2",
"react": "16.4.2",
"react-dom": "16.4.2",
"react-scripts": "1.1.4"
"react": "16.6.3",
"react-dom": "16.6.3",
"react-scripts": "2.1.1"
},
"devDependencies": {},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
43 changes: 43 additions & 0 deletions sandboxes/react/public/index.html
@@ -0,0 +1,43 @@
<!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">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>TodoMVC in React</title>
</head>

<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>

</html>
116 changes: 116 additions & 0 deletions sandboxes/react/src/App.js
@@ -0,0 +1,116 @@
import React from "react";
import classnames from "classnames";

import { map, create, Store, valueOf } from "microstates";
import TodoMVC from "@microstates/todomvc";

import TodoTextInput from "./TodoTextInput";

const pluralize = (word, count) => (count === 1 ? word : `${word}s`);

export default class App extends React.Component {
state = {
$: Store(create(TodoMVC, this.props.value), $ => {
this.setState({ $ });
this.props.onChange(valueOf($));
})
}
render() {
let { $ } = this.state;
return (
<div className="todoapp">
<header className="header">
<h1>todos</h1>
<TodoTextInput
text={$.newTodo.state}
classes="new-todo"
onSave={$.insertNewTodo}
onBlur={$.insertNewTodo}
onInputChange={$.newTodo.set}
placeholder="What needs to be done?"
/>
</header>
<section className="main">
{$.hasTodos && (
<span>
<input
id="toggle-all"
className="toggle-all"
type="checkbox"
checked={$.isAllComplete}
onChange={$.toggleAll}
/>
<label htmlFor="toggle-all" />
</span>
)}
<ul className="todo-list">
{map($.filtered, todo => (
<li
className={classnames({
completed: todo.completed.state,
editing: todo.editing.state
})}
key={todo.id.state}
>
{todo.editing.state ? (
<TodoTextInput
text={todo.text.state}
classes="edit"
onSave={todo.save}
onBlur={todo.save}
onInputChange={todo.text.set}
/>
) : (
<div className="view">
<input
className="toggle"
type="checkbox"
checked={todo.completed.state}
onChange={todo.completed.toggle}
/>
<label onDoubleClick={todo.edit}>{todo.text.state}</label>
<button
className="destroy"
onClick={() =>
$.todos.filter(item => todo.state !== item.state)
}
/>
</div>
)}
</li>
))}
</ul>
{$.hasTodos && (
<footer className="footer">
<span className="todo-count">
<strong>{$.active.length || "No"}</strong>{" "}
{pluralize("item", $.active.length)}
</span>
<ul className="filters">
{$.filters.map(filter => (
<li key={filter.key}>
<button
className={classnames({ selected: filter.selected })}
style={{ cursor: "pointer" }}
onClick={filter.select}
>
{filter.label}
</button>
</li>
))}
</ul>
{$.hasCompleted && (
<button
className="clear-completed"
onClick={$.clearCompleted}
>
Clear completed
</button>
)}
</footer>
)}
</section>
</div>
)
}
}
Expand Up @@ -32,7 +32,7 @@ export default class TodoTextInput extends Component {
className={this.props.classes}
type="text"
placeholder={this.props.placeholder}
autoFocus="true"
autoFocus={true}
value={this.props.text}
onBlur={this.handleBlur}
onChange={this.handleChange}
Expand Down
18 changes: 18 additions & 0 deletions sandboxes/react/src/index.js
@@ -0,0 +1,18 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import "./styles.css";

let key = "microstates-todomvc";

let restore = () => JSON.parse(localStorage.getItem(key) || "null");
let save = value => localStorage.setItem(key, JSON.stringify(value));

let initial = restore() || {
todos: [{ id: 0, text: "Write Microstates Docs", completed: false }]
};

ReactDOM.render(
<App value={initial} onChange={save} />,
document.getElementById("root")
);
File renamed without changes.

0 comments on commit 6d2ae1d

Please sign in to comment.