Skip to content

Instantly share code, notes, and snippets.

View downzer0's full-sized avatar
😎

Chris McRiguez downzer0

😎
View GitHub Profile
@downzer0
downzer0 / focus-trap.ts
Last active December 22, 2021 20:10
Accessibility trap focus plugin
/**
* This helper utility is meant to be used with the flyout navigation or modals.
* It traps focus inside the opened or overlaying component per WCAG spec.
*
* Some trap focus examples only focus on Tab and Shift+Tab, but many screen readers
* browse differently, in caret mode, with arrow keys. As a result, these traditional
* trap focus methods are insufficient. We need to hide everything outside the overlay
* from screen readers and make it not focusable. This means applying 'aria-hidden'
* and 'tabindex=-1' to all elements not within the modal. Once the modal is closed
* we need to remove these attributes.
@downzer0
downzer0 / logger.js
Created August 13, 2018 14:57
logger.js
/* eslint no-console: off */
const chalk = require('chalk');
const log = (...args) => console.log(...args);
const warn = (...args) => console.warn(chalk.yellow(...args));
const error = (...args) => console.error(chalk.redBright(...args));
const success = (...args) => console.log(chalk.green(...args));
module.exports = { log, warn, error, success };
@downzer0
downzer0 / depth-first-search.js
Created July 13, 2018 13:56
Depth-first object searching
// depth-first object search
const findNode = (scores, opDiv, found = []) => {
for (let org in scores) {
if (scores[org].path === opDiv) {
found.push(scores[org]);
return found[0];
}
if (typeof scores[org] === 'object') {
findNode(scores[org].children, opDiv, found);
}
@downzer0
downzer0 / keybase.md
Created November 22, 2016 19:17
Keybase proof

Keybase proof

I hereby claim:

  • I am downzer0 on github.
  • I am clrux (https://keybase.io/clrux) on keybase.
  • I have a public key whose fingerprint is 3855 F359 DA0B CF88 F551 3186 FB47 2769 B168 7A09

To claim this, I am signing this object:

@downzer0
downzer0 / image-zoom-tool.js
Created August 23, 2016 19:19
image-zoom-tool.js
/*
* edX Image Zoom Tool
* v0.0.1
*
* This script was modified from our jquery.loupeAndLightbox.js script, but
* goes further and adds keyboard accessibility to the zooming controls.
*/
(function($){
$.fn.edxImageZoomTool = function(options) {