mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat(accessibility): new module definition (#45531)
- definition file - tests https://www.npmjs.com/package/accessibility https://ranbuch.github.io/accessibility/ Thanks!
This commit is contained in:
parent
6dba6cd0c6
commit
325d1254e1
50
types/accessibility/accessibility-tests.ts
Normal file
50
types/accessibility/accessibility-tests.ts
Normal file
@ -0,0 +1,50 @@
|
||||
let options: Accessibility.Options = {
|
||||
icon: {
|
||||
position: {
|
||||
bottom: { size: 50, units: 'px' },
|
||||
right: { size: 0, units: 'px' },
|
||||
type: 'fixed',
|
||||
},
|
||||
circular: false,
|
||||
img: 'accessible',
|
||||
},
|
||||
session: {
|
||||
persistent: false,
|
||||
},
|
||||
};
|
||||
new Accessibility(options);
|
||||
|
||||
options = {
|
||||
icon: {
|
||||
position: {
|
||||
top: { size: 2, units: 'vh' },
|
||||
left: { size: 2, units: '%' },
|
||||
type: 'absolute',
|
||||
},
|
||||
},
|
||||
};
|
||||
new Accessibility(options);
|
||||
|
||||
const instance = new Accessibility(options);
|
||||
|
||||
instance.menuInterface.increaseText();
|
||||
|
||||
instance.menuInterface.decreaseText();
|
||||
|
||||
instance.menuInterface.increaseTextSpacing();
|
||||
|
||||
instance.menuInterface.decreaseTextSpacing();
|
||||
|
||||
instance.menuInterface.invertColors();
|
||||
|
||||
instance.menuInterface.grayHues();
|
||||
|
||||
instance.menuInterface.underlineLinks();
|
||||
|
||||
instance.menuInterface.bigCursor();
|
||||
|
||||
instance.menuInterface.readingGuide();
|
||||
|
||||
instance.menuInterface.textToSpeech();
|
||||
|
||||
instance.menuInterface.speechToText();
|
||||
204
types/accessibility/index.d.ts
vendored
Normal file
204
types/accessibility/index.d.ts
vendored
Normal file
@ -0,0 +1,204 @@
|
||||
// Type definitions for accessibility 3.0
|
||||
// Project: https://github.com/ranbuch/accessibility#readme
|
||||
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export as namespace Accessibility;
|
||||
|
||||
/**
|
||||
* Adaptive Accessibility Menu
|
||||
*/
|
||||
declare class Accessibility {
|
||||
readonly menuInterface: Accessibility.MenuInterface;
|
||||
/** @deprecated */
|
||||
static init(options?: Accessibility.Options): Accessibility;
|
||||
|
||||
constructor(options?: Accessibility.Options);
|
||||
|
||||
alterTextSpace(isIncrease: boolean): void;
|
||||
build(): void;
|
||||
deleteOppositesIfDefined(options: Accessibility.Options): Accessibility.Options;
|
||||
destroy(): void;
|
||||
disabledUnsupportedFeatures(): void;
|
||||
fontFallback(): void;
|
||||
initFontSize(): void;
|
||||
injectCss(): void;
|
||||
invoke(action: () => void): void;
|
||||
listen(): void;
|
||||
onChange(updateSession: boolean): void;
|
||||
read(): void;
|
||||
resetIfDefined(src: any, dest: any, prop: string): void;
|
||||
runHotkey(name: string): void;
|
||||
saveSession(): void;
|
||||
setSessionFromCache(): void;
|
||||
speechToText(): void;
|
||||
textToSpeech(text: string): void;
|
||||
toggleMenu(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add accessibility to your website
|
||||
*/
|
||||
declare namespace Accessibility {
|
||||
interface MenuInterface {
|
||||
increaseText: () => void;
|
||||
decreaseText: () => void;
|
||||
increaseTextSpacing: () => void;
|
||||
decreaseTextSpacing: () => void;
|
||||
invertColors: (destroy?: boolean) => void;
|
||||
grayHues: (destroy?: boolean) => void;
|
||||
underlineLinks: (destroy?: boolean) => void;
|
||||
bigCursor: (destroy?: boolean) => void;
|
||||
readingGuide: (destroy?: boolean) => void;
|
||||
textToSpeech: (destroy?: boolean) => void;
|
||||
speechToText: (destroy?: boolean) => void;
|
||||
}
|
||||
interface Options {
|
||||
icon?: Icon;
|
||||
hotkeys?: HotKeys;
|
||||
buttons?: {
|
||||
font: SizeOrPosition;
|
||||
};
|
||||
guide?: {
|
||||
/** @default '#20ff69' */
|
||||
cBorder?: string;
|
||||
/** @default '#000000' */
|
||||
cBackground?: string;
|
||||
/** @default '12px' */
|
||||
height?: string;
|
||||
};
|
||||
menu?: {
|
||||
dimensions?: Dimensions;
|
||||
fontFamily?: string;
|
||||
};
|
||||
labels?: Labels;
|
||||
/** @default 'en-US' */
|
||||
textToSpeechLang?: string;
|
||||
/** @default 'en-US' */
|
||||
speechToTextLang?: string;
|
||||
/** @default false */
|
||||
textPixelMode?: boolean;
|
||||
/** @default true */
|
||||
textEmlMode?: boolean;
|
||||
animations?: {
|
||||
/** @default true */
|
||||
buttons?: boolean;
|
||||
};
|
||||
modules?: Modules;
|
||||
session?: {
|
||||
/** @default true */
|
||||
persistent?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface Icon {
|
||||
position?: Position;
|
||||
dimensions?: Dimensions;
|
||||
/** @default '9999' */
|
||||
zIndex?: string | number;
|
||||
/** @default '#4054b2' */
|
||||
backgroundColor?: string;
|
||||
/** @default '#fff' */
|
||||
color?: string;
|
||||
/** @default 'accessible' */
|
||||
img?: string;
|
||||
/** @default false */
|
||||
circular?: boolean;
|
||||
/** @default false */
|
||||
circularBorder?: boolean;
|
||||
/** @default ['https://fonts.googleapis.com/icon?family=Material+Icons'] */
|
||||
fontFaceSrc?: string[];
|
||||
/** @default 'Material Icons' */
|
||||
fontFamily?: string;
|
||||
/** @default 'Material Icons' */
|
||||
fontClass?: string;
|
||||
/** @default false */
|
||||
useEmojis?: boolean;
|
||||
}
|
||||
|
||||
interface Labels {
|
||||
/** @default 'Reset' */
|
||||
resetTitle?: string;
|
||||
/** @default 'Close' */
|
||||
closeTitle?: string;
|
||||
/** @default 'Accessibility Options' */
|
||||
menuTitle?: string;
|
||||
/** @default 'increase text size' */
|
||||
increaseText?: string;
|
||||
/** @default 'decrease text size' */
|
||||
decreaseText?: string;
|
||||
/** @default 'increase text spacing' */
|
||||
increaseTextSpacing?: string;
|
||||
/** @default 'decrease text spacing' */
|
||||
decreaseTextSpacing?: string;
|
||||
/** @default 'invert colors' */
|
||||
invertColors?: string;
|
||||
/** @default 'gray hues' */
|
||||
grayHues?: string;
|
||||
/** @default 'gray hues' */
|
||||
bigCursor?: string;
|
||||
/** @default 'reading guide' */
|
||||
readingGuide?: string;
|
||||
/** @default 'underline links' */
|
||||
underlineLinks?: string;
|
||||
/** @default 'underline links' */
|
||||
textToSpeech?: string;
|
||||
/** @default 'speech to text' */
|
||||
speechToText?: string;
|
||||
}
|
||||
|
||||
interface Modules {
|
||||
/** @default true */
|
||||
increaseText?: boolean;
|
||||
/** @default true */
|
||||
decreaseText?: boolean;
|
||||
/** @default true */
|
||||
increaseTextSpacing?: boolean;
|
||||
/** @default true */
|
||||
decreaseTextSpacing?: boolean;
|
||||
/** @default true */
|
||||
invertColors?: boolean;
|
||||
/** @default true */
|
||||
grayHues?: boolean;
|
||||
/** @default true */
|
||||
bigCursor?: boolean;
|
||||
/** @default true */
|
||||
readingGuide?: boolean;
|
||||
/** @default true */
|
||||
underlineLinks?: boolean;
|
||||
/** @default true */
|
||||
textToSpeech?: boolean;
|
||||
/** @default true */
|
||||
speechToText?: true;
|
||||
}
|
||||
|
||||
interface HotKeys {
|
||||
/** @default false */
|
||||
enabled?: boolean;
|
||||
/** @default true */
|
||||
helpTitles?: boolean;
|
||||
keys?: {
|
||||
[key: string]: HotKeyDefinition;
|
||||
};
|
||||
}
|
||||
|
||||
type HotKeyDefinition = [number, number, string];
|
||||
interface Dimensions {
|
||||
width?: SizeOrPosition;
|
||||
height?: SizeOrPosition;
|
||||
}
|
||||
|
||||
interface Position {
|
||||
top?: SizeOrPosition;
|
||||
right?: SizeOrPosition;
|
||||
bottom?: SizeOrPosition;
|
||||
left?: SizeOrPosition;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface SizeOrPosition {
|
||||
size: number | string;
|
||||
units?: string;
|
||||
}
|
||||
}
|
||||
export = Accessibility;
|
||||
23
types/accessibility/tsconfig.json
Normal file
23
types/accessibility/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"accessibility-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/accessibility/tslint.json
Normal file
1
types/accessibility/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user