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
const { writeFileSync } = require('fs'); | |
const prettyFormat = require('pretty-format'); | |
const reactTestPlugin = require('pretty-format/plugins/ReactTestComponent'); | |
const reactElementPlugin = require('pretty-format/plugins/ReactElement'); | |
let globalForceUpdate = false; | |
if (process.argv.includes('--snapshots-update')) { | |
globalForceUpdate = true; | |
} |
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
/** @jsx h */ | |
// refs | |
// https://medium.com/@deathmood/how-to-write-your-own-virtual-dom-ee74acc13060 | |
// https://medium.com/@deathmood/write-your-virtual-dom-2-props-events-a957608f5c76 | |
// test: https://jsfiddle.net/Luca_Colonnello/Lzjy5a67/1/ | |
// comparison: | |
// current - https://jsfiddle.net/Luca_Colonnello/5xebu97u/3/ | |
// vidom - https://jsfiddle.net/Luca_Colonnello/dp9cwn37/2/ |
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
const componentMap = { | |
TemplateX: ({ children }) => (<div>{children}</div>), | |
Header: ({ text }) => (<h1>{text}</h1>), | |
HeroBanner: ({ imgUrl, text }) => ( | |
<section style={{ backgroundImage: `url(${imageUrl}) center center` }}> | |
<h2>{text}</h2> | |
</section> | |
), | |
Markdown: ({ content }) => (<ReactMarkdown content={content} />), | |
Carousel: ({ children }) => (<ReactSlick>{children}</ReactSlick>) |
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 { compose } from 'redux'; | |
import { connect } from 'react-redux'; | |
// supposed to receive a class and return a new function (curryed) that | |
// if called add a render function to the received class, | |
// rendering the received component passing down all the props | |
import { withRender } from './utils'; | |
// container class with event handler and action creator dispatch |
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 { bindActionCreator } from 'redux'; | |
export default function bindNestedActionCreators(actions, dispatch) { | |
if (typeof actions !== 'function' && (typeof actions !== 'object' || actions === null)) return false; | |
let dispatchedActions; | |
if (typeof actions === 'object') { | |
dispatchedActions = {}; |
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'; | |
import { Component } from 'react'; | |
let Sort = Sortable => class extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
items: [] | |
} |
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'; | |
import { Component } from 'react'; | |
let Filter = Filterable => class extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
items: props.items | |
}; |
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 i18next from 'i18next' | |
const resources = require("i18next-resource-store-loader!../assets/i18n/index.js"); | |
i18next | |
.init({ | |
lng: 'en', // set dynamically on build | |
fallbackLng: 'en', | |
resources: resources, | |
debug: true, |
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
// Strip margin (Leading whitespaces) | |
function pipeFactory( separator = ' ' ){ | |
return (s, ...args) => { | |
return s | |
.map(( v, i ) => v + ( args[i] || '') ) | |
.join('') | |
.replace(/(\r\n|\r|\n)([\s]+)?\|/g, separator) | |
; | |
}; |
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
Lib purpose |