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

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

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

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

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