mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-05-29 15:44:31 +00:00
Type definitions for "typography.js" (#28625)
* autogenerate files * add strictFunctionTypes * create type definitions for typography.js * add type tests * use pascal case instead of camel case
This commit is contained in:
committed by
Ryan Cavanaugh
parent
a60fadd782
commit
2b9558d869
60
types/typography/index.d.ts
vendored
Normal file
60
types/typography/index.d.ts
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
// Type definitions for typography 0.16
|
||||
// Project: https://github.com/KyleAMathews/typography.js
|
||||
// Definitions by: Boye <https://github.com/boyeborg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
interface BaseLine {
|
||||
fontSize: string;
|
||||
lineHeight: string;
|
||||
}
|
||||
|
||||
export interface VerticalRhythm {
|
||||
rhythm: (value: number) => string;
|
||||
scale: (value: number) => object;
|
||||
adjustFontSizeTo: (value?: number | string) => object;
|
||||
linesForFontSize: (fontSize: number) => number;
|
||||
establishBaseline: () => BaseLine;
|
||||
}
|
||||
|
||||
export interface GoogleFont {
|
||||
name: string;
|
||||
styles: string[];
|
||||
}
|
||||
|
||||
export interface TypographyOptions {
|
||||
baseFontSize?: string;
|
||||
baseLineHeight?: number;
|
||||
scaleRatio?: number;
|
||||
googleFonts?: GoogleFont[];
|
||||
headerFontFamily?: string[];
|
||||
bodyFontFamily?: string[];
|
||||
headerColor?: string;
|
||||
bodyColor?: string;
|
||||
headerWeight?: number | string;
|
||||
bodyWeight?: number | string;
|
||||
boldWeight?: number | string;
|
||||
blockMarginBottom?: number;
|
||||
includeNormalize?: boolean;
|
||||
overrideStyles?: (
|
||||
VerticalRhythm: VerticalRhythm,
|
||||
options: TypographyOptions,
|
||||
styles: any
|
||||
) => object;
|
||||
overrideThemeStyles?: (
|
||||
VerticalRhythm: VerticalRhythm,
|
||||
options: TypographyOptions,
|
||||
styles: any
|
||||
) => object;
|
||||
plugins?: any[];
|
||||
}
|
||||
|
||||
declare class Typography {
|
||||
constructor(opts: TypographyOptions);
|
||||
options: TypographyOptions;
|
||||
createStyles(): string;
|
||||
toJSON(): object;
|
||||
injectStyles(): void;
|
||||
}
|
||||
|
||||
export default Typography;
|
||||
23
types/typography/tsconfig.json
Normal file
23
types/typography/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"typography-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/typography/tslint.json
Normal file
1
types/typography/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
12
types/typography/typography-tests.ts
Normal file
12
types/typography/typography-tests.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import Typography from 'typography';
|
||||
|
||||
const typography = new Typography({
|
||||
baseFontSize: '18px',
|
||||
baseLineHeight: 1.45,
|
||||
headerFontFamily: ['Avenir Next', 'Helvetica Neue', 'Segoe UI', 'Helvetica', 'Arial', 'sans-serif'],
|
||||
bodyFontFamily: ['Georgia', 'serif']
|
||||
});
|
||||
|
||||
typography.createStyles(); // $ExpectType string
|
||||
typography.toJSON(); // $ExpectType object
|
||||
typography.options; // $ExpectType TypographyOptions
|
||||
Reference in New Issue
Block a user