pk-utilities

1.0.2 • Public • Published

pk-utilities

A set of javasript utilities and patterns to use in pk- modules. You may of course adopt and leverage these utilities in any non pk- project as well.

classes.js

An object of common classes, particularly used to determine UI state.

focusable.js

An array of possible focusable DOM elements to check against.

helpers.js

An object of helper functions.

addClass, removeClass, and toggleClass pulled from http://youmightnotneedjquery.com

closest pulled from https://github.com/apostrophecms/apostrophe-lean-frontend

keys.js

An object of javascript event key codes

state.js

helpers that handle toggling classes and aria for UI state.

How To Use:

Import entire module and call whatever utils:

import pkutils from 'pk-utilities';

button.addEventListener('click', function () {
  pkutils.helpers.toggleClass(this, pkutils.classes.active);
});

Or import each util as needed:

import { helpers, classes } from 'pk-utilities';

button.addEventListener('click', function () {
  helpers.toggleClass(this, classes.active);
});

Package Sidebar

Install

npm i pk-utilities

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

5.96 kB

Total Files

10

Last publish

Collaborators

  • jlandrum_yesand