Commit 3a93bc0a authored by Arthur Verschaeve's avatar Arthur Verschaeve

Use `classnames` directly

parent fc92daa5
......@@ -15,6 +15,9 @@ node_modules/react/dist/*
!node_modules/react/dist/react-with-addons.js
!node_modules/react/dist/JSXTransformer.js
node_modules/classnames/*
!node_modules/classnames/index.js
node_modules/todomvc-app-css/*
!node_modules/todomvc-app-css/index.css
......
......@@ -18,6 +18,7 @@
<script src="node_modules/todomvc-common/base.js"></script>
<script src="node_modules/react/dist/react-with-addons.js"></script>
<script src="node_modules/react/dist/JSXTransformer.js"></script>
<script src="node_modules/classnames/index.js"></script>
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="node_modules/underscore/underscore.js"></script>
<script src="node_modules/backbone/backbone.js"></script>
......
......@@ -26,8 +26,6 @@ var app = app || {};
);
}
// React idiom for shortcutting to `classSet` since it'll be used often
var cx = React.addons.classSet;
var nowShowing = this.props.nowShowing;
return (
<footer id="footer">
......@@ -38,7 +36,7 @@ var app = app || {};
<li>
<a
href="#/"
className={cx({selected: nowShowing === app.ALL_TODOS})}>
className={classNames({selected: nowShowing === app.ALL_TODOS})}>
All
</a>
</li>
......@@ -46,7 +44,7 @@ var app = app || {};
<li>
<a
href="#/active"
className={cx({selected: nowShowing === app.ACTIVE_TODOS})}>
className={classNames({selected: nowShowing === app.ACTIVE_TODOS})}>
Active
</a>
</li>
......@@ -54,7 +52,7 @@ var app = app || {};
<li>
<a
href="#/completed"
className={cx({selected: nowShowing === app.COMPLETED_TODOS})}>
className={classNames({selected: nowShowing === app.COMPLETED_TODOS})}>
Completed
</a>
</li>
......
......@@ -58,7 +58,7 @@ var app = app || {};
render: function () {
return (
<li className={React.addons.classSet({
<li className={classNames({
completed: this.props.todo.get('completed'),
editing: this.props.editing
})}>
......
/*!
Copyright (c) 2015 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
(function () {
'use strict';
function classNames () {
var classes = '';
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (!arg) continue;
var argType = typeof arg;
if ('string' === argType || 'number' === argType) {
classes += ' ' + arg;
} else if (Array.isArray(arg)) {
classes += ' ' + classNames.apply(null, arg);
} else if ('object' === argType) {
for (var key in arg) {
if (arg.hasOwnProperty(key) && arg[key]) {
classes += ' ' + key;
}
}
}
}
return classes.substr(1);
}
if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
// AMD. Register as an anonymous module.
define(function () {
return classNames;
});
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = classNames;
} else {
window.classNames = classNames;
}
}());
......@@ -3,6 +3,7 @@
"dependencies": {
"backbone": "^1.1.2",
"backbone.localstorage": "^1.1.7",
"classnames": "^2.1.2",
"jquery": "^2.1.0",
"react": "^0.13.3",
"todomvc-app-css": "^1.0.0",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment