Skip to content

Instantly share code, notes, and snippets.

const initialState = {
// The current state of the battle
currentState: 'SELECT_MOVE',
// The active Pokemon on each side
activePokemon: [null, null],
// The remaining health of each Pokemon
health: [0, 0],
// The moves available to each Pokemon
moves: [[], []],
// The current move being used by each Pokemon
@painedpineapple
painedpineapple / res_of_re.js
Last active January 11, 2021 23:14
Convert all Reason files in a project to ReScript
/**
* 1. Make sure "glob" is installed globally
* 2. Update src path if necessary
* 3. Run `node res_of_re.js`
*/
let glob = require("glob");
let { exec } = require("child_process");
glob("src/**/*.re", (err, files) => {
// Component: https://github.com/airbnb/react-outside-click-handler
[@bs.module "react-outside-click-handler"] [@react.component]
external make:
(
~onOutsideClick: unit => unit,
~children: React.element,
~disabled: bool=?,
~useCapture: bool=?,
~display: [@bs.string] [
open Utils;
type align = [ | `right | `left];
module Style = {
open Css;
let root =
style([
zIndex(50),
module CountDown = {
/** matches css animation play states */
type playState = [ | `running | `paused];
type value = {
time: int,
play: unit => unit,
pause: unit => unit,
restart: unit => unit,
playState,
/**
* Dependencies:
* - Utils
* - bs-css
* - react-spring (and bindings: bs-react-spring)
* - react-use-memo (and bindings: custom)
* - Close Icon
* - Loader/Spinner
*/
open Utils;
type resizeObserverPolyfill;
[@bs.module "@juggle/resize-observer"]
external polyfill: resizeObserverPolyfill = "ResizeObserver";
type debounce = {
scroll: int,
resize: float,
};
/**
* This is deprecated. I recommend using https://gist.github.com/thislogancall/8d13eac0cc9a9435921817be071650a4
*/
open Utils;
[%raw {|
require("react-notifications-component/dist/theme.css")
|}];
open Belt;
let str = React.string;
let rem_of_px = pixel => (pixel->float_of_int /. 16.)->Css.rem;
let createMarkup = str => <span dangerouslySetInnerHTML={"__html": str} />;
let unknownErrorMessage = "An unknown error has occurred.";
type timerValue = {
seconds: int,
minutes: int,
hours: int,
days: int,
start: unit => unit,
pause: unit => unit,
restart: unit => unit,
};