Skip to content

Instantly share code, notes, and snippets.

View codecorsair's full-sized avatar

JB <codecorsair> codecorsair

  • Dallas, TX
View GitHub Profile
@codecorsair
codecorsair / sharedState.ts
Created January 6, 2020 19:38
Simple React shared state using hooks.
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import React, { useState, useEffect } from 'react';
interface StateDef<TState> {
key: string;
@codecorsair
codecorsair / request.ts
Last active April 23, 2024 17:08
Simple TypeScript XMLHttpRequest
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
export interface RequestOptions {
ignoreCache?: boolean;
headers?: {[key: string]:string};
// 0 (or negative) to wait forever
timeout?: number;
@codecorsair
codecorsair / ReactAphroditeTooltip.tsx
Last active February 17, 2017 21:24
A simple tooltip that follows the mouse on hover over an element using Aphrodite for styling.
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* @Author: JB ([email protected])
* @Date: 2017-01-24 11:47:41
* @Last Modified by: JB ([email protected])
* @Last Modified time: 2017-02-17 16:24:32
*/
@codecorsair
codecorsair / ConfirmDialog.tsx
Last active February 1, 2017 23:12
React TypeScript confirm dialog component.
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* @Author: JB ([email protected])
* @Date: 2017-02-01 14:43:06
* @Last Modified by: JB ([email protected])
* @Last Modified time: 2017-02-01 17:49:37
*/
@codecorsair
codecorsair / ReactTooltip.tsx
Created January 24, 2017 18:01
React Tooltip written in TypeScript!
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* @Author: JB ([email protected])
* @Date: 2017-01-24 11:47:41
* @Last Modified by: JB ([email protected])
* @Last Modified time: 2017-01-24 12:58:32
*/
@codecorsair
codecorsair / slider.tsx
Last active January 4, 2017 21:02
React fading slider using react-motion in Typescript
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* USAGE EXAMPLE
*
* <Slider>
* {items.map((item: Item, index: number) => {
* return (
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* @Author: JB ([email protected])
* @Date: 2016-08-29 17:31:15
* @Last Modified by: JB ([email protected])
* @Last Modified time: 2016-09-21 18:47:36
*/