-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support SAPBusinessSuite icons v1 and v2 font ( Horizon ) (#6535)
* feat: support business icons v1 and v2 font ( Horizon )
- Loading branch information
Showing
13 changed files
with
1,244 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 13 additions & 5 deletions
18
packages/icons-business-suite/src/json-imports/Icons-static.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
import { registerIconLoader, CollectionData } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js"; | ||
|
||
import SAPIconsBusinessSuiteUrl from "../generated/assets/SAP-icons-business-suite.json"; | ||
import SAPIconsBusinessSuiteUrlV1 from "../generated/assets/v1/SAP-icons-business-suite.json"; | ||
import SAPIconsBusinessSuiteUrlV2 from "../generated/assets/v2/SAP-icons-business-suite.json"; | ||
|
||
const loadIconsBundle = async (): Promise<CollectionData> => { | ||
if (typeof SAPIconsBusinessSuiteUrl === "object") { | ||
const loadIconsBundle = async (collection: string): Promise<CollectionData> => { | ||
if (typeof SAPIconsBusinessSuiteUrlV1 === "object" || typeof SAPIconsBusinessSuiteUrlV2 === "object") { | ||
// inlined from build | ||
throw new Error("[icons-business-suite] Inlined JSON not supported with static imports of assets. Use dynamic imports of assets or configure JSON imports as URLs"); | ||
} | ||
return (await fetch(SAPIconsBusinessSuiteUrl)).json(); | ||
|
||
const iconsUrl: string = collection === "business-suite-v1" ? SAPIconsBusinessSuiteUrlV1 : SAPIconsBusinessSuiteUrlV2; | ||
return (await fetch(iconsUrl)).json(); | ||
} | ||
|
||
registerIconLoader("business-suite", loadIconsBundle); | ||
const registerLoaders = () => { | ||
registerIconLoader("business-suite-v1", loadIconsBundle); | ||
registerIconLoader("business-suite-v2", loadIconsBundle); | ||
}; | ||
|
||
registerLoaders(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
import { registerIconLoader, CollectionData } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js"; | ||
|
||
const loadIconsBundle = async (): Promise<CollectionData> => { | ||
const iconData = (await import("../generated/assets/SAP-icons-business-suite.json")).default; | ||
if (typeof iconData === "string" && (iconData as string).endsWith(".json")) { | ||
throw new Error("[icons-business-suite] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build or use `import \"@ui5/webcomponents-icons-business-suite/dist/Assets-static.js\". Check the \"Assets\" documentation for more information."); | ||
} | ||
return iconData; | ||
const loadIconsBundle = async (collection: string): Promise<CollectionData> => { | ||
let iconData: CollectionData; | ||
|
||
if (collection === "business-suite-v1") { | ||
iconData = (await import(`../generated/assets/v1/SAP-icons-business-suite.json`)).default; | ||
} else { | ||
iconData = (await import(`../generated/assets/v2/SAP-icons-business-suite.json`)).default; | ||
} | ||
|
||
if (typeof iconData === "string" && (iconData as string).endsWith(".json")) { | ||
throw new Error("[icons-business-suite] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build or use `import \"@ui5/webcomponents-icons-business-suite/dist/Assets-static.js\". Check the \"Assets\" documentation for more information."); | ||
} | ||
return iconData; | ||
} | ||
|
||
registerIconLoader("business-suite", loadIconsBundle); | ||
const registerLoaders = () => { | ||
registerIconLoader("business-suite-v1", loadIconsBundle); | ||
registerIconLoader("business-suite-v2", loadIconsBundle); | ||
}; | ||
|
||
registerLoaders(); |
Oops, something went wrong.