// @flow
import type { ColorPaletteColorNameKey } from './branding.proptypes';
import type { ThemeProps } from '../../types';
import type { PatchworkTheme } from '../../themes/theme.types';

export const getPaletteColor = (colorNameKey: ColorPaletteColorNameKey) => ({
  theme,
}: ThemeProps) => (colorNameKey ? theme.colorPalette[colorNameKey] : '');

export const getOutlineColor = (theme: PatchworkTheme) =>
  getPaletteColor('greyscale-light')({ theme });

/**
 * This is a stub! It does not offer full colour support
 * Please upgrade your micro-app to v.3.x to have full colour support
 * Instead, use `getPaletteColor` with one of ColorPaletteColorNameKey
 */
// $FlowFixMe
type DeprecatedVariant = ?any;
// $FlowFixMe
type DeprecatedMode = ?any;
// $FlowFixMe
type DeprecatedFade = ?any;

export const getColor = (
  theme: PatchworkTheme,
  variant: DeprecatedVariant,
  mode: DeprecatedMode,
  fade: DeprecatedFade = null,
) => {
  switch (variant) {
    case 'primary':
      return getPaletteColor(
        fade === null ? 'brand-primary-base' : 'brand-primary-dark',
      )({ theme });

    case 'secondary':
      return getPaletteColor(
        fade === null ? 'brand-secondary-base' : 'brand-secondary-dark',
      )({ theme });

    default:
      return getPaletteColor('greyscale-black')({ theme });
  }
};
