mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
feat(types): add carbon__icon-helpers (#43314)
This commit is contained in:
parent
b21148cd10
commit
db21a0f0c0
26
types/carbon__icon-helpers/carbon__icon-helpers-tests.ts
Normal file
26
types/carbon__icon-helpers/carbon__icon-helpers-tests.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { defaultAttributes, getAttributes, formatAttributes, toString, toSvg } from '@carbon/icon-helpers';
|
||||
|
||||
defaultAttributes.focusable; // $Expect 'false'
|
||||
defaultAttributes.preserveAspectRatio; // $Expect 'xMidYMid meet'
|
||||
getAttributes({ width: 16, height: 16 }); // $ExpectType IconAttributes
|
||||
formatAttributes({ width: 16, height: 16 }); // $ExpectType string
|
||||
toString(); // $Expect string
|
||||
toString({
|
||||
elem: 'svg',
|
||||
attrs: { width: 16, height: 16 },
|
||||
content: [
|
||||
{ elem: 'path', attrs: { d: '' } },
|
||||
{ elem: 'circle', attrs: { cx: '', cy: '', r: '' } },
|
||||
{ elem: 'rect', attrs: { width: '', height: '', x: '', y: '', rx: '' } },
|
||||
],
|
||||
}); // $Expect string
|
||||
toSvg(); // $ExpectType SVGSVGElement
|
||||
toSvg({
|
||||
elem: 'svg',
|
||||
attrs: { width: 16, height: 16 },
|
||||
content: [
|
||||
{ elem: 'path', attrs: { d: '' } },
|
||||
{ elem: 'circle', attrs: { cx: '', cy: '', r: '' } },
|
||||
{ elem: 'rect', attrs: { width: '', height: '', x: '', y: '', rx: '' } },
|
||||
],
|
||||
}); // $Expect SVGSVGElement
|
||||
56
types/carbon__icon-helpers/index.d.ts
vendored
Normal file
56
types/carbon__icon-helpers/index.d.ts
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
// Type definitions for @carbon/icon-helpers 10.6
|
||||
// Project: https://github.com/carbon-design-system/carbon/blob/master/packages/icon-helpers
|
||||
// Definitions by: Eric Liu <https://github.com/metonym>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.8
|
||||
|
||||
export interface Path {
|
||||
elem: 'path';
|
||||
attrs: { d: string };
|
||||
}
|
||||
|
||||
export interface Circle {
|
||||
elem: 'circle';
|
||||
attrs: { cx: string; cy: string; r: string };
|
||||
}
|
||||
|
||||
export interface Rect {
|
||||
elem: 'rect';
|
||||
attrs: { width: string; height: string; x: string; y: string; rx: string };
|
||||
}
|
||||
|
||||
export type IconSize = 16 | 20 | 24 | 32;
|
||||
|
||||
export type IconContent = Array<Path | Circle | Rect>;
|
||||
|
||||
export interface IconAttributes extends Record<string, any> {
|
||||
'aria-hidden'?: boolean;
|
||||
'aria-label'?: string;
|
||||
'aria-labelledby'?: string;
|
||||
class?: string;
|
||||
focusable?: 'true' | 'false';
|
||||
height: IconSize;
|
||||
id?: string;
|
||||
preserveAspectRatio?: string | 'xMidYMid meet';
|
||||
role?: 'img';
|
||||
style?: string;
|
||||
tabindex?: string;
|
||||
title?: string;
|
||||
viewBox?: string;
|
||||
width: IconSize;
|
||||
}
|
||||
|
||||
export interface Descriptor {
|
||||
elem?: string | 'svg';
|
||||
attrs?: IconAttributes | {};
|
||||
content?: IconContent | [];
|
||||
}
|
||||
|
||||
export const defaultAttributes: {
|
||||
focusable: 'false';
|
||||
preserveAspectRatio: 'xMidYMid meet';
|
||||
};
|
||||
export function getAttributes(attributes: IconAttributes): IconAttributes;
|
||||
export function formatAttributes(attributes: IconAttributes): string;
|
||||
export function toString(descriptor?: Descriptor): string;
|
||||
export function toSvg(descriptor?: Descriptor): SVGSVGElement;
|
||||
19
types/carbon__icon-helpers/tsconfig.json
Normal file
19
types/carbon__icon-helpers/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6", "DOM"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@carbon/icon-helpers": ["carbon__icon-helpers"]
|
||||
}
|
||||
},
|
||||
"files": ["index.d.ts", "carbon__icon-helpers-tests.ts"]
|
||||
}
|
||||
1
types/carbon__icon-helpers/tslint.json
Normal file
1
types/carbon__icon-helpers/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user