This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (doc, w) { | |
"use strict"; | |
var readyCallbacks = [], | |
docLoadEv = "DOMContentLoaded", | |
ready = (document.readyState === "complete"); | |
function registerForReadyEvent(fn) { | |
if (ready) { //already ready, execute immediately |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* accepts n methods in sequence as arguments and returns a promise that is resolved | |
* once all methods finish. | |
* any argument may be an array of methods instead of a method itself. in this case, the array methods | |
* will be run in parallel | |
* any of the passed in methods may return a promise or any other type | |
* | |
* the results of the previous methods is handed over to the next method | |
* | |
* the last parameter may be an object containing one or both: {context, data} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const addFrameConsciousEvent = (obj, event, handler) => { //adapted from: https://developer.mozilla.org/en-US/docs/Web/Events/resize#Example | |
let isRunning = false; | |
const handlerWrapper = (e)=> { | |
if (!isRunning){ | |
isRunning = true; | |
requestAnimationFrame(()=>{ //throttling so only execute when the browser is ready to re-render | |
isRunning = false; | |
handler(e); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onItemsRendered = (gridData: Object) => { | |
const {useOverscanForLoading} = this.props; //default is true | |
const { | |
visibleRowStartIndex, | |
visibleRowStopIndex, | |
visibleColumnStopIndex, | |
overscanRowStartIndex, | |
overscanRowStopIndex, | |
overscanColumnStopIndex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext, useState, } from "react"; | |
import { navigate } from "gatsby"; | |
import styled from "styled-components"; | |
import { Box, Button } from "grommet"; | |
import ReCaptcha from "react-google-recaptcha"; | |
import { NotificationContext } from "../Notifications/NotificationProvider"; | |
const isDev = process.env.NODE_ENV === "development"; | |
const onRegisterSuccess = (navUrl) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useRef, useLayoutEffect } from "react"; | |
import { StyleSheetManager } from "styled-components"; | |
import PreviewContext from "./PreviewContext"; | |
const WithPreviewContext = ({ children }) => | |
<PreviewContext.Provider value={true}> | |
<main> | |
{children} | |
</main> | |
</PreviewContext.Provider>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import NetlifyCmsWidgetMarkdown from "netlify-cms-widget-markdown"; | |
const name = "rtlmarkdown"; | |
const PreviewComponent = NetlifyCmsWidgetMarkdown.previewComponent; | |
const OrgControlComponent = NetlifyCmsWidgetMarkdown.controlComponent; | |
const ControlComponent = React.forwardRef((props, ref) => { | |
return <div dir="rtl"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {getResponsiveAttributes} from "../getResponsiveAttributes"; | |
const Image = ({publidId}) => { | |
const transformation = [{ | |
quality: "auto", | |
fetchFormat: "auto", | |
dpr: 2, | |
},]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { isFunction } from "lodash"; | |
import { mount } from "enzyme"; | |
export default (hook, props) => { | |
let wrapper, hookResult, hookParams, error; | |
if (isFunction(props)) { | |
hookParams = props; | |
props = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import Uploady from "@rpldy/uploady"; | |
import UploadButton from "@rpldy/upload-button"; | |
const MyApp = () => ( | |
<Uploady destination={{url: "https://my-server.com/upload"}}> | |
<UploadButton/> | |
</Uploady> | |
); |