This file contains 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 { useCollapsible } from './use-collapsible'; | |
export function Collapsible({ open, title, className, lazyLoad, onToggle, children, ...props }) { | |
const { isOpen, shouldRender, getTriggerProps, getContentProps } = useCollapsible({ open, onToggle }); | |
const classNames = [className, 'collapsible']; | |
if (isOpen) classNames.push('is-open'); | |
return ( | |
<div {...props} className={classNames.join(' ')}> | |
<header className="collapsible-trigger" {...getTriggerProps()}> |
This file contains 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 stringToHsl( | |
str, | |
{ saturation = 50, lightness = 50, range: [minHue, maxHue] = [0, 360] } = {} | |
) { | |
const hash = str.split('').reduce((hash, char) => char.charCodeAt(0) + ((hash << 5) - hash), 0); | |
return `hsl(${(Math.abs(hash) % (maxHue - minHue)) + minHue}, ${saturation}%, ${lightness}%)`; | |
} |
This file contains 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
export const qsPrimitivesDecoder = (value, defaultDecoder, charset, type) => | |
(type === "key" ? defaultDecoder : convertFromString)(value); | |
function convertFromString(value) { | |
if (typeof value === "undefined" || value === "") { | |
return null; | |
} else if (value === "false" || value === "true") { | |
return value === "true"; | |
} else if (Array.isArray(value)) { | |
return value.map(convertFromString); |
This file contains 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 { serialize, deserialize, serializable, custom } from 'serializr'; | |
import { deepObserve } from 'mobx-utils'; | |
import storage from 'utils/storage'; | |
import _ from 'lodash'; | |
export const deserializable = serializable(custom(() => {}, v => v)); | |
export const fromStorage = (model, defaults = {}) => | |
deserialize(model, _.merge(defaults, storage.get(model.name, {}))); |
This file contains 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 classNames from 'classnames/bind'; | |
import React from 'react'; | |
export default styles => Component => isStateless(Component) | |
? props => transformElement(Component(props), classNames.bind(styles)) | |
: class extends Component { render() { return transformElement(super.render(), classNames.bind(styles)); } }; | |
function transformElement(el, cx) { | |
let className = el && el.props.className; | |
if (className) { |
This file contains 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
// a simple implementation of a css modules decorator which utilizes the | |
// classNames package and automatically overrides the original className | |
import classNames from 'classnames/bind'; | |
import React from 'react'; | |
export default styles => Component => isStateless(Component) | |
? props => transformElement(Component(props), classNames.bind(styles)) | |
: class extends Component { render() { return transformElement(super.render(), classNames.bind(styles)); } }; |
This file contains 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 stateRecord from './state-record'; | |
import { | |
FETCH_SEARCH_RESULTS_LOADING, | |
FETCH_SEARCH_RESULTS_SUCCESS, | |
FETCH_SEARCH_RESULTS_FAILURE, | |
} from './actions'; | |
export default { | |
stateRecord, | |
actionHandlers: { |
This file contains 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
/** | |
* Takes a jQuery collection and wraps each 'groupSize' items with 'wrapHtml' | |
* Example: $('#Example span').wrapInGroups('<div/>', 4); | |
* Will wrap every 4 span's inside #Example with a div | |
* See for yourself: http://jsfiddle.net/M9ZFh/ | |
* Author: iMoses ([email protected]) | |
*/ | |
(function($) { | |
$.fn.wrapInGroups = function(wrapHtml, groupSize) { | |
var selector = this.selector; |