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, { useEffect, useRef } from "react"; | |
interface ConfettiParticle { | |
x: number; | |
y: number; | |
r: number; | |
d: number; | |
color: string; | |
tilt: number; | |
tiltAngleIncremental: number; |
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 generateSlug(str: string): string { | |
return str | |
.trim() // Remove leading/trailing whitespace | |
.toLowerCase() // Convert to lowercase | |
.replace(/[^a-zA-Z0-9\s]/g, "") // Remove non-alphanumeric characters | |
.replace(/\s+/g, "-") // Replace spaces with hyphens | |
.replace(/-+/g, "-") // Replace consecutive hyphens with a single hyphen | |
} |
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 { useState, useEffect } from "react" | |
interface Coordinates { | |
latitude: number | |
longitude: number | |
} | |
interface GeoLocationError extends Error { | |
name: string | |
} |
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
{ | |
"data": [ | |
{ | |
"name": "Ship Ahoy Tavern", | |
"address": "2889 SE Gladstone St, Portland, OR 97202, United States", | |
"phoneNumber": "(503) 239-0868", | |
"type": "Bar", | |
"latitude": "45.4935217", | |
"longitude": "-122.6357506", | |
"placeId": "ChIJqbtFh4EKlVQRTW9LYiGvVfA" |
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, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
import { FormGroup, Label, FormFeedback } from 'reactstrap'; | |
import { RequiredMark } from './'; | |
import { constants, log } from '@src/lib'; | |
class FileInputField extends Component { | |
constructor(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 ReactDOM from "react-dom"; | |
const PortalContext = React.createContext( | |
typeof document !== "undefined" ? document.body : null | |
); | |
export function Portal({ children }) { | |
// if it's a nested portal, context is the parent portal | |
// otherwise it's document.body |
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
// lightweight version of jQuery to select DOM elements | |
let $ = document.querySelector.bind(document) | |
let $$ = document.querySelectorAll.bind(document) | |
// render products into the products container - we have to call this whenever the state changes | |
$('.products').innerHTML = products.map(getProductHTML).join(' ') |
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 LoadLazyImagesAndPrint = () => { | |
// Loop through every lazy loaded element | |
const imageDivs = [...document.querySelectorAll('.image')] | |
.map(imageDiv => { | |
let image = imageDiv.querySelector('img'); | |
// Determine if the image is unloaded | |
if (!image.src) { | |
// Load the image element string from the accompanying <noscript> element | |
const unloadedImageString = imageDiv.querySelector('noscript').innerText; | |
// Replace the unloaded image |
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
/* | |
Margin & Padding spacers | |
usage: mt-4 -> margin-top: 4rem; | |
*/ | |
$spacer: 1rem; | |
$sizes: 0, 1, 2, 3, 4, 5, 6; | |
$directions: top, left, bottom, right; | |
@each $direction in $directions{ | |
@each $size in $sizes{ |
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 'isomorphic-fetch'; | |
import gql from 'graphql-tag'; | |
import { ApolloClient } from 'apollo-client'; | |
import { InMemoryCache } from 'apollo-cache-inmemory'; | |
import { HttpLink } from 'apollo-link-http'; | |
import url from 'url'; | |
import { normalizeRequest } from './sms-middleware.util'; | |
import log from '../../../common/log'; | |
/** |
NewerOlder