How to use the stylis function in stylis

To help you get started, we’ve selected a few stylis 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 styled-components / styled-components / src / utils / stringifyRules.js View on Github external
// @flow
import Stylis from 'stylis'
import type { Interpolation } from '../types'

const stylis = new Stylis({
  global: false,
  cascade: true,
  keyframe: false,
  prefix: true,
  compress: false,
  semicolon: true,
})

const stringifyRules = (
  rules: Array,
  selector: ?string,
  prefix: ?string,
): string => {
  const flatCSS = rules
    .join('')
    .replace(/^\s*\/\/.*$/gm, '') // replace JS comments
github rashmiap / personal-website-react / node_modules / styled-components / dist / styled-components-no-parser.esm.js View on Github external
return match;
  });
  return existingComponents.map(function (_ref, i) {
    var componentId = _ref.componentId,
        matchIndex = _ref.matchIndex;

    var nextComp = existingComponents[i + 1];
    var cssFromDOM = nextComp ? css.slice(matchIndex, nextComp.matchIndex) : css.slice(matchIndex);
    return { componentId: componentId, cssFromDOM: cssFromDOM };
  });
});

// 

// NOTE: This stylis instance is only used to split rules from SSR'd style tags
var stylisSplitter = new Stylis({
  global: false,
  cascade: true,
  keyframe: false,
  prefix: false,
  compress: false,
  semicolon: true
});

var stylis = new Stylis({
  global: false,
  cascade: true,
  keyframe: false,
  prefix: true,
  compress: false,
  semicolon: false // NOTE: This means "autocomplete missing semicolons"
});
github siddharthkp / css-constructor / api.js View on Github external
let insertRules = realCSS => {
  let style = getStyleElement()
  /* Get unique classname */
  let className = getHash(realCSS)
  /* Convert nested CSS */
  let styles = stylis(`.${className}`, realCSS)
  style.innerHTML += styles
  return className
}
github rashmiap / personal-website-react / node_modules / styled-components / dist / styled-components.esm.js View on Github external
// 

var COMMENT_REGEX = /^\s*\/\/.*$/gm;

// NOTE: This stylis instance is only used to split rules from SSR'd style tags
var stylisSplitter = new Stylis({
  global: false,
  cascade: true,
  keyframe: false,
  prefix: false,
  compress: false,
  semicolon: true
});

var stylis = new Stylis({
  global: false,
  cascade: true,
  keyframe: false,
  prefix: true,
  compress: false,
  semicolon: false // NOTE: This means "autocomplete missing semicolons"
});

// Wrap `insertRulePlugin to build a list of rules,
// and then make our own plugin to return the rules. This
// makes it easier to hook into the existing SSR architecture

var parsingRules = [];
// eslint-disable-next-line consistent-return
var returnRulesPlugin = function returnRulesPlugin(context) {
  if (context === -2) {
github rashmiap / personal-website-react / node_modules / styled-components / dist / styled-components-no-parser.browser.esm.js View on Github external
/* Handle objects */
    ruleSet.push(
    // $FlowFixMe have to add %checks somehow to isPlainObject
    isPlainObject(chunk) ? objToCss(chunk) : chunk.toString());

    return ruleSet;
  }, []);
};

// 

var COMMENT_REGEX = /^\s*\/\/.*$/gm;

// NOTE: This stylis instance is only used to split rules from SSR'd style tags
var stylisSplitter = new Stylis({
  global: false,
  cascade: true,
  keyframe: false,
  prefix: false,
  compress: false,
  semicolon: true
});

var stylis = new Stylis({
  global: false,
  cascade: true,
  keyframe: false,
  prefix: true,
  compress: false,
  semicolon: false // NOTE: This means "autocomplete missing semicolons"
});
github rashmiap / personal-website-react / node_modules / styled-components / dist / styled-components.esm.js View on Github external
/* Handle objects */
    ruleSet.push(
    // $FlowFixMe have to add %checks somehow to isPlainObject
    isPlainObject(chunk) ? objToCss(chunk) : chunk.toString());

    return ruleSet;
  }, []);
};

// 

var COMMENT_REGEX = /^\s*\/\/.*$/gm;

// NOTE: This stylis instance is only used to split rules from SSR'd style tags
var stylisSplitter = new Stylis({
  global: false,
  cascade: true,
  keyframe: false,
  prefix: false,
  compress: false,
  semicolon: true
});

var stylis = new Stylis({
  global: false,
  cascade: true,
  keyframe: false,
  prefix: true,
  compress: false,
  semicolon: false // NOTE: This means "autocomplete missing semicolons"
});
github styled-components / vue-styled-components / src / models / ComponentStyle.js View on Github external
generateAndInjectStyles (executionContext) {
      const flatCSS = flatten(this.rules, executionContext).join('')
        .replace(/^\s*\/\/.*$/gm, '') // replace JS comments
      const hash = hashStr(flatCSS)
      if (!inserted[hash]) {
        const selector = nameGenerator(hash)
        inserted[hash] = selector
        const css = stylis(`.${selector}`, flatCSS)
        this.insertedRule.appendRule(css)
      }
      return inserted[hash]
    }
  }
github siddharthkp / use-css / index.js View on Github external
function insertStyles(styles) {
  const className = getClassName(styles)

  // skip if these styles are already inserted
  if (isAlreadyInserted(className)) return className

  insertedClasses.push(className)
  const container = document.head.querySelector('#usecss')

  const raw = stylis(`.` + className, styles)
  container.append(raw)

  return className
}
github cdonohue / benefit / packages / benefit / util / getProcessedRules.ts View on Github external
export default function getProcessedRules(
  selector: string,
  cssRules: string
): string {
  return stylis(selector.replace(":", "\\:").replace("/", "\\/"), cssRules)
}
github davidbailey00 / ninetales / packages / style / src / lib / style-transform.js View on Github external
import Stylis from "stylis";

const stylis = new Stylis();

function disableNestingPlugin(...args) {
  let [context, , , parent = [], line, column] = args;
  if (context === 2) {
    parent = parent[0];
    if (
      typeof parent === "string" &&
      parent.trim().length > 0 &&
      parent.charAt(0) !== "@"
    ) {
      throw new Error(
        `Nesting detected at ${line}:${column}. ` +
          "Unfortunately nesting is not supported by styled-jsx."
      );
    }
  }

stylis

A Light–weight CSS Preprocessor

MIT
Latest version published 3 months ago

Package Health Score

84 / 100
Full package analysis