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
/** | |
* Determines if html element is | |
* contained within other html element | |
* | |
* @param {HTMLElement} refNode | |
* @param {HTMLElement} otherNode | |
*/ | |
const isParent = (refNode, otherNode) => { | |
var parent = otherNode.parentNode; | |
do { |
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 React from 'react'; | |
import {useSpring, animated, config} from 'react-spring'; | |
import Slider from './Slider'; | |
const convertPercentageToRotation = percentage => { | |
return percentage * 1.8; | |
} | |
function norm(value, min, max) { | |
return (value - min) / (max - min); |
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 React, {useState, useImperativeHandle, useRef, useEffect, useMemo, useCallback} from 'react'; | |
const AccordionContext = React.createContext(); | |
function AccordionProvider(props) { | |
const accordionItems = new Map(); | |
const registerAccordionItem = (id, item) => { | |
accordionItems.set(id, item); | |
}; |
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 React, {forwardRef, useRef, useImperativeHandle, useState, useCallback, useMemo} from 'react'; | |
const Accordion = (props) => { | |
let items = useRef(new Map()).current; | |
const handleOnToggle = (id) => { | |
items.forEach((value, key) => { | |
if (key != id) { | |
value.close(); | |
} |
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 { storeFactory } from "../test/testUtils"; | |
import { guessWord } from "./actions"; | |
describe("guessWord action dispatcher", () => { | |
const secretWord = "party"; | |
const unsuccessfulGuess = "train"; | |
describe("no guessed words", () => { | |
let store; | |
const initialState = { secretWord }; |
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 { createStore, applyMiddleware } from "redux"; | |
import ReduxThunk from "redux-thunk"; | |
import rootReducer from "./reducers"; | |
export const middlewares = [ReduxThunk]; | |
const createStoreWidthMiddleware = applyMiddleware(...middlewares)(createStore); | |
export default createStoreWidthMiddleware(rootReducer); | |
///////////////////////////////////////////////////////////////////////////////////////////// |
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 fs = require('fs'); | |
const path = require('path'); | |
const crypto = require('crypto'); | |
const findIdsRegex = /id="(.+?)"?/ig; | |
const fileName = process.argv[2]; | |
const fileAbsoluteDirectory = path.dirname(path.resolve(fileName)); | |
let buffer = ''; | |
if (path.extname(fileName) !== '.svg') { |
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
// Its like $('<h1>hello</h1>') in jquery | |
var parseHTML = function(str) { | |
var tmp = document.implementation.createHTMLDocument(); | |
tmp.body.innerHTML = str; | |
return tmp.body.children; | |
}; |
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
// To mock a function | |
// utils has a function called getWinner that takes two strings | |
// as arguments and return one of them as the winner. It | |
// is used internally by thumbWar. Problem here is that the original | |
// function gets clobbered by our mock, so we have to manually | |
// reassign the original back after the test has run. | |
// This is called monkey patching and only works with commonjs modules | |
const utils = require('./utils'); | |
const thumbWar = require('./thumb-war'); |
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
to install eslint run | |
npm install eslint | |
create eslint.rc file with contents | |
{ | |
"parserOptions": { | |
"ecmaVersion": "2018" | |
}, | |
"extends": ["eslint:recommended"], |
NewerOlder