mirror of
https://github.com/block/buzz.git
synced 2026-10-30 05:51:46 +00:00
Signed-off-by: Taylor Ho <taylorkmho@gmail.com> Signed-off-by: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@sprout-oss.stage.blox.sqprod.co>
29 lines
722 B
TypeScript
29 lines
722 B
TypeScript
import type { ReactNode } from "react";
|
|
import { useFeatureEnabled } from "./useFeatureEnabled";
|
|
|
|
interface FeatureGateProps {
|
|
/** The feature id from the manifest */
|
|
feature: string;
|
|
/** Content to render when the feature is enabled */
|
|
children: ReactNode;
|
|
/** Optional fallback when the feature is disabled */
|
|
fallback?: ReactNode;
|
|
}
|
|
|
|
/**
|
|
* Conditionally renders children based on whether a feature is enabled.
|
|
*
|
|
* Usage:
|
|
* <FeatureGate feature="workflows">
|
|
* <WorkflowsPanel />
|
|
* </FeatureGate>
|
|
*/
|
|
export function FeatureGate({
|
|
feature,
|
|
children,
|
|
fallback = null,
|
|
}: FeatureGateProps): ReactNode {
|
|
const enabled = useFeatureEnabled(feature);
|
|
return enabled ? children : fallback;
|
|
}
|