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

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

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

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

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