How to use the aphrodite.StyleSheetServer.renderStatic 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 TrueCar / gluestick / packages / gluestick-plugin-aphrodite / src / server.js View on Github external
renderMethod: (root, styleTags) => {
    const { css, html } = StyleSheetServer.renderStatic(() => {
      return renderToString(root);
    });
    const head = [
      ...styleTags,
      <style data-aphrodite="">{`${css.content}`}</style>,
    ];
    const rehydrate = `window.renderedClassNames = ${JSON.stringify(
      css.renderedClassNames,
    )};`;
    const additionalScript = [
      // eslint-disable-next-line react/no-danger
github javascriptair / site / generate / renderComponentToFile.js View on Github external
function renderComponent(comp, destinations, callback = noop) {
  destinations = arrify(destinations)
  const {html, css} = StyleSheetServer.renderStatic(() => ReactDOMServer.renderToStaticMarkup(comp))
  const string = html.replace('/* aphrodite-content */', css.content)
  async.parallel(
    destinations.map(d => cb => writeFile(d, string, cb)),
    callback,
  )
}
github Ariel-Rodriguez / react-amp-template / src / StyleManager / Aphrodite.js View on Github external
static render(element, opts) {
    // eslint-disable-next-line global-require
    const { StyleSheetServer } = require('aphrodite')
    const { css, html } = StyleSheetServer.renderStatic(() => preactToString(element, null, opts))
    return {
      css: css.content,
      html,
    }
  }
}
github watson-developer-cloud / natural-language-understanding-nodejs / views / index.jsx View on Github external
import React from 'react';
import { StyleSheetServer } from 'aphrodite';
import ReactDOMServer from 'react-dom/server';
import HtmlToReact from 'html-to-react';
import Layout from './Layout.jsx';
import Demo from './Demo.jsx';

// Contains the generated html, as well as the generated css and some
// rehydration data.
const { html, css } = StyleSheetServer.renderStatic(() =&gt; ReactDOMServer
  .renderToStaticMarkup());

export { html, css };

export default function Index() {
  return (
    
      {(new HtmlToReact.Parser(React)).parse(html)}
    
  );
}
github Khan / aphrodite / examples / runkit.js View on Github external
":hover": {
                color: "blue",
            },
        },
    });

    // Generate some CSS with Aphrodite class names in it.
    return `<div class="${css(styles.red)}">
        Hover, and I'll turn blue!
    </div>`;
}

const {StyleSheetServer} = require("aphrodite");

// Call our render function inside of StyleSheetServer.renderStatic
const {css, html} = StyleSheetServer.renderStatic(() =&gt; {
    return render();
});

// Observe our output HTML and the Aphrodite-generated CSS
`<style>${css.content}</style>${html}`;
github DefinitelyTyped / DefinitelyTyped / aphrodite / aphrodite-tests.tsx View on Github external
<span>
                This is blue.
            </span>
            <span>
                This is blue and turns red when the browser is less than
                600px width.
            </span>
            <span>
                With font
            </span>
        ;
    }
}

const output = StyleSheetServer.renderStatic(() =&gt; {
    return "test";
});

output.css.content;
output.css.renderedClassNames;
output.html;

StyleSheet.rehydrate(output.css.renderedClassNames);

StyleSheetTestUtils.suppressStyleInjection();
StyleSheetTestUtils.clearBufferAndResumeStyleInjection();
github Khan / OpenResponses / pages / _document.js View on Github external
static async getInitialProps({ renderPage }) {
    const { html, css } = StyleSheetServer.renderStatic(() => renderPage());
    return { ...html, css };
  }
github alloy / relational-theory / app / routes.js View on Github external
}, res.locals.networkLayer).then(({ data, props }) =&gt; {
    const { html, css } = StyleSheetServer.renderStatic(() =&gt; {
      return ReactDOMServer.renderToString()
    })
    res.send(`
      
      
        <style data-aphrodite="">${css.content}</style>
        
        
      
      
        <div id="root">${html}</div>
github expo / snack-web / src / server / routes.tsx View on Github external
return decodeURIComponent(result);
      }

      return result;
    },
  };

  const index =
    '' +
    ReactDOMServer.renderToStaticMarkup(
       {
          return ReactDOMServer.renderToString(
            
              
              
                
                  
                    
                      
                    
                  
                
              
            
          );
        })}
      /&gt;
github zeit / next.js / examples / with-aphrodite / pages / _document.js View on Github external
static async getInitialProps({ renderPage }) {
    const { html, css } = StyleSheetServer.renderStatic(() => renderPage())
    const ids = css.renderedClassNames
    return { ...html, css, ids }
  }