Skip to content

Instantly share code, notes, and snippets.

View vincentriemer's full-sized avatar

Vincent Riemer vincentriemer

View GitHub Profile

Keybase proof

I hereby claim:

  • I am vincentriemer on github.
  • I am vincentriemer (https://keybase.io/vincentriemer) on keybase.
  • I have a public key ASBbyFx0Y416Yh_pdSHCOTmkEOVLG0rnocD-kCKgd7KKjQo

To claim this, I am signing this object:

(() => {
window.history.pushState("BackHandler", null, null);
window.onpopstate = () => {
if(document.dispatchEvent(new Event("hardwareBackPress")) {
window.history.back();
} else {
window.history.pushState("BackHandler", null, null);
}
@vincentriemer
vincentriemer / font-native.js
Created May 20, 2018 14:16
Example React Native DOM native module which provides the ability to load fonts from the worker thread
/**
* This is the "native" module that runs on the main thread
* To add this to the bridge the exported class gets added to the `nativeModules` array in the `bootstrap.js` file.
*
* @flow
*/
import {
RCT_EXPORT_METHOD,
RCT_EXPORT_MODULE,
@vincentriemer
vincentriemer / SketchSystems.spec
Last active September 2, 2018 19:57
React Wormhole Registry Entry*
React Wormhole Registry Entry*
Unmounted*
Empty*
container registered -> Has Container
Has Container
target registered -> Mounted
@vincentriemer
vincentriemer / Gateway.js
Created October 29, 2018 17:44
Hooks implementation of `react-gateway`
import React, { useContext, useLayoutEffect, useEffect, useRef } from "react";
import GatewayRegistry from "./GatewayRegistry";
import { GatewayContext } from "./GatewayProvider";
const Gateway = props => {
const gatewayRegistry = useContext(GatewayContext);
// keeping track of previous `into` prop
const prevIntoRef = useRef();
useLayoutEffect(() => {
@vincentriemer
vincentriemer / usage.js
Created November 4, 2018 01:22
A first attempt at an accessible "press handler" React hook
import React from "react";
import { usePress } from "./usePress";
export const MyJSButton = () => {
const [pressRef, isPressed, accessibilityProps] = usePress(
"button", // role [button | link]
() => console.log("Pressed!"), // callback
true // should preventDefault
);
import ReactDOM from "react-dom";
export default ReactDOM.unstable_batchedUpdates;
@vincentriemer
vincentriemer / react-virtual-scroller.tsx
Created December 3, 2018 15:09
React wrapper around the <virtual-scroller /> web component
// Global import to register <virtual-scroller /> custom element
// This should be replaced with a layered import once it is introduced into browsers
import "virtual-scroller/src/virtual-scroller";
import React, {
useRef,
useEffect,
forwardRef,
useImperativeMethods
} from "react";
@vincentriemer
vincentriemer / plugin.js
Last active December 7, 2018 01:52
rollup-plugin-netlify-modulepreload
import * as path from "path";
import * as fs from "fs";
export default function netlifyModulePreload(config) {
return {
name: "netlify-modulepreload",
generateBundle(outputOptions, bundle) {
const { publicRoot, entries } = config;
const { dir, format } = outputOptions;
@vincentriemer
vincentriemer / iphone-frame-overlay-app.js
Created January 20, 2019 23:52
Video iPhone Frame Overlay Web App Prototype
import React, { Component, useCallback, useState, useRef } from "react";
import "./App.css";
const imgUrl = require("./assets/iPhone-XS-Portrait-Space-Gray.png");
const fullSize = {
width: 1325,
height: 2616
};