How to use the @microsoft/load-themed-styles.splitStyles function in @microsoft/load-themed-styles

To help you get started, we’ve selected a few @microsoft/load-themed-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 / monaco-editor / tasks / transformCssTask.js View on Github external
function createEsm(css) {
  const { splitStyles } = require('@microsoft/load-themed-styles');

  // Create a source file.
  const source = [
    `/* tslint:disable */`,
    `import { loadStyles } from \'@microsoft/load-themed-styles\';`,
    `loadStyles(${JSON.stringify(splitStyles(css))});`
  ];

  return source.join('\n');
}
github microsoft / roosterjs-react / tools / scss.js View on Github external
function createTypeScriptModule(fileName, css) {
    const { splitStyles } = require("@microsoft/load-themed-styles");

    // Create a source file.
    const source = [
      `/* tslint:disable */`,
      `import { loadStyles } from \'@microsoft/load-themed-styles\';`,
      `loadStyles(${JSON.stringify(splitStyles(css))});`
    ];

    const map = _fileNameToClassMap[fileName];

    for (let prop in map) {
      source.push(`export const ${prop} = "${map[prop]}";`);
    }

    return source.join('\n');
}
github OfficeDev / office-ui-fabric-react / scripts / tasks / sass.js View on Github external
function createTypeScriptModule(fileName, css) {
  const { splitStyles } = require('@microsoft/load-themed-styles');

  // Create a source file.
  const source = [
    `/* tslint:disable */`,
    `import { loadStyles } from \'@microsoft/load-themed-styles\';`,
    `loadStyles(${JSON.stringify(splitStyles(css))});`
  ];

  const map = _fileNameToClassMap[fileName];

  for (let prop in map) {
    source.push(`export const ${prop} = "${map[prop]}";`);
  }

  return source.join('\n');
}
github OfficeDev / office-ui-fabric-react / scripts / just-tasks / sass.js View on Github external
function createTypeScriptModule(fileName, css) {
  const { splitStyles } = require('@microsoft/load-themed-styles');

  // Create a source file.
  const source = [
    `/* tslint:disable */`,
    `import { loadStyles } from \'@microsoft/load-themed-styles\';`,
    `loadStyles(${JSON.stringify(splitStyles(css))});`
  ];

  const map = _fileNameToClassMap[fileName];

  for (let prop in map) {
    source.push(`export const ${prop} = "${map[prop]}";`);
  }

  return source.join('\n');
}
github microsoft / rushstack / core-build / gulp-core-build-sass / src / SassTask.ts View on Github external
let lines: string[] = [];
      lines.push(this.taskConfig.preamble || '');

      if (cssOutputPathAbsolute) {
        lines = lines.concat([
          `require(${JSON.stringify(`./${path.basename(cssOutputPathAbsolute)}`)});`,
          stylesExportString
        ]);
      } else if (content) {
        lines = lines.concat([
          'import { loadStyles } from \'@microsoft/load-themed-styles\';',
          '',
          stylesExportString,
          '',
          `loadStyles(${JSON.stringify(splitStyles(content))});`
        ]);
      }

      lines.push(this.taskConfig.postamble || '');

      const generatedTsFile: string = (
        lines
          .join(EOL)
          .replace(new RegExp(`(${EOL}){3,}`, 'g'), `${EOL}${EOL}`)
          .replace(new RegExp(`(${EOL})+$`, 'm'), EOL)
      );

      FileSystem.writeFile(scssTsOutputPath, generatedTsFile);
    });
  }
github microsoft / rushstack / gulp-core-build-sass / src / SassTask.ts View on Github external
let lines: string[] = [];

          lines.push(this.taskConfig.preamble || '');

          if (this.taskConfig.dropCssFiles) {
            lines = lines.concat([
              `require('./${path.basename(file.path, scssTsExtName)}.css');`,
              exportClassNames
            ]);
          } else if (!!content) {
            lines = lines.concat([
              'import { loadStyles } from \'@microsoft/load-themed-styles\';',
              '',
              exportClassNames,
              '',
              `loadStyles(${JSON.stringify(splitStyles(content))});`
            ]);
          }

          lines.push(this.taskConfig.postamble || '');

          return (
            lines
              .join(EOL)
              .replace(new RegExp(`(${EOL}){3,}`, 'g'), `${EOL}${EOL}`)
              .replace(new RegExp(`(${EOL})+$`, 'm'), EOL)
            );
        }
      }))

@microsoft/load-themed-styles

Loads themed styles.

MIT
Latest version published 12 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages