How to use the jss.createStyleSheet function in jss

To help you get started, we’ve selected a few jss 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 krasimir / cssx / playground / jss / src / index.js View on Github external
import styles from './styles';
import jss from 'jss';
import nested from 'jss-nested'

jss.use(nested());

const { classes } = jss.createStyleSheet(styles).attach();

// classes // {button: '.button--jss-0-0 ', ctaButton: '.ctaButton--jss-0-2'}

document.body.innerHTML = `
  <button class="${classes.button}">Button</button>
  <br>
  <button class="${classes.ctaButton}">CTA Button</button>
  <p class="${classes.p}">Grumpy wizards make toxic brew for the evil Queen and Jack.</p>
`;
github teleporthq / teleport-code-generators / packages / teleport-plugin-common / src / builders / style-builders.ts View on Github external
export const createCSSClass = (className: string, styleObject: Record) =&gt; {
  return jss
    .createStyleSheet(
      {
        [`.${className}`]: styleObject,
      },
      {
        generateId: () =&gt; className,
      }
    )
    .toString()
}
github styleguidist / react-styleguidist / src / styles / addStyles.js View on Github external
export default memoize((styles, config, componentName) => {
	const mergedTheme = merge(theme, config.theme);
	const mergedStyles = merge(
		styles(mergedTheme),
		config.styles && config.styles[componentName]
	);
	const sheet = jss.createStyleSheet(mergedStyles, { meta: componentName }).attach();
	sheets.add(sheet);
	return sheet.classes;
});
github ArthurClemens / polythene / components / polythene / styler.js View on Github external
module.exports = function (key, rules) {
    var jss = require('jss');

    if (!key) return;
    if (!cache[key]) {
        var sheet = jss.createStyleSheet(rules, {named: false});
        sheet.attach();
        cache[key] = true;
    }
};
github KarolAltamirano / generator-react-web / app / templates / src / style / global.js View on Github external
a: {
      color: theme.color04,
      textDecoration: 'underline',
      cursor: 'pointer',
      '&:hover': {
        color: theme.color05,
      },
    },
    canvas: {
      display: 'block',
    },
  },
};

jss.setup(preset());
jss.createStyleSheet(styles, { meta: __filename }).attach();
github jeffkhull / typescript-fullstack-monorepo / packages / boilerplate-client / src / components / App.tsx View on Github external
import jssPreset from 'jss-preset-default'
import { useComputed, observer } from 'mobx-react-lite'
import { StoreContext } from '@client/index'

const styles = {
  '@global': {
    h1: config.markdownTheme.h1,
    h2: config.markdownTheme.h2,
    h3: config.markdownTheme.h3,
    p: config.markdownTheme.p,
    li: config.markdownTheme.li
  }
}

jss.setup(jssPreset())
jss.createStyleSheet(styles as any).attach()

export const App = observer(() =&gt; {
  const store = React.useContext(StoreContext)
  const currentPage: JSX.Element = useComputed(() =&gt; {
    switch (store.viewStore.currentPage) {
      case AppPage.Home:
        return 
      case AppPage.ComponentsDemos:
        return 
      case AppPage.ServerApiDemo:
        return 
      case AppPage.HooksDemo:
        return 
      default:
        throw new Error(`Unknown page ${store.viewStore.currentPage}`)
    }
github xenophilicibex / react-kronos / src / styled-component.js View on Github external
function attach(rules, options) {
    return jss.createStyleSheet(rules, options).attach()
  }
github alexkuz / cake-chart / src / utils / defaultSheets.js View on Github external
const ringSheet = jss.createStyleSheet({
    ...Array.apply(null, Array(depth + 1)).map((v, k) => k)
      .reduce((rules, idx) => ({
        ...rules,
        ['ring-' + idx]: { },
        ['labels-' + idx]: { }
      }), {})
  });

  const rings = ringSheet.classes;

  const trName = props.transitionName;
  const labelTrName = props.labelTransitionName;

  const ringTransitionSheet = jss.createStyleSheet({
    ...Array.apply(null, Array(depth + 1)).map((v, k) => k)
      .reduce((rules, idx) => ({
        ...rules,
        [`.${trName}-appear.${rings['ring-' + idx]}`]: {
          transform: 'scale(0.5)'
        },
        [`.${trName}-appear.${trName}-appear-active.${rings['ring-' + idx]}`]: {
          transform: 'scale(1)',
          transition: `transform 0.5s ease-out ${(idx / 5)}s`
        },
        [`.${trName}-enter.${rings['ring-' + idx]}`]: {
          transform: 'scale(0.5)'
        },
        [`.${trName}-enter.${trName}-enter-active.${rings['ring-' + idx]}`]: {
          transform: 'scale(1)',
          transition: `transform 0.5s ease-out ${(idx / 5)}s`
github mui-org / material-ui / packages / material-ui-benchmark / src / styles.js View on Github external
.add('JSS naked', () =&gt; {
    const sheetsRegistry = new SheetsRegistry();

    const staticStyles = cssObject;
    const dynamicStyles = getDynamicStyles(staticStyles);

    const staticSheet = jss.createStyleSheet(staticStyles);
    staticSheet.attach({
      link: false,
    });
    sheetsRegistry.add(staticSheet);

    if (dynamicStyles) {
      const dynamicSheet = jss.createStyleSheet(dynamicStyles, {
        link: true,
      });
      dynamicSheet.update({}).attach();
      sheetsRegistry.add(dynamicSheet);
    }

    ReactDOMServer.renderToString(
      
        {Array.from(new Array(5)).map((_, index) =&gt; (
          <button type="submit">
            Material-UI
          </button>
        ))}
      ,
    );
    sheetsRegistry.toString();
github alexkuz / cake-chart / src / Ring.jsx View on Github external
import React, { Component, PropTypes } from 'react';
import shouldPureComponentUpdate from 'react-pure-render/function';
import getSliceRadius from './getSliceRadius';
import Slice from './Slice';
import getColor from './getColor';
import jss from 'jss';
import classNames from 'classnames';

const sheet = jss.createStyleSheet({
  slice: {

  },
  sliceActive: {
    cursor: 'pointer'
  }
}).attach();

export default class Ring extends Component {
  static propTypes = {
    stroke: Slice.propTypes.stroke,
    strokeWidth: Slice.propTypes.strokeWidth,
    sliceRadius: Slice.propTypes.sliceRadius,
    onClick: Slice.propTypes.onClick,

    level: PropTypes.number.isRequired,