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

[v4] [icons] fix: restore support for old IconName keys #4945

Merged
merged 2 commits into from
Oct 1, 2021

Conversation

adidahiya
Copy link
Contributor

Changes proposed in this pull request:

Restore support for icon names access via IconNames.ERROR, while retaining support for the new syntax (IconNames.Error).

This breaking change happened as a result of the switch to fantasticon as the icon build tool, and although IMO it looks cleaner with the pascal case syntax, the costs of this breaking change (thousands of lines of meaningless code diff) outweigh the benefits of the code looking ever so slightly cleaner.

Originally I thought I would be able to accomplish this using a custom fantasticon template (similar to how we have scss and css templates), but it turns out that ts templates are unsupported. So instead I had to resort to some hacky type mapping...

Reviewers should focus on:

The type hacks are not very pretty, but they don't really get expose to consumers in their TS build, so I think it's ok...

Screenshot

N/A

@blueprint-bot
Copy link

[v4] [icons] fix: restore support for old IconName keys

Previews: documentation | landing | table | modern colors demo


/**
* This is a hacky implementation of a camelCase to Snake_Case string literal
* type converter... it works up to 30 characters, which is fine for our
Copy link
Contributor

Choose a reason for hiding this comment

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

is there somewhere closer to where icons are defined that we should mention this 30 character limit?

Copy link
Contributor Author

@adidahiya adidahiya Oct 1, 2021

Choose a reason for hiding this comment

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

not really 😅 it's up to the icons reviewer (me) to enforce it.

to be fair though, it only affects the older naming convention... if you have a new icon added to the set and it's greater than 30 chars... nothing will really break, you just won't be able to reference it as IconNames.SOMETHING_VERY_LONG_NOT_SURE_WHY_IM_SCREAMING... you'll just need to simmer down and use pascal case

Copy link
Contributor

Choose a reason for hiding this comment

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

ha ok. in fairness, prefer just using the string literal anyway

@blueprint-bot
Copy link

change-case is now a regular dependency

Previews: documentation | landing | table | modern colors demo

@adidahiya adidahiya merged commit 87dd509 into next Oct 1, 2021
@adidahiya adidahiya deleted the ad/v4-revert-icon-name-break branch October 1, 2021 19:36
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