當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。