const toHex = opacity => Number(opacity * 255).toString(16);

const createOpacityColorPicker = (colorPicker, opacity) => props =>
  `${colorPicker(props)}${toHex(opacity)}`;

const createColorPicker = colorPicker => {
  colorPicker[0.2] = createOpacityColorPicker(colorPicker, 0.2);
  colorPicker[0.4] = createOpacityColorPicker(colorPicker, 0.4);
  colorPicker[0.6] = createOpacityColorPicker(colorPicker, 0.6);
  colorPicker[0.8] = createOpacityColorPicker(colorPicker, 0.8);

  return colorPicker;
};

export const primaryColor = createColorPicker(
  ({ theme }) => theme.colors.brand.primary,
);

export const secondaryColor = createColorPicker(
  ({ theme }) => theme.colors.brand.secondary,
);

export const whiteColor = createColorPicker(
  ({ theme }) => theme.colors.grays.white,
);

export const grayColor = createColorPicker(
  ({ theme }) => theme.colors.grays.gray,
);

export const notificationColor = status =>
  createColorPicker(({ theme }) => theme.colors.notifications[status]);

export const linkColor = createColorPicker(({ theme }) => theme.colors.link);
