import get from 'lodash/get';

import { OtherToken, OtherTokenRef, PropsWithTheme } from './types';

/**
 * Returns other theme value that can be used inside styled-component.
 *
 * ```tsx
 * import styled from 'styled-components/macro';
 * import { other } from '../theme';
 *
 * const StyledDiv = styled.div`
 *   transition-timing-function: ${other("timingFunction/smooth")};
 * `;
 * ```
 */
export function other(name: OtherTokenRef) {
  return (props: PropsWithTheme): OtherToken => get(props.theme, name.split('/'));
}
