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

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

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

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

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