@awsui/components-react
Version:
On July 19th, 2022, we launched [Cloudscape Design System](https://cloudscape.design). Cloudscape is an evolution of AWS-UI. It consists of user interface guidelines, front-end components, design resources, and development tools for building intuitive, en
22 lines • 1.37 kB
JavaScript
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { useContext } from 'react';
import { getGlobalFlag } from '@awsui/component-toolkit/internal';
import { useVisualRefresh } from '../../internal/hooks/use-visual-mode';
import { AppLayoutToolbarPublicContext } from '../visual-refresh-toolbar/contexts';
// useAppLayoutFlagEnabled is set to true only in consoles. It controls if AppLayout theme is toolbar
export const useAppLayoutFlagEnabled = () => {
const isRefresh = useVisualRefresh();
return isRefresh && (getGlobalFlag('appLayoutWidget') || getGlobalFlag('appLayoutToolbar'));
};
// AppLayoutToolbar component will have 2 modes:
// - for those who use AppLayout component with toolbar. they expect to have all existing features, including deduplication
// - for non-console usage. in this case we don't need "hidden" features to be enabled, now it's only deduplication
// the hooks I want to name will exist only internally to control this behavior
export const useAppLayoutToolbarDesignEnabled = () => {
var _a;
const isToolbarPrivate = useAppLayoutFlagEnabled();
const isToolbarPublic = (_a = useContext(AppLayoutToolbarPublicContext)) !== null && _a !== void 0 ? _a : false;
return isToolbarPublic || isToolbarPrivate;
};
//# sourceMappingURL=feature-flags.js.map