Skip to content

Instantly share code, notes, and snippets.

View ainalain's full-sized avatar

Elena Sufieva ainalain

View GitHub Profile
@ainalain
ainalain / tsconfig.json
Created February 1, 2019 19:46
Tsconfig.json file for Typescript project. "typeRoots" option helps to avoid compilation error in case of global type declarations collision.
{
"compilerOptions": {
"outDir": "build/dist",
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom", "es2016.array.include", "es2017"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
@ainalain
ainalain / ConnectExample.tsx
Last active April 15, 2018 10:12
An example of typings in connecting component to Redux store
import * as React from 'react';
import { RouteComponentProps, withRouter } from 'react-router';
import { Dispatch, compose } from 'redux';
import { connect } from 'react-redux';
import { WithStyles, withStyles } from 'material-ui/styles';
import Button from 'material-ui/Button';
import { Model } from '../../../Main/Model';
import { Product } from '../../Model/store';
import { ProductActions } from '../../Model/actions/actions';
@ainalain
ainalain / InputAdornment.d.ts
Created April 8, 2018 18:35
An example of Typescript declaration merge: Material-UI InputAdornment interface enhancement
import { InputAdornmentClassKey } from "material-ui/Input/InputAdornment";
import { StandardProps } from "material-ui/index";
declare module "material-ui/Input/InputAdornment" {
export interface InputAdornmentProps extends StandardProps<{}, InputAdornmentClassKey> {
onClick?: () => void;
}
}
@ainalain
ainalain / css tooltip
Last active September 25, 2017 10:39
/*there is scss syntax in this gist */
/* based on this pen: https://codepen.io/mildrenben/pen/rVBrpK */
$white: #fff;
$cubic: cubic-bezier(0.64, 0.09, 0.08, 1);
/* element that needs a hint */
.tooltip--triangle {
position: relative;
@ainalain
ainalain / testSetup.js
Last active February 9, 2021 17:39
Setup environment for testing React components with mocha, sinon, enzyme and jsdom
/* This file helps you to setup an environment
* for testing a React app with Mocha.
* It provides transpiling and some global variables before
* Mocha runs all the tests.
* Usage example in npm script: "test": "mocha --require tools/testSetup.js test/*.test.js"
* The major part of this file I got from Cory House pluralsight-redux-starter repo:
* https://github.com/coryhouse/pluralsight-redux-starter/blob/master/tools/testSetup.js
*/
process.env.NODE_ENV = 'test';