import get from 'lodash/get';

/**
 * Creates a function that will look up the a design token from the `theme` context of a
 * tyled component or a component that accepts theme as a prop.
 *
 * @param path Valid path for current theme
 * @returns A function that accepts an object with a keyof `theme` and looks up the
 *  value at supplied path parameter
 */

export function themed(path) {
  return ({
    theme
  }) => get(theme, path);
}