Skip to content

Instantly share code, notes, and snippets.

@thomas-mcdonald
Created August 11, 2017 14:44
Show Gist options
  • Save thomas-mcdonald/e703bcc940e16ee6ba8fff8bc554fdb1 to your computer and use it in GitHub Desktop.
Save thomas-mcdonald/e703bcc940e16ee6ba8fff8bc554fdb1 to your computer and use it in GitHub Desktop.
import { ISelectProps } from "@blueprintjs/labs";
import * as React from "react";
import { DropdownButton } from "./DropdownButton";
interface IDisableableSelectProps {
disabled?: boolean;
text: string;
}
export function disableableSelect<T>(
InitialSelectComponent: React.ComponentClass<ISelectProps<T>>
): React.ComponentClass<ISelectProps<T> & IDisableableSelectProps> {
return class DisableableSelectWrapper extends React.Component<ISelectProps<T> & IDisableableSelectProps> {
public render() {
const { disabled = false, items, itemRenderer, onItemSelect, text } = this.props;
if (disabled) {
return <DropdownButton disabled={true} text={text} />;
}
return (
<InitialSelectComponent items={items} itemRenderer={itemRenderer} onItemSelect={onItemSelect}>
<DropdownButton text={text} />
</InitialSelectComponent>
);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment