Skip to content

Commit

Permalink
Updating rackt-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabriskie committed Jul 21, 2015
1 parent a660104 commit 4d3d48f
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 39 deletions.
4 changes: 2 additions & 2 deletions examples/basic/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import FlipCard from '../../lib/main';

var App = React.createClass({
let App = React.createClass({
getInitialState() {
return {
isFlipped: false
Expand Down Expand Up @@ -54,7 +54,7 @@ var App = React.createClass({
</div>
<div>Back</div>
</FlipCard>

{/*
The `disabled` attribute allows turning off the auto-flip
on hover, or focus. This allows manual control over flipping.
Expand Down
9 changes: 5 additions & 4 deletions lib/components/FlipCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default React.createClass({
onFlip: PropTypes.func,
onKeyDown: PropTypes.func,
children(props, propName, componentName) {
var prop = props[propName];
let prop = props[propName];

if (React.Children.count(prop) !== 2) {
return new Error(
Expand Down Expand Up @@ -52,7 +52,7 @@ export default React.createClass({
setTimeout(() => {
this.setState({
isFlipped: newProps.flipped
})
});
}, 0);
},

Expand All @@ -68,7 +68,7 @@ export default React.createClass({
// If isFlipped has changed need to notify
if (this.state.isFlipped !== nextState.isFlipped) {
this.notifyFlip = true;
}
}
},

componentDidUpdate() {
Expand All @@ -82,6 +82,7 @@ export default React.createClass({
this.focusElement = null;
}
// Direct focus to the back if needed
/* eslint brace-style:0 */
else if (this.focusBack) {
this.refs.back.getDOMNode().focus();
this.focusBack = false;
Expand Down Expand Up @@ -139,7 +140,7 @@ export default React.createClass({
}
},

render() {
render() {
return (
<div
className={cx({
Expand Down
37 changes: 19 additions & 18 deletions lib/components/__tests__/FlipCard-test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
var React = require('react/addons');
var TestUtils = React.addons.TestUtils;
var FlipCard = require('../../main');
var { ok, equal, strictEqual, throws } = require('assert');
let React = require('react/addons');
let TestUtils = React.addons.TestUtils;
let FlipCard = require('../../main');
let { equal, throws } = require('assert');

describe('react-flipcard', function () {
it('should throw an error if less than 2 children are provided', function () {
throws(function () {
/* eslint func-names:0 */
describe('react-flipcard', function() {
it('should throw an error if less than 2 children are provided', function() {
throws(function() {
TestUtils.renderIntoDocument(<FlipCard/>);
}, TypeError);
});

it('should flip vertically', function () {
var card = TestUtils.renderIntoDocument(
it('should flip vertically', function() {
let card = TestUtils.renderIntoDocument(
<FlipCard type="vertical">
<div>foo</div>
<div>bar</div>
Expand All @@ -20,9 +21,9 @@ describe('react-flipcard', function () {
equal(card.getDOMNode().classList.contains('ReactFlipCard--vertical'), true);
equal(card.getDOMNode().classList.contains('ReactFlipCard--horizontal'), false);
});
it('should flip horizontally by default', function () {
var card = TestUtils.renderIntoDocument(

it('should flip horizontally by default', function() {
let card = TestUtils.renderIntoDocument(
<FlipCard>
<div>foo</div>
<div>bar</div>
Expand All @@ -32,26 +33,26 @@ describe('react-flipcard', function () {
equal(card.getDOMNode().classList.contains('ReactFlipCard--horizontal'), true);
});

it('should default to enabled', function () {
var card = TestUtils.renderIntoDocument(
it('should default to enabled', function() {
let card = TestUtils.renderIntoDocument(
<FlipCard>
<div>foo</div>
<div>bar</div>
</FlipCard>
);
equal(card.getDOMNode().classList.contains('ReactFlipCard--enabled'), true);
});
it('should allow disabling', function () {
var card = TestUtils.renderIntoDocument(

it('should allow disabling', function() {
let card = TestUtils.renderIntoDocument(
<FlipCard disabled={true}>
<div>foo</div>
<div>bar</div>
</FlipCard>
);
equal(card.getDOMNode().classList.contains('ReactFlipCard--enabled'), false);
});

// TODO: Why doesn't this work?
// it('should call onFlip', function (done) {
// var called = false;
Expand Down
8 changes: 5 additions & 3 deletions lib/helpers/classSet.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module.exports = function classSet(classNames) {
if (typeof classNames == 'object') {
return Object.keys(classNames).filter(function(className) {
let result = null;
if (typeof classNames === 'object') {
result = Object.keys(classNames).filter((className) => {
return classNames[className];
}).join(' ');
} else {
return Array.prototype.join.call(arguments, ' ');
result = Array.prototype.join.call(arguments, ' ');
}
return result;
};
1 change: 1 addition & 0 deletions lib/helpers/contains.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Checks to see if a parent element contains a child element
/* eslint no-param-reassign:0, no-cond-assign:0 */
module.exports = function contains(parent, child) {
do {
if (parent === child) {
Expand Down
16 changes: 8 additions & 8 deletions lib/helpers/injectStyle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var CSS = `
const CSS = `
.ReactFlipCard {
-webkit-perspective: 1000;
-moz-perspective: 1000;
Expand All @@ -7,8 +7,8 @@ var CSS = `
-ms-transform: perspective(1000px);
-moz-transform: perspective(1000px);
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
display: inline-block;
}
Expand All @@ -30,7 +30,7 @@ var CSS = `
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
}
/* END: Accommodating for IE */
.ReactFlipCard__Flipper {
Expand Down Expand Up @@ -138,13 +138,13 @@ var CSS = `
/* END: Accommodating for IE */
`;

export default function () {
var style = document.getElementById('react-flipcard-style');
export default function() {
let style = document.getElementById('react-flipcard-style');
if (!style) {
style = document.createElement('style');
style.setAttribute('id', 'react-flipcard-style');
var head = document.querySelector('head');
let head = document.querySelector('head');
head.insertBefore(style, head.firstChild);
}
style.innerHTML = CSS;
};
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "React flip card component",
"main": "lib/main.js",
"scripts": {
"test": "rackt test --ci --browsers Firefox",
"start": "rackt dev"
"test": "rackt test --single-run --browsers Firefox",
"start": "rackt server"
},
"repository": {
"type": "git",
Expand All @@ -21,10 +21,10 @@
},
"homepage": "https://github.com/mzabriskie/react-flipcard",
"devDependencies": {
"rackt-cli": "^0.3.2",
"rackt-cli": "^0.4.0",
"react": "^0.13.3"
},
"peerDependencies": {
"react": "^0.13.3"
}
}
}

0 comments on commit 4d3d48f

Please sign in to comment.