当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript jss.create函数代码示例

本文整理汇总了TypeScript中jss.create函数的典型用法代码示例。如果您正苦于以下问题:TypeScript create函数的具体用法?TypeScript create怎么用?TypeScript create使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createJSS

// API docs at http://cssinjs.org/js-api

import {
	create as createJSS,
	default as sharedInstance
} from 'jss';

const jss = createJSS().setup({});

const styleSheet = jss.createStyleSheet(
	{
		ruleWithMockObservable: {
			subscribe() {}
		},
		container: {
			display: 'flex',
			width: 100,
			opacity: .5,
		},
	},
	{
		link: true,
	}
).attach();

styleSheet.classes.container; // $ExpectType string
styleSheet.classes.ruleWithMockObservable; // $ExpectType string

const rule = styleSheet.addRule('dynamicRule', { color: 'indigo' });
rule.prop('border-radius', 5).prop('color'); // $ExpectType string
styleSheet.classes.dynamicRule; // $ExpectType string
开发者ID:AdaskoTheBeAsT,项目名称:DefinitelyTyped,代码行数:31,代码来源:jss-tests.ts

示例2: create

import JSS, { create, SheetsManager } from "jss";
import presets from "jss-preset-default";

const jss: JSS = create(presets());
const stylesheetManager: SheetsManager = new SheetsManager();

export default jss;
export { stylesheetManager };
开发者ID:AlexxNica,项目名称:fast-dna,代码行数:8,代码来源:jss.ts

示例3: createMuiTheme

import { create, SheetsRegistry } from 'jss';
import preset from 'jss-preset-default';
import { createMuiTheme } from 'material-ui/styles';
import { purple, green } from 'material-ui/colors';
import createGenerateClassName from 'material-ui/styles/createGenerateClassName';

const theme = createMuiTheme({
  palette: {
    primary: purple,
    secondary: green,
  },
});

// Configure JSS
const jss = create(preset());
jss.options.createGenerateClassName = createGenerateClassName;

export const sheetsManager = new Map();

export default function createContext() {
  return {
    jss,
    theme,
    // This is needed in order to deduplicate the injection of CSS in the page.
    sheetsManager,
    // This is needed in order to inject the critical CSS.
    sheetsRegistry: new SheetsRegistry(),
  };
}
开发者ID:manelp,项目名称:menucoo-react,代码行数:29,代码来源:createContext.ts

示例4: createJSS

// API docs at http://cssinjs.org/js-api

import {create as createJSS, createGenerateId, SheetsRegistry, default as sharedInstance} from 'jss'

const jss = createJSS().setup({createGenerateId})
jss.use({}, {}) // $ExpectType JSS

const styleSheet = jss.createStyleSheet<string>(
  {
    rule: {
      color: (data: {color: string}) => data.color,

      '&:hover': {
        color: 'blue'
      }
    },
    container: {
      display: 'flex',
      'align-items': 'center',
      width: 100,
      opacity: 0.5
    }
  },
  {
    link: true
  }
)

const attachedStyleSheet = styleSheet.attach()

attachedStyleSheet.classes.container // $ExpectType string
开发者ID:cssinjs,项目名称:jss,代码行数:31,代码来源:jss-tests.ts

示例5: createJSS

// API docs at http://cssinjs.org/js-api

import {
	create as createJSS,
	createGenerateClassName,
	SheetsRegistry,
	default as sharedInstance,
} from 'jss';

const jss = createJSS().setup({ createGenerateClassName });
jss.use({}, {}); // $ExpectType JSS

const styleSheet = jss.createStyleSheet<string>(
	{
		ruleWithMockObservable: {
			subscribe: observer => {
				const next = typeof observer === 'function' ? observer : observer.next;
				next({ background: 'blue', display: 'flex' });
				next({ invalidKey: 'blueish' }); // $ExpectError

				// only kebab case allowed in observables
				next({ 'align-items': 'center' });
				next({ alignItems: 'center' }); // $ExpectError
				return {
					unsubscribe() {}
				};
			}
		},
		container: {
			display: 'flex',
			'align-items': 'center',
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:jss-tests.ts


注:本文中的jss.create函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。