From df621539b4653440d7a51833b8a1adc08da32c8c Mon Sep 17 00:00:00 2001 From: gidztech Date: Thu, 17 Jan 2019 00:05:37 +0000 Subject: [PATCH] #3 Fix reference --- .gitignore | 2 +- e2e/todomvc-react/index.html | 32 ------ e2e/todomvc-react/js/app.jsx | 181 ------------------------------ e2e/todomvc-react/js/footer.jsx | 62 ---------- e2e/todomvc-react/js/todoItem.jsx | 108 ------------------ e2e/todomvc-react/js/todoModel.js | 87 -------------- e2e/todomvc-react/js/utils.js | 50 --------- e2e/todomvc-react/license.md | 20 ---- e2e/todomvc-react/package.json | 10 -- e2e/todomvc-react/readme.md | 37 ------ package.json | 2 +- 11 files changed, 2 insertions(+), 589 deletions(-) delete mode 100644 e2e/todomvc-react/index.html delete mode 100644 e2e/todomvc-react/js/app.jsx delete mode 100644 e2e/todomvc-react/js/footer.jsx delete mode 100644 e2e/todomvc-react/js/todoItem.jsx delete mode 100644 e2e/todomvc-react/js/todoModel.js delete mode 100644 e2e/todomvc-react/js/utils.js delete mode 100644 e2e/todomvc-react/license.md delete mode 100644 e2e/todomvc-react/package.json delete mode 100644 e2e/todomvc-react/readme.md diff --git a/.gitignore b/.gitignore index a2d51d0..d78b378 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,5 @@ .env npm-debug.log node_modules -tests/todomvc-react/ +e2e/todomvc-react/ lib \ No newline at end of file diff --git a/e2e/todomvc-react/index.html b/e2e/todomvc-react/index.html deleted file mode 100644 index 3d1774c..0000000 --- a/e2e/todomvc-react/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - React • TodoMVC - - - - -
- - - - - - - - - - - - - - - - diff --git a/e2e/todomvc-react/js/app.jsx b/e2e/todomvc-react/js/app.jsx deleted file mode 100644 index ae6ea00..0000000 --- a/e2e/todomvc-react/js/app.jsx +++ /dev/null @@ -1,181 +0,0 @@ -/*jshint quotmark:false */ -/*jshint white:false */ -/*jshint trailing:false */ -/*jshint newcap:false */ -/*global React, Router*/ -var app = app || {}; - -(function () { - 'use strict'; - - app.ALL_TODOS = 'all'; - app.ACTIVE_TODOS = 'active'; - app.COMPLETED_TODOS = 'completed'; - var TodoFooter = app.TodoFooter; - var TodoItem = app.TodoItem; - - var ENTER_KEY = 13; - - var TodoApp = React.createClass({ - getInitialState: function () { - return { - nowShowing: app.ALL_TODOS, - editing: null, - newTodo: '' - }; - }, - - componentDidMount: function () { - var setState = this.setState; - var router = Router({ - '/': setState.bind(this, {nowShowing: app.ALL_TODOS}), - '/active': setState.bind(this, {nowShowing: app.ACTIVE_TODOS}), - '/completed': setState.bind(this, {nowShowing: app.COMPLETED_TODOS}) - }); - router.init('/'); - }, - - handleChange: function (event) { - this.setState({newTodo: event.target.value}); - }, - - handleNewTodoKeyDown: function (event) { - if (event.keyCode !== ENTER_KEY) { - return; - } - - event.preventDefault(); - - var val = this.state.newTodo.trim(); - - if (val) { - this.props.model.addTodo(val); - this.setState({newTodo: ''}); - } - }, - - toggleAll: function (event) { - var checked = event.target.checked; - this.props.model.toggleAll(checked); - }, - - toggle: function (todoToToggle) { - this.props.model.toggle(todoToToggle); - }, - - destroy: function (todo) { - this.props.model.destroy(todo); - }, - - edit: function (todo) { - this.setState({editing: todo.id}); - }, - - save: function (todoToSave, text) { - this.props.model.save(todoToSave, text); - this.setState({editing: null}); - }, - - cancel: function () { - this.setState({editing: null}); - }, - - clearCompleted: function () { - this.props.model.clearCompleted(); - }, - - render: function () { - var footer; - var main; - var todos = this.props.model.todos; - - var shownTodos = todos.filter(function (todo) { - switch (this.state.nowShowing) { - case app.ACTIVE_TODOS: - return !todo.completed; - case app.COMPLETED_TODOS: - return todo.completed; - default: - return true; - } - }, this); - - var todoItems = shownTodos.map(function (todo) { - return ( - - ); - }, this); - - var activeTodoCount = todos.reduce(function (accum, todo) { - return todo.completed ? accum : accum + 1; - }, 0); - - var completedCount = todos.length - activeTodoCount; - - if (activeTodoCount || completedCount) { - footer = - ; - } - - if (todos.length) { - main = ( -
- -
    - {todoItems} -
-
- ); - } - - return ( -
-
-

todos

- -
- {main} - {footer} -
- ); - } - }); - - var model = new app.TodoModel('react-todos'); - - function render() { - React.render( - , - document.getElementsByClassName('todoapp')[0] - ); - } - - model.subscribe(render); - render(); -})(); diff --git a/e2e/todomvc-react/js/footer.jsx b/e2e/todomvc-react/js/footer.jsx deleted file mode 100644 index c6b6e4d..0000000 --- a/e2e/todomvc-react/js/footer.jsx +++ /dev/null @@ -1,62 +0,0 @@ -/*jshint quotmark:false */ -/*jshint white:false */ -/*jshint trailing:false */ -/*jshint newcap:false */ -/*global React */ -var app = app || {}; - -(function () { - 'use strict'; - - app.TodoFooter = React.createClass({ - render: function () { - var activeTodoWord = app.Utils.pluralize(this.props.count, 'item'); - var clearButton = null; - - if (this.props.completedCount > 0) { - clearButton = ( - - ); - } - - var nowShowing = this.props.nowShowing; - return ( - - ); - } - }); -})(); diff --git a/e2e/todomvc-react/js/todoItem.jsx b/e2e/todomvc-react/js/todoItem.jsx deleted file mode 100644 index a14493f..0000000 --- a/e2e/todomvc-react/js/todoItem.jsx +++ /dev/null @@ -1,108 +0,0 @@ -/*jshint quotmark: false */ -/*jshint white: false */ -/*jshint trailing: false */ -/*jshint newcap: false */ -/*global React */ -var app = app || {}; - -(function () { - 'use strict'; - - var ESCAPE_KEY = 27; - var ENTER_KEY = 13; - - app.TodoItem = React.createClass({ - handleSubmit: function (event) { - var val = this.state.editText.trim(); - if (val) { - this.props.onSave(val); - this.setState({editText: val}); - } else { - this.props.onDestroy(); - } - }, - - handleEdit: function () { - this.props.onEdit(); - this.setState({editText: this.props.todo.title}); - }, - - handleKeyDown: function (event) { - if (event.which === ESCAPE_KEY) { - this.setState({editText: this.props.todo.title}); - this.props.onCancel(event); - } else if (event.which === ENTER_KEY) { - this.handleSubmit(event); - } - }, - - handleChange: function (event) { - if (this.props.editing) { - this.setState({editText: event.target.value}); - } - }, - - getInitialState: function () { - return {editText: this.props.todo.title}; - }, - - /** - * This is a completely optional performance enhancement that you can - * implement on any React component. If you were to delete this method - * the app would still work correctly (and still be very performant!), we - * just use it as an example of how little code it takes to get an order - * of magnitude performance improvement. - */ - shouldComponentUpdate: function (nextProps, nextState) { - return ( - nextProps.todo !== this.props.todo || - nextProps.editing !== this.props.editing || - nextState.editText !== this.state.editText - ); - }, - - /** - * Safely manipulate the DOM after updating the state when invoking - * `this.props.onEdit()` in the `handleEdit` method above. - * For more info refer to notes at https://facebook.github.io/react/docs/component-api.html#setstate - * and https://facebook.github.io/react/docs/component-specs.html#updating-componentdidupdate - */ - componentDidUpdate: function (prevProps) { - if (!prevProps.editing && this.props.editing) { - var node = React.findDOMNode(this.refs.editField); - node.focus(); - node.setSelectionRange(node.value.length, node.value.length); - } - }, - - render: function () { - return ( -
  • -
    - - -
    - -
  • - ); - } - }); -})(); diff --git a/e2e/todomvc-react/js/todoModel.js b/e2e/todomvc-react/js/todoModel.js deleted file mode 100644 index f6da95b..0000000 --- a/e2e/todomvc-react/js/todoModel.js +++ /dev/null @@ -1,87 +0,0 @@ -/*jshint quotmark:false */ -/*jshint white:false */ -/*jshint trailing:false */ -/*jshint newcap:false */ -var app = app || {}; - -(function () { - 'use strict'; - - var Utils = app.Utils; - // Generic "model" object. You can use whatever - // framework you want. For this application it - // may not even be worth separating this logic - // out, but we do this to demonstrate one way to - // separate out parts of your application. - app.TodoModel = function (key) { - this.key = key; - this.todos = Utils.store(key); - this.onChanges = []; - }; - - app.TodoModel.prototype.subscribe = function (onChange) { - this.onChanges.push(onChange); - }; - - app.TodoModel.prototype.inform = function () { - Utils.store(this.key, this.todos); - this.onChanges.forEach(function (cb) { cb(); }); - }; - - app.TodoModel.prototype.addTodo = function (title) { - this.todos = this.todos.concat({ - id: Utils.uuid(), - title: title, - completed: false - }); - - this.inform(); - }; - - app.TodoModel.prototype.toggleAll = function (checked) { - // Note: it's usually better to use immutable data structures since they're - // easier to reason about and React works very well with them. That's why - // we use map() and filter() everywhere instead of mutating the array or - // todo items themselves. - this.todos = this.todos.map(function (todo) { - return Utils.extend({}, todo, {completed: checked}); - }); - - this.inform(); - }; - - app.TodoModel.prototype.toggle = function (todoToToggle) { - this.todos = this.todos.map(function (todo) { - return todo !== todoToToggle ? - todo : - Utils.extend({}, todo, {completed: !todo.completed}); - }); - - this.inform(); - }; - - app.TodoModel.prototype.destroy = function (todo) { - this.todos = this.todos.filter(function (candidate) { - return candidate !== todo; - }); - - this.inform(); - }; - - app.TodoModel.prototype.save = function (todoToSave, text) { - this.todos = this.todos.map(function (todo) { - return todo !== todoToSave ? todo : Utils.extend({}, todo, {title: text}); - }); - - this.inform(); - }; - - app.TodoModel.prototype.clearCompleted = function () { - this.todos = this.todos.filter(function (todo) { - return !todo.completed; - }); - - this.inform(); - }; - -})(); diff --git a/e2e/todomvc-react/js/utils.js b/e2e/todomvc-react/js/utils.js deleted file mode 100644 index 3944fe1..0000000 --- a/e2e/todomvc-react/js/utils.js +++ /dev/null @@ -1,50 +0,0 @@ -var app = app || {}; - -(function () { - 'use strict'; - - app.Utils = { - uuid: function () { - /*jshint bitwise:false */ - var i, random; - var uuid = ''; - - for (i = 0; i < 32; i++) { - random = Math.random() * 16 | 0; - if (i === 8 || i === 12 || i === 16 || i === 20) { - uuid += '-'; - } - uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)) - .toString(16); - } - - return uuid; - }, - - pluralize: function (count, word) { - return count === 1 ? word : word + 's'; - }, - - store: function (namespace, data) { - if (data) { - return localStorage.setItem(namespace, JSON.stringify(data)); - } - - var store = localStorage.getItem(namespace); - return (store && JSON.parse(store)) || []; - }, - - extend: function () { - var newObj = {}; - for (var i = 0; i < arguments.length; i++) { - var obj = arguments[i]; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - newObj[key] = obj[key]; - } - } - } - return newObj; - } - }; -})(); diff --git a/e2e/todomvc-react/license.md b/e2e/todomvc-react/license.md deleted file mode 100644 index fbfa2e3..0000000 --- a/e2e/todomvc-react/license.md +++ /dev/null @@ -1,20 +0,0 @@ -Everything in this repo is MIT License unless otherwise specified. - -Copyright (c) Addy Osmani, Sindre Sorhus, Pascal Hartig, Stephen Sawchuk. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/e2e/todomvc-react/package.json b/e2e/todomvc-react/package.json deleted file mode 100644 index 3f8a814..0000000 --- a/e2e/todomvc-react/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "private": true, - "dependencies": { - "classnames": "^2.1.5", - "director": "^1.2.0", - "react": "^0.13.3", - "todomvc-app-css": "^2.0.0", - "todomvc-common": "^1.0.1" - } -} diff --git a/e2e/todomvc-react/readme.md b/e2e/todomvc-react/readme.md deleted file mode 100644 index 4d5b6c8..0000000 --- a/e2e/todomvc-react/readme.md +++ /dev/null @@ -1,37 +0,0 @@ -# React TodoMVC Example - -> React is a JavaScript library for creating user interfaces. Its core principles are declarative code, efficiency, and flexibility. Simply specify what your component looks like and React will keep it up-to-date when the underlying data changes. - -> _[React - facebook.github.io/react](http://facebook.github.io/react)_ - - -## Learning React - -The [React getting started documentation](http://facebook.github.io/react/docs/getting-started.html) is a great way to get started. - -Here are some links you may find helpful: - -* [Documentation](http://facebook.github.io/react/docs/getting-started.html) -* [API Reference](http://facebook.github.io/react/docs/reference.html) -* [Blog](http://facebook.github.io/react/blog/) -* [React on GitHub](https://github.com/facebook/react) -* [Support](http://facebook.github.io/react/support.html) - -Articles and guides from the community: - -* [How is Facebook's React JavaScript library](http://www.quora.com/React-JS-Library/How-is-Facebooks-React-JavaScript-library) -* [React: Under the hood](http://www.quora.com/Pete-Hunt/Posts/React-Under-the-Hood) - -Get help from other React users: - -* [React on StackOverflow](http://stackoverflow.com/questions/tagged/reactjs) -* [Discussion Forum](https://discuss.reactjs.org/) - -_If you have other helpful links to share, or find any of the links above no longer work, please [let us know](https://github.com/tastejs/todomvc/issues)._ - - -## Running - -The app is built with [JSX](http://facebook.github.io/react/docs/jsx-in-depth.html) and compiled at runtime for a lighter and more fun code reading experience. As stated in the link, JSX is not mandatory. - -To run the app, spin up an HTTP server (e.g. `python -m SimpleHTTPServer`) and visit http://localhost/.../myexample/. diff --git a/package.json b/package.json index cb4ac6b..fcad12a 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "e2e": "cross-env JEST_PUPPETEER_CONFIG=e2e/jest-puppeteer.config.js jest /e2e -c e2e/jest.e2e.config.js", "build-and-e2e": "npm run build && npm run e2e", "build-and-test": "npm run build && npm run test", - "postinstall": "node tests/setup.js", + "postinstall": "node e2e/setup.js", "lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts'", "precommit": "lint-staged" },