export function clickOutside(el, callback) {
  document.addEventListener('click', evt => {
    let targetElement = evt.target; // clicked element
    do {
      if (targetElement == el) {
        // This is a click inside. Do nothing, just return.
        return;
      }
      targetElement = targetElement.parentNode; // Go up the DOM
    } while (targetElement);
    // run callback
    callback();
  });
}
