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 * as R from 'ramda'; | |
const resolveModuleFromLocation = R.curry((location, next) => { | |
try { | |
return require.resolve(location) && require(location); | |
} catch (err) { | |
if (next && err && err.code === 'MODULE_NOT_FOUND') { | |
return next(); | |
} | |
} |
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
const accessCors = res => { | |
// Website you wish to allow to connect | |
res.setHeader('Access-Control-Allow-Origin', '*'); | |
// Request methods you wish to allow | |
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); | |
// Request headers you wish to allow | |
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); |
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 * as React from 'react'; | |
import {hot} from "react-hot-loader"; | |
const slotChildren = (UnwrappedComponent, options = {}) => { | |
// enable hot reloading in each react tree | |
const Component = hot(options.module || module)(UnwrappedComponent); | |
const slotName = `slot-${options.name}`; | |
class SlotWrapper extends React.Component { | |
constructor(props) { |
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 * as React from 'react'; | |
import toWebComponent from './WebComponent'; | |
const styles = { | |
greeting: { | |
color: 'green', | |
}, | |
user: { | |
color: 'blue', | |
} |
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
* { | |
border: solid lightgray 1px !important; | |
} | |
/* blocks use solid border */ | |
section, aside, nav { | |
border: solid green 1px !important; | |
} | |
div { |
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
'.source.js.jsx': | |
'ReactJS Component single unit test': | |
'prefix': 'comput' | |
'body': """ | |
it('$1', () => { | |
const {output} = setup(); | |
const expected = $2; | |
const actual = $3; | |
expect(actual).toEqual(expected); | |
}); |
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
/** | |
* @module {Function} components/Break | |
* @flow | |
*/ | |
import * as React from 'react'; | |
import {css} from 'emotion'; | |
const style = css` | |
margin: 0; | |
padding: 0; |
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
/** | |
* Create a uniform appearance for date and time displays | |
* @module {Function} components/DateDisplay | |
* @flow | |
*/ | |
import * as React from 'react'; | |
import typeOf from 'ramda/src/type'; | |
const createDateDisplay = (getDisplay: (Date) => string, name: string) => { |
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
// gets the prototype function of an object so it can be called against a value | |
const protoOf = curry((Obj, method, value, ...args) => | |
Obj.prototype[method].call(value, ...args)); |
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
/** | |
* Converts a Date or TimeStamp into a human readable format | |
* @module {Function} utils/displayDate | |
* @flow | |
*/ | |
import memoizeWith from 'ramda/src/memoizeWith'; | |
import identity from 'ramda/src/identity'; | |
import pipe from 'ramda/src/pipe'; | |
import ifElse from 'ramda/src/ifElse'; | |
import useWith from 'ramda/src/useWith'; |
NewerOlder