// @flow
import { getPaletteColor } from '../../mixins/branding';
import type { ThemeProps } from '../../types';
import type { FileUploaderProps } from './file-uploader.proptypes';

export const getDropzoneHeight = ({
  attachments,
  baseHeight = '200px',
}: FileUploaderProps) =>
  attachments && attachments.length > 0 ? undefined : baseHeight;

export const getDropzoneBorderColor = ({
  theme,
  attachmentsError,
  isDragActive,
}: {|
  ...FileUploaderProps,
  ...ThemeProps,
  isDragActive: boolean,
|}) => {
  if (isDragActive) {
    return getPaletteColor('greyscale-dark')({ theme });
  }

  if (attachmentsError != null) {
    return getPaletteColor('error-fg')({ theme });
  }

  return getPaletteColor('greyscale-light')({ theme });
};
