How to use the @uifabric/merge-styles.setRTL function in @uifabric/merge-styles

To help you get started, we’ve selected a few @uifabric/merge-styles examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OfficeDev / office-ui-fabric-react / packages / utilities / src / rtl.ts View on Github external
export function getRTL(theme: { rtl?: boolean } = {}): boolean {
  if (theme.rtl !== undefined) {
    return theme.rtl;
  }
  if (_isRTL === undefined) {
    // Fabric supports persisting the RTL setting between page refreshes via session storage
    let savedRTL = getItem(RTL_LOCAL_STORAGE_KEY);
    if (savedRTL !== null) {
      _isRTL = savedRTL === '1';
      setRTL(_isRTL);
    }

    let doc = getDocument();
    if (_isRTL === undefined && doc) {
      _isRTL = ((doc.body && doc.body.getAttribute('dir')) || doc.documentElement.getAttribute('dir')) === 'rtl';
      mergeStylesSetRTL(_isRTL);
    }
  }

  return !!_isRTL;
}
github OfficeDev / office-ui-fabric-react / packages / utilities / src / rtl.ts View on Github external
export function setRTL(isRTL: boolean, persistSetting: boolean = false): void {
  let doc = getDocument();
  if (doc) {
    doc.documentElement.setAttribute('dir', isRTL ? 'rtl' : 'ltr');
  }

  if (persistSetting) {
    setItem(RTL_LOCAL_STORAGE_KEY, isRTL ? '1' : '0');
  }

  _isRTL = isRTL;
  mergeStylesSetRTL(_isRTL);
}