mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
jss: Add definitions for createGenerateClassName
This commit is contained in:
5
types/jss/index.d.ts
vendored
5
types/jss/index.d.ts
vendored
@@ -3,6 +3,7 @@
|
||||
// Definitions by: Brenton Simpson <https://github.com/appsforartists>
|
||||
// Oleg Slobodskoi <https://github.com/kof>
|
||||
// Thomas Crockett <https://github.com/pelotom>
|
||||
// Sebastian Silbermann <https://github.com/eps1lon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -137,6 +138,10 @@ export declare class JSS {
|
||||
* Creates a new instance of JSS.
|
||||
*/
|
||||
export function create(options?: Partial<JSSOptions>): JSS;
|
||||
/**
|
||||
* Creates a GenerateClassName function
|
||||
*/
|
||||
export function createGenerateClassName(): GenerateClassName;
|
||||
declare const sharedInstance: JSS;
|
||||
/**
|
||||
* A global JSS instance.
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
import {
|
||||
create as createJSS,
|
||||
createGenerateClassName,
|
||||
SheetsRegistry,
|
||||
default as sharedInstance,
|
||||
} from 'jss';
|
||||
|
||||
const jss = createJSS().setup({});
|
||||
const jss = createJSS().setup({ createGenerateClassName });
|
||||
jss.use({}, {}); // $ExpectType JSS
|
||||
|
||||
const styleSheet = jss.createStyleSheet<string>(
|
||||
@@ -46,6 +47,9 @@ const rule = attachedStyleSheet.addRule('dynamicRule', { color: 'indigo' });
|
||||
rule.prop('border-radius', 5).prop('color'); // $ExpectType string
|
||||
attachedStyleSheet.classes.dynamicRule; // $ExpectType string
|
||||
|
||||
const generateClassName = createGenerateClassName();
|
||||
const dynamicRuleClassName = generateClassName(rule, attachedStyleSheet);
|
||||
|
||||
attachedStyleSheet.deleteRule('dynamicRule');
|
||||
|
||||
// test that `addRule` supports the shorthand signature
|
||||
|
||||
Reference in New Issue
Block a user