UNPKG

@atlaskit/app-provider

Version:

A top level provider for the Design System.

36 lines (35 loc) 1.73 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; exports.getScrollbarHarmonisationHtmlAttrs = getScrollbarHarmonisationHtmlAttrs; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _fg = require("@atlaskit/platform-feature-flags/fg"); var _constants = require("./constants"); /** * Server-side rendering utility. Generates the harmonised scrollbar HTML attributes so a * product's server can spread them onto the server-rendered `<html>` element. This avoids the * flash of un-harmonised scrollbars that would otherwise occur while waiting for * `useScrollbarHarmonisation`'s client-only effect to run. * * @param {boolean} [isEnabled] - An explicit value overrides the shared rollout gate; when * omitted, the shared gate controls the appearance. * * @returns {Object} Object of HTML attributes to be applied to the document root */ function getScrollbarHarmonisationHtmlAttrs(isEnabled) { var isGateEnabled = (0, _fg.fg)('platform_dst_scrollbar_harmonisation'); var shouldEnable = isEnabled !== null && isEnabled !== void 0 ? isEnabled : isGateEnabled; if (!shouldEnable) { return {}; } var result = (0, _defineProperty2.default)({}, _constants.SCROLLBAR_HARMONISATION_ATTRIBUTE, ''); var isTransparentTrackGateEnabled = (0, _fg.fg)('platform_dst_scrollbar_harmonisation_transparent'); if (isGateEnabled && isTransparentTrackGateEnabled) { result[_constants.SCROLLBAR_HARMONISATION_TRANSPARENT_ATTRIBUTE] = ''; } return result; } var _default = exports.default = getScrollbarHarmonisationHtmlAttrs;