本文整理汇总了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
示例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 };
示例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(),
};
}
示例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
示例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',