本文整理匯總了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',