import { ComponentProps, ComponentType, JSX, PureComponent } from "react";

import { SvgConstantNegativeTheme } from "../SvgConstants";
import { InjectedSvgProps } from "./hocTypings";
import { getDisplayName } from "./utils";

export function asNegativeSvg<
  C extends ComponentType<ComponentProps<C> & InjectedSvgProps>,
  ResolvedProps = JSX.LibraryManagedAttributes<C, ComponentProps<C>>
>(WrappedComponent: C) {
  return class AsNegativeSvg extends PureComponent<
    ResolvedProps & InjectedSvgProps
  > {
    static displayName = `asNegativeSvg(${getDisplayName(WrappedComponent)})`;

    static defaultProps = {
      fillColor: SvgConstantNegativeTheme.fill,
      secondaryFillColor: SvgConstantNegativeTheme.secondaryFill,
      className: "ddbc-svg--negative",
    };

    render() {
      return <WrappedComponent {...(this.props as any)} />;
    }
  };
}
