How to use the styletron-engine-atomic.Server function in styletron-engine-atomic

To help you get started, we’ve selected a few styletron-engine-atomic 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 uber / baseweb / documentation-site / helpers / styletron.js View on Github external
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/

/* eslint-disable flowtype/require-valid-file-annotation */
/* global document */

import {Client, Server} from 'styletron-engine-atomic';
import {DebugEngine} from 'styletron-react';

export const isServer = typeof window === 'undefined';

const getHydrate = () => document.getElementsByClassName('_styletron_hydrate_');

export const styletron = isServer
  ? new Server()
  : new Client({hydrate: getHydrate()});

export const debug =
  /*eslint-disable*/
  process.env.NODE_ENV === 'production' ? void 0 : new DebugEngine();
github styletron / styletron / packages / styletron-standard / src / __tests__ / core.node.js View on Github external
test("driver", t => {
  let cssString;
  const instance = new Server();
  const styleObject = {
    color: "red",
  };
  driver(styleObject, instance);
  cssString = ".ae{color:red}";
  t.strictEqual(instance.getCss(), cssString, "injects basic style");
  const fontFallback = {
    fontFamily: ["Arial", "sans-serif"],
  };
  driver(fontFallback, instance);
  cssString = `${cssString}.af{font-family:Arial,sans-serif}`;
  t.strictEqual(instance.getCss(), cssString, "injects font fallbacks - basic");
  const fontFace = {
    src: "url(some-awesome-font.ttf)",
  };
  const declaredFontFaceFallback = {
github rtsao / www / gatsby-ssr.js View on Github external
import React from "react";
import { Server as Styletron } from "styletron-engine-atomic";
import { Provider } from "styletron-react";

const engine = new Styletron();

export const wrapRootElement = ({ element }, options) => (
  {element}
);

export const onRenderBody = ({ bodyComponent, setHeadComponents }, options) => {
  const stylesheets = engine.getStylesheets();
  const headComponents = stylesheets[0].css
    ? stylesheets.map((sheet, index) => (
github zeit / next.js / examples / with-styletron / styletron.js View on Github external
import { Client, Server } from 'styletron-engine-atomic'
import { DebugEngine } from 'styletron-react'

const getHydrateClass = () =>
  document.getElementsByClassName('_styletron_hydrate_')

export const styletron =
  typeof window === 'undefined'
    ? new Server()
    : new Client({
        hydrate: getHydrateClass(),
      })

export const debug =
  process.env.NODE_ENV === 'production' ? void 0 : new DebugEngine()
github iotexproject / iotex-explorer / src / shared / common / apollo-ssr.tsx View on Github external
ssrMode: true,
    link: createHttpLink({
      uri,
      fetch,
      credentials: "same-origin",
      headers: {
        cookie: ctx.get("Cookie")
      }
    }),
    cache: new InMemoryCache()
  });

  const state = ctx.getState();
  initAssetURL(state.base.manifest);
  const store = configureStore(state, noopReducer);
  const styletron = new engine.Server({ prefix: "_" });

  const context = {};

  const walletState: IWalletState = {
    customRPCs: [],
    tokens: {},
    defaultNetworkTokens: []
  };

  try {
    await getDataFromTree(

styletron-engine-atomic

Universal, high-performance JavaScript styles

MIT
Latest version published 1 year ago

Package Health Score

62 / 100
Full package analysis

Popular styletron-engine-atomic functions

Similar packages