Files
buzz/desktop/src/shared/features/FeatureGate.tsx
Taylor Ho ae430d4dd9 feat: preview features (experiments settings UI) (#888)
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@sprout-oss.stage.blox.sqprod.co>
2026-06-09 09:53:09 -07:00

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;
}