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

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

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

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

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