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: allow passing in only icon SVG data to addIcons #1256

Merged
merged 6 commits into from
Aug 22, 2023

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Aug 21, 2023

See https://github.com/ionic-team/ionic-framework-design-documents/commit/a12daf314e9fdd6619503e88e9c99d2c184d95b7

This feature allows developers to pass icons to the icon map without explicitly setting the string name. This cuts down on boilerplate and reduces the likelihood of mapping the icon to a typo (i.e. "log-ionic" instead of "logo-ionic")

For backwards compatibility purposes, the camel case key will still be available for developers who are explicitly mapping icon SVG data to camel case keys.

As part of this, Ionicons will now warn if multiple icons are mapped to the same key. TypeScript should prevent devs from explicitly doing this in Objects, but by autogenerating keys this may happen without the developer knowing. A warning will be logged so devs are aware of when this happens.

Usage

/**
 * Yields "logo-ionic" and "logoIonic" keys in the map
 */
addIcons({ 'logoIonic': logoIonic });

/**
 * Yields "logo-ionic" key in the map
 */
addIcons({ 'logo-ionic': logoIonic });

/**
 * Yields "logo-ionic" and "logoIonic" keys in the map
 */
addIcons({ logoIonic });

/**
 * "logo-a" key maps to logoB object, and a warning is logged for the logoA object.
 */
addIcons({ 'logo-a': logoB, logoA });

@liamdebeasi liamdebeasi changed the title Icon map kebab feat: allow passing in only icon SVG Data to addIcons Aug 21, 2023
@liamdebeasi liamdebeasi changed the title feat: allow passing in only icon SVG Data to addIcons feat: allow passing in only icon SVG data to addIcons Aug 21, 2023
@liamdebeasi liamdebeasi requested review from a team and thetaPC and removed request for a team and thetaPC August 21, 2023 14:39
@liamdebeasi liamdebeasi marked this pull request as draft August 21, 2023 14:40
@liamdebeasi liamdebeasi marked this pull request as ready for review August 21, 2023 14:50
@liamdebeasi liamdebeasi requested review from a team and brandyscarney and removed request for a team August 21, 2023 15:00
src/components/icon/utils.ts Outdated Show resolved Hide resolved
@sean-perkins sean-perkins changed the base branch from main to feature-7.2 August 21, 2023 20:04
@sean-perkins
Copy link
Contributor

Updated the base branch to target a feature-7.2 branch so we can group updates for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants