This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let newStudent = React.addons.update(student, {grades:{$push: ['A']}}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let newStudent = update(student, {grades:{$set: ['A','A','B']}}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let newTicket = update(originalTicket, { | |
arrival: { | |
airport: {$set: 'MCO'} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calculates the Rank of a 5 card Poker hand using bit manipulations. | |
// Adapted from the original CPOL-Licensed code by subskybox | |
// In-depth article explaining how the rank function works available here: | |
// http://www.codeproject.com/Articles/569271/A-Poker-hand-analyzer-in-JavaScript-using-bit-math | |
rankPokerHand(hand) { | |
if(hand.length < 5) return; | |
let v, i, o, s = 1 << hand[0].rank | 1 << hand[1].rank | 1 << hand[2].rank | 1 << hand[3].rank | 1 << hand[4].rank; | |
for (i = 0, v = o = 0; i < 5; i++) { | |
o = Math.pow(2, hand[i].rank * 4); | |
v += o * ((v / o & 15) + 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Card basic structure and positioning (Including front and back) */ | |
/* Slightly modified version from the original: http://selfthinker.github.io/CSS-Playing-Cards/ (CC BY-SA) */ | |
.card-group { | |
transform-style: preserve-3d; | |
transform-origin: 3em 4.5em; /* half of card size */ | |
} | |
.card { | |
width: 6em; | |
height: 9em; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import {render} from 'react-dom'; | |
class SearchBox extends Component { | |
render(){ | |
return ( | |
<input type="search" | |
value={this.props.value} | |
onChange={this.props.onSearch.bind(this)}/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import {render} from 'react-dom' | |
import Toggable from './Toggable' | |
class App extends Component { | |
constructor() { | |
super() | |
this.state = { | |
amountOfItems: 0, | |
totalPrice: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import {render} from 'react-dom' | |
import Toggable from './Toggable' | |
class App extends Component { | |
constructor() { | |
super() | |
this.state = { | |
amountOfItems: 0, | |
totalPrice: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
class Toggable extends Component { | |
onBuyClick(){ | |
this.props.onBuy(this.props.price) | |
} | |
onHeaderClick(){ | |
this.props.onToggle(this.props.id) | |
} |