Skip to content

Instantly share code, notes, and snippets.

View logandeancall's full-sized avatar

Logan Call logandeancall

View GitHub Profile
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
open Belt;
[@bs.deriving abstract]
type queryConfig('data, 'key, 'fnParamsFilter) = {
[@bs.optional]
retry: int,
[@bs.optional]
retryDelay: int,
[@bs.optional]
initialData: unit => 'data,
@logandeancall
logandeancall / 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) => {
/**
* Dependencies:
* - Utils
* - bs-css
* - react-spring (and bindings: bs-react-spring)
* - react-use-memo (and bindings: custom)
* - Close Icon
* - Loader/Spinner
*/
open Utils;
// 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),
[@bs.val] [@bs.return nullable] [@bs.scope "document"]
external getElementById: string => option(Dom.element) = "getElementById";
[@bs.val]
external appendChild: Dom.element => Dom.element = "document.body.appendChild";
[@bs.val]
external removeChild: Dom.element => Dom.element = "document.body.removeChild";
[@bs.val] [@bs.scope "document"]
open Belt;
/**
* Currently only setup for use with Bold's Recurring Orders
* SETUP:
* ALL: SET VARIABLES IN LIQUID (within <script>)
* window.boldGroupId = "{{product.variants[0].metafields.bold_rp.rp_group_id}}"
* BUNDLES: SET VARIABLES IN LIQUID (within <script>)
{% assign is_bundle = false %}
{% if product.metafields.sms.bundle_products != blank %}
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,
[@bs.module "react"]
external useMemo8:
([@bs.uncurry] (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h)) => 'any =
"useMemo";
[@bs.module "react"]
external useCallback4:
([@bs.uncurry] ('input => 'output), ('a, 'b, 'c, 'd)) =>
React.callback('input, 'output) =
"useCallback";