const allSides = ['x', 'y', 't', 'r', 'b', 'l'];

/**
 * Map a side-spacer (e.g., margin or padding) specification onto a list of
 * classes. A side-spacer can be specified as a single value that applies to
 * all sides or as an object that specifies different values for different
 * sides. Sides include `x` (left and right), `y` (top and bottom), `t` (top),
 * `r` (right), `b` (bottom), and `l` (left).
 *
 * @param {'p'|'m'} prefix
 *   The class prefix to use. The prefix `p` specifies padding and `m`
 *   specifies margin.
 * @param {string|Object} value
 *   The side-spacer specification.
 * @returns {string[]} An array of class names.
 */
const getPaddingClasses = function getPaddingClasses(prefix, value, options = {}) {
  const {
    defaultSide = '',
    sides = allSides
  } = options;
  if (!value) {
    return [];
  }
  if (typeof value !== 'object') {
    return [`${prefix}${defaultSide}-${value}`];
  }
  return sides.map(side => {
    const level = value[side];
    if (typeof level === 'undefined') return null;
    return `${prefix}${side}-${level}`;
  }).filter(Boolean);
};
export default getPaddingClasses;