Skip to content

Instantly share code, notes, and snippets.

View adamduncan's full-sized avatar
👋

Adam Duncan adamduncan

👋
View GitHub Profile
@adamduncan
adamduncan / useRouterStatus.js
Created January 16, 2021 18:58
Next.js Router status hook
import { useState, useEffect } from 'react';
import Router from 'next/router';
export default function useRouterStatus() {
const [isLoading, setIsLoading] = useState(false);
const [isError, setIsError] = useState(false);
const [error, setError] = useState();
useEffect(() => {
const start = () => {
<script>
/*! loadJS: load a JS file asynchronously. [c]2014 @scottjehl, Filament Group, Inc. (Based on http://goo.gl/REQGQ by Paul Irish). Licensed MIT */
!function(e){var t=function(t,o,n){"use strict";var r,a=e.document.getElementsByTagName("script")[0],c=e.document.createElement("script");return"boolean"==typeof o&&(r=n,n=o,o=r),c.src=t,c.async=!n,a.parentNode.insertBefore(c,a),o&&"function"==typeof o&&(c.onload=o),c};"undefined"!=typeof module?module.exports=t:e.loadJS=t}("undefined"!=typeof global?global:this);
// Polyfill custom properties for <= IE11
if (!window.CSS || !window.CSS.supports || !window.CSS.supports('--a', 0)) {
loadJS('https://unpkg.com/css-vars-ponyfill@2/dist/css-vars-ponyfill.min.js', function() {
cssVars();
})
}
@adamduncan
adamduncan / App.css
Last active April 19, 2018 15:43
postcss-import / postcss-custom-variables duplication
/* import tokens at top of App, along with any other global styles (e.g. normalize, etc.) */
@import "tokens";
@adamduncan
adamduncan / Modal.js
Created January 26, 2018 09:29
Container component for AriaModal
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import AriaModal from 'react-aria-modal';
import classNames from 'utils/namespace-classnames';
import './Modal.css';
class Modal extends React.Component {
constructor(props) {
super(props);
const StyledCard = styled.div`
background-color: #eee;
padding: 1rem;
border-radius: 0.25rem;
`
const Card = ({ title, copy }) => {
return (
<StyledCard>
<h3>{ title }</h3>
@adamduncan
adamduncan / snippets.cson
Created September 14, 2017 13:26
Atom HTML snippet
'.text.html':
'HTML5 Starter':
'prefix': 'html'
'body': '
<!DOCTYPE html>\n
<html class="no-js" lang="en">\n
\t<head prefix="og: http://ogp.me/ns">\n
\t\t<meta charset="utf-8">\n
\t\t<meta http-equiv="X-UA-Compatible" content="IE=edge">\n
\t\t<meta name="viewport" content="width=device-width, initial-scale=1.0" />\n\n
var docEl = document.documentElement;
console.log('Hello, external');
//----------------------------------------------------------------------
// HISTORY API
// Base Package
//----------------------------------------------------------------------
var HistoryAPI = {
contentId: 'content',
content: document.getElementById('content'),
animateClass: 'history-content--animate-out',
@adamduncan
adamduncan / SassMeister-input.scss
Created July 15, 2015 14:51
Generated by SassMeister.com. Example of @extending into classes instead of nested media queries.
// ----
// libsass (v3.2.5)
// ----
$doc-font-size: 16; /* 16px */
$lap: 600;
$desk: 900;
@mixin mq($point, $constraint: min, $feature: width) {
@media screen and (#{$constraint}-#{$feature}: $point / $doc-font-size + em) {
@adamduncan
adamduncan / SassMeister-input.scss
Created February 6, 2015 14:20
Generated by SassMeister.com.
// ----
// Sass (v3.4.11)
// Compass (v1.0.3)
// ----
/*-----------------------------------------------------*/
/*--------------------- VERSION 1 ---------------------*/
/*-----------------------------------------------------*/
.link-a {
color: red;