mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-05-02 19:42:30 +02:00
25 lines
523 B
TypeScript
25 lines
523 B
TypeScript
import * as React from 'react';
|
|
|
|
export interface IFeatureFlagProps {
|
|
flag: string;
|
|
features: string[] | null;
|
|
alternative?: JSX.Element;
|
|
}
|
|
|
|
export const FeatureFlag: React.FunctionComponent<IFeatureFlagProps> = ({
|
|
flag,
|
|
features,
|
|
alternative,
|
|
children
|
|
}: React.PropsWithChildren<IFeatureFlagProps>) => {
|
|
if (!features || features.length === 0 || (features.length > 0 && !features.includes(flag))) {
|
|
if (alternative) {
|
|
return alternative;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
};
|