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 from 'react'; | |
class Popup extends React.Component { | |
render() { | |
return ( | |
<div className={'popup' + (this.props.visible ? ' popup_visible' : '')}> | |
<div className="popup__overlay"></div> | |
<div className="popup__content">{this.props.children}</div> | |
</div> | |
); |
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 DataWatcher from 'components/@data-watcher'; | |
const sortTypes = [ 'asc', 'desc' ]; | |
@DataWatcher | |
class ProductsList extends Component { | |
static displayName = 'ProductsList'; | |
static data = (props, state) => ({ | |
// in data dependency besides cursor path |
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 { Component } from 'react'; | |
// Flux action creators for products | |
import ProductsActions from 'actions/products'; | |
// global state | |
import state from 'state'; | |
// main wrapper component | |
class App extends Component { |
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 { Component } from 'react'; | |
import DataWatcher from 'components/@data-watcher'; | |
// DataWatcher decorator watches data paths described below | |
// and updates local state whenever global state changes something in these paths | |
@DataWatcher | |
class Product extends Component { | |
static displayName = 'Product'; | |
// data paths can be static or they can contain props and states |
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
function example(){ | |
class Actions { | |
@Observable | |
static processSomething | |
} | |
class Store { | |
constructor(name){ | |
this.name = name; |
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
$lh: 1.4em; | |
body { | |
font-size: 1em; | |
line-height: $lh; | |
} | |
h1 { | |
background: #333; | |
margin: 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
let mergeSort = (arr) => { | |
if (arr.length < 2) return arr; | |
let middle = parseInt(arr.length / 2), | |
left = arr.slice(0, middle), | |
right = arr.slice(middle); | |
return merge(mergeSort(left), mergeSort(right)); | |
} |
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
var selectionSort = function (a) { | |
for (let i = -1; ++i < a.length;) { | |
for (let m = j = i; ++j < a.length;) { | |
if (a[m] > a[j]) m = j; | |
} | |
a[m], a[i] = a[i], a[m]; | |
} | |
return 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 insertionSort = (arr) => { | |
for (let i = 0; i < a.length; i++) { | |
let toCmp = arr[i]; | |
for (let j = i; j > 0 && toCmp < a[j - 1]; j--) | |
arr[j] = a[j - 1]; | |
arr[j] = toCmp; | |
} | |
return arr; | |
} |
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 compare = (n1, n2) => n1 - n2; | |
let bubbleSort = (arr, cmp = compare) => { | |
for (let i = 0; i < arr.length; i++) { | |
for (var j = i; j > 0; j--) { | |
if (cmp(arr[j], arr[j - 1]) < 0) { | |
arr[j], arr[j - 1] = arr[j - 1], arr[j]; | |
} | |
} | |
} |