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

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

export const getDropzoneOpacity = (props: FileUploaderProps) =>
  props.savePending ? 0.5 : 1;

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 });
};
