Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(framework): support theme dependent custom icon collections #7341

Merged
merged 4 commits into from
Aug 1, 2023

Conversation

ilhan007
Copy link
Member

@ilhan007 ilhan007 commented Jul 18, 2023

The PR aims to add support for registering versioned/theme dependent custom icon collections.

Previously, one could register an icon collection (f.e. "my-icons") with the use of registerIconLoader and use it with the Icon web component:

<ui5-icon name="my-icons/home">

However, there is no API to register theme dependant version of the same icon, so that whenever the theme is changed the used SVGs are auto-switched behind the scenes.

Proposal
The markup remains the same, so that no changes will be required in the icon usage.

<ui5-icon name="my-icons/home">

-registerIconLoader now can be used to register additional second version (won't fail in case of multiple versions, but at the end the separation is "legacy" vs "sap_horizon" theme families) and use the newly supported field "themeFamily" to define in which themeFamily the icon collection should be used. If "themeFamily" is not present, by default it means in all themes (sap_belize_, sap_fiori_3_) other than "sap_horizon" theme families.

registerIconLoader("my-icons", () => {
	return Promise.resolve([{
		"collection": "my-legacy-icons",
		"packageName": "test",
		"data": {
			"mark": {
				
			},
		},
	},
	{
		"collection": "my-horizon-icons",
		"packageName": "test",
		"themeFamily": "sap_horizon",
		"data": {
			"mark": {
			
			},
		},
	}]);
});

*collection (my-legacy-icons, my-horizon-icons) is the name under we will internally store the icon collection

Flow
my-icons/home is set, if sap_fiori_3 is set, effectively show my-legacy-icons/home
my-icons/home is set, if sap_ horizon is set, effectively show my-horizon-icons/home

Fixes: #7312

@ilhan007 ilhan007 changed the title feat(framework): support theme dependant custom icon collections POC(framework): support theme dependant custom icon collections Jul 18, 2023
@ilhan007 ilhan007 marked this pull request as draft July 18, 2023 15:02
@ilhan007 ilhan007 changed the title POC(framework): support theme dependant custom icon collections feat(framework): support theme dependant custom icon collections Jul 26, 2023
@ilhan007 ilhan007 marked this pull request as ready for review July 26, 2023 05:22
@ilhan007 ilhan007 closed this Jul 26, 2023
@ilhan007 ilhan007 reopened this Jul 26, 2023
@ilhan007 ilhan007 changed the title feat(framework): support theme dependant custom icon collections feat(framework): support theme dependent custom icon collections Jul 26, 2023
@ilhan007 ilhan007 merged commit 33967dd into main Aug 1, 2023
@ilhan007 ilhan007 deleted the feat-register-versioned-custom-icon-collections branch August 1, 2023 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: support auto-switch for versioned custom icon SVGs based on the current theme
2 participants