@ampify/utils

Utilities to use in plugins.

Usage no npm install needed!

<script type="module">
  import ampifyUtils from 'https://cdn.skypack.dev/@ampify/utils';
</script>

README

Ampify Utils

Utilities to use in plugins.

togglify

Generate amp toggle events on targets

Accepts object:

  • el - The element to tap
  • targets - Array of objects with el and class to toggle

Example:

const el = document.querySelector('.hamburger');

const targets = [
  {
    el: document.querySelector('#menu'),
    className: 'active'
  },

  {
    el: document.querySelector('#submenu'),
    className: 'is-open'
  }
];

toggle({ el, targets });