Skip to content

Commit

Permalink
[v5] [icons] feat: make Icons.isValidIconName API public (#6219)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored Jun 14, 2023
1 parent 9be9a5f commit 0aff877
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/icons/src/iconLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ export interface IconLoaderOptions {
loader?: "webpack-lazy-once" | "webpack-lazy" | "webpack-eager" | IconPathsLoader;
}

let defaultLoader: Required<IconLoaderOptions>["loader"] = "webpack-lazy-once";

/**
* Blueprint icons loader.
*/
export class Icons {
/** @internal */
public defaultLoader: Required<IconLoaderOptions>["loader"] = "webpack-lazy-once";

/** @internal */
public loadedIconPaths16: Map<IconName, IconPaths> = new Map();

Expand All @@ -49,7 +50,7 @@ export class Icons {
*/
public static setLoaderOptions(options: IconLoaderOptions) {
if (options.loader !== undefined) {
defaultLoader = options.loader;
singleton.defaultLoader = options.loader;
}
}

Expand Down Expand Up @@ -111,7 +112,7 @@ export class Icons {
return;
}

const { loader = defaultLoader } = options;
const { loader = singleton.defaultLoader } = options;

const loaderFn =
typeof loader == "function"
Expand All @@ -138,9 +139,12 @@ export class Icons {
}
}

private static isValidIconName(icon: IconName): boolean {
/**
* @returns true if the given string is a valid {@link IconName}
*/
public static isValidIconName(iconName: string): iconName is IconName {
const allIcons: IconName[] = Object.values(IconNames);
return allIcons.indexOf(icon) >= 0;
return allIcons.indexOf(iconName as IconName) >= 0;
}
}

Expand Down

1 comment on commit 0aff877

@adidahiya
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v5] [icons] feat: make Icons.isValidIconName API public (#6219)

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Please sign in to comment.