This file contains hidden or 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
/** | |
* setAttributes | |
* Sets multiple html element attributes at once | |
* | |
* @param elm html element that the at attributes will be applied to | |
* @param attrs object with key (attribute name) and value (attribute value) | |
* | |
* e.g. | |
* setAttributes(document.querySelector('.sample'), { | |
* 'title': 'Sample Title', |
This file contains hidden or 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
<?php | |
class LocalValetDriver extends BasicValetDriver | |
{ | |
/** | |
* Mutate the incoming URI. | |
* | |
* @param string $uri | |
* @return string | |
*/ |
This file contains hidden or 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
/** | |
* useScroll React custom hook | |
* Usage: | |
* const { scrollX, scrollY, scrollDirection } = useScroll(); | |
*/ | |
import { useState, useEffect } from "react"; | |
export function useScroll() { | |
const [lastScrollTop, setLastScrollTop] = useState(0); |
This file contains hidden or 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
/** | |
* useWindowDimension React custom hook | |
* Usage: | |
* const { width, height } = useWindowDimension(); | |
*/ | |
import { useState, useEffect } from "react"; | |
export function useWindowDimension() { | |
const [width, setWidth] = useState(window.innerWidth); |
This file contains hidden or 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 } from 'react'; | |
export default function useLocalStorage(key, initialValue) { | |
const [item, setInnerValue] = useState(() => { | |
try { | |
return window.localStorage.getItem(key) | |
? JSON.parse(window.localStorage.getItem(key)) | |
: initialValue; | |
} catch (error) { | |
return initialValue; |
This file contains hidden or 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
/* | |
* Based off of the blog post "A More Modern Scale for Web Typography" | |
* - http://typecast.com/blog/a-more-modern-scale-for-web-typography | |
*/ | |
html { | |
font-size: 16px; | |
} | |
body { |
This file contains hidden or 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
export function debounce (fn, time) { | |
let timeout; | |
return function() { | |
const functionCall = () => fn.apply(this, arguments); | |
clearTimeout(timeout); | |
timeout = setTimeout(functionCall, time); | |
} | |
} |
This file contains hidden or 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
/** | |
* animateCount | |
* | |
* Usage: | |
* animateCount({ | |
* selector: '.your-selector', // the selector for the element to animate | |
* from: 0, // the value to animate from | |
* to: 50, // the value to animate to | |
* duration: 1000 // animation duration in miliseconds, defaults to 1000 | |
* }) |
This file contains hidden or 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
element { | |
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; | |
} |
This file contains hidden or 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
// Add requestAnimationFrame shim | |
// http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
window._animate = (function() { | |
return ( | |
window.requestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
function(callback) { | |
window.setTimeout(callback, 1000 / 60); | |
} |