Skip to content

Instantly share code, notes, and snippets.

import chalk from 'chalk';
import path from 'path';
import errorCallSites from 'error-callsites';
import {SourceMapConsumer} from 'source-map';
import {retrieveSourceMap} from 'source-map-support/source-map-support';
const sourceMapCache = {};
const fileContentsCache = {};
export function supportRelativeURL(file, url) {
export const colors = {
blue: '#0080ff',
green: '#005a00',
};
export const sizes = {
small: 12,
medium: 16,
large: 24,
};
.buttonBlue {
background-color: rgb(0, 120, 255);
color: rgb(255, 255, 255);
}
.buttonDarkGreen {
background-color: rgb(0, 90, 0);
color: rgb(255, 255, 255);
}
import compact from 'lodash/fp/compact';
export const anchorColor = (color, hover = color, visited = color) => ({
'&': {color},
'&:hover, &:visited:hover': {color: hover},
'&:visited': {color: visited},
});
export const mediaQuery = (rules) => {
let _rules = compact(rules);
import sortBy from 'lodash/fp/sortBy';
import tinycolor from 'tinycolor2';
sortBy((color) => {
const {s: saturation, l: lightness} = tinycolor(color).toHsl();
const darkness = (1 - lightness);
const intensity = darkness * darkness * saturation * saturation;
return lightness + intensity * 20;
}, colors);
// @flow
/* eslint-env browser */
/* eslint-disable complexity */
// =============================================================================
// Import modules
// =============================================================================
import React, {PureComponent} from 'react';
import {findDOMNode} from 'react-dom';
import classnames from 'classnames';
declare module 're-reselect' {
declare type Selector<S, P, R> = {
(S, P, ...rest: any[]): R;
};
declare type Resolver<S, P, K: number | string> = {
(state: S, P, ...rest: any[]): K;
};
declare type CachedSelectorCreator = {
// @flow
type Result<T> = {
url: string;
status: number;
body: T;
};
type Handlers<T = mixed> = [
(Response) => Promise<Result<T>>,
const patch = (target, func) => {
const original = target[func];
target[func] = function () {
return Promise.reolve(original.apply(this, arguments));
};
}
const targets = [
[window, 'fetch'],
@10xjs
10xjs / measureScrollbars.js
Created March 10, 2018 07:04
🔥🔥🔥
const measureScrollbars = (): {width: number, height: number} => {
const container = document.createElement('div');
container.style.width = '100px';
container.style.height = '100px';
container.style.overflow = 'scroll';
const liner = document.createElement('div');
liner.style.width = '200px';
liner.style.height = '200px';