How to use the aphrodite.StyleSheetServer function in aphrodite

To help you get started, we’ve selected a few aphrodite 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 phenomic / phenomic / src / components / Html / index.js View on Github external
// https://github.com/threepointone/glamor/blob/master/docs/server.md
  let glamorRenderStatic
  try {
    // $FlowFixMe just ignore glamor as we don't have it as a dep
    glamorRenderStatic = require("glamor/server").renderStatic
  }
  catch (e) {
    // skip glamor if not working
  }

  // Aprodite
  // https://github.com/Khan/aphrodite#server-side-rendering
  let aproditeRenderStatic
  try {
    // $FlowFixMe just ignore aprodite as we don't have it as a dep
    aproditeRenderStatic = require("aphrodite").StyleSheetServer.renderStatic
  }
  catch (e) {
    // skip aprodite if not working
  }

  // render body
  let body
  if (glamorRenderStatic) {
    const glamorResult = glamorRenderStatic(() => props.renderBody())

    renderToString(
github styletron / styletron / packages / benchmarks / filesize.js View on Github external
function outputAphrodite(aphroditeApp, filename) {
  const {css} = aphrodite.StyleSheetServer.renderStatic(aphroditeApp);
  fs.writeFileSync(
    path.join(__dirname, 'results', filename),
    css.content,
    'utf8'
  );
}
github styletron / styletron / packages / benchmarks / server.js View on Github external
.add('aphrodite (uber.css)', function() {
    aphrodite.StyleSheetServer.renderStatic(uberApp.aphrodite);
  })
  .add('styletron (uber.css)', function() {
github styletron / styletron / packages / benchmarks / server.js View on Github external
.add('aphrodite (all-unique)', function() {
    aphrodite.StyleSheetServer.renderStatic(allUniqueApp.aphrodite);
  })
  .add('styletron (all-unique)', function() {
github styletron / styletron / packages / benchmarks / renderers / aphrodite.js View on Github external
module.exports = (sheet, synthetic) => {
  const keys = Object.keys(sheet);
  const len = keys.length;
  let first;
  let middle;
  let last;
  let {css} = aphrodite.StyleSheetServer.renderStatic(() => {
    let aphroditeStyles = aphrodite.StyleSheet.create(sheet);
    for (let i = 0; i < len; i++) {
      let className = aphrodite.css(aphroditeStyles[keys[i]]);
      if (i === 0) {
        first = className;
      } else if (keys[i] === 'c1000') {
        middle = className;
      } else if (i === len - 1) {
        last = className;
      }
    }
  });

  const styleElement = synthetic
    ? `<style data-aphrodite=""></style>`
    : `<style data-aphrodite="">${css.content}</style>`;