From 7eae3e0c702005920b8a5a6b21f42b926739a7d2 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 18 Jan 2024 14:15:46 +0100 Subject: [PATCH] frontend-plugin-api: added IconsApi Signed-off-by: Patrik Oldsberg --- .changeset/flat-wasps-fold.md | 5 +++ packages/frontend-plugin-api/api-report.md | 13 +++++++ .../src/apis/definitions/IconsApi.ts | 38 +++++++++++++++++++ .../src/apis/definitions/index.ts | 1 + 4 files changed, 57 insertions(+) create mode 100644 .changeset/flat-wasps-fold.md create mode 100644 packages/frontend-plugin-api/src/apis/definitions/IconsApi.ts diff --git a/.changeset/flat-wasps-fold.md b/.changeset/flat-wasps-fold.md new file mode 100644 index 0000000000..653dc0d78f --- /dev/null +++ b/.changeset/flat-wasps-fold.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-plugin-api': patch +--- + +Added initial `IconsApi` definition. diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index 1d42d8bab8..fd0e1302b7 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -976,6 +976,19 @@ export type IconComponent = ComponentType< } >; +// @public +export interface IconsApi { + // (undocumented) + getIcon(key: string): IconComponent | undefined; + // (undocumented) + listIconKeys(): { + keys: Iterable; + }; +} + +// @public +export const iconsApiRef: ApiRef; + export { IdentityApi }; export { identityApiRef }; diff --git a/packages/frontend-plugin-api/src/apis/definitions/IconsApi.ts b/packages/frontend-plugin-api/src/apis/definitions/IconsApi.ts new file mode 100644 index 0000000000..daef2ca40f --- /dev/null +++ b/packages/frontend-plugin-api/src/apis/definitions/IconsApi.ts @@ -0,0 +1,38 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createApiRef } from '@backstage/core-plugin-api'; +import { IconComponent } from '../../icons'; + +/** + * API for accessing app icons. + * + * @public + */ +export interface IconsApi { + getIcon(key: string): IconComponent | undefined; + + listIconKeys(): { keys: Iterable }; +} + +/** + * The `ApiRef` of {@link IconsApi}. + * + * @public + */ +export const iconsApiRef = createApiRef({ + id: 'core.icons', +}); diff --git a/packages/frontend-plugin-api/src/apis/definitions/index.ts b/packages/frontend-plugin-api/src/apis/definitions/index.ts index f2496ee61a..c0a2101db0 100644 --- a/packages/frontend-plugin-api/src/apis/definitions/index.ts +++ b/packages/frontend-plugin-api/src/apis/definitions/index.ts @@ -40,6 +40,7 @@ export * from './DiscoveryApi'; export * from './ErrorApi'; export * from './FeatureFlagsApi'; export * from './FetchApi'; +export * from './IconsApi'; export * from './IdentityApi'; export * from './OAuthRequestApi'; export * from './StorageApi';