-
Notifications
You must be signed in to change notification settings - Fork 72
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
[Enhance] Implement Validation for Icon Input Source & Set Default Icon to Beaker
#1137
[Enhance] Implement Validation for Icon Input Source & Set Default Icon to Beaker
#1137
Conversation
Signed-off-by: Willie Hung <[email protected]>
694e481
to
303d5a4
Compare
Signed-off-by: Willie Hung <[email protected]>
Signed-off-by: Willie Hung <[email protected]>
Signed-off-by: Willie Hung <[email protected]>
Signed-off-by: Willie Hung <[email protected]>
8487f6f
to
80a1741
Compare
Signed-off-by: Willie Hung <[email protected]>
Beaker
Beaker
// Category 1: cached oui icons | ||
if (isCachedIcon(type)) { | ||
initialIcon = iconComponentCache[type as string]; | ||
// Category 2: URL (relative, absolute) | ||
} else if (isUrl(type)) { | ||
initialIcon = type; | ||
// Category 3: non-cached oui icon or new icon | ||
} else if (typeof type === 'string') { | ||
isLoading = true; | ||
this.loadIconComponent(type); | ||
this.loadIconComponent(type as OuiIconType); | ||
} else { | ||
// Category 4: custom icon component | ||
initialIcon = type; | ||
this.onIconLoad(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be rewritten to not use a mutable variable. I'll make a followup issue, no need to worry about pushing it in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('renders custom svg from relative url', () => { | ||
const component = mount(<OuiIcon type="./assets/beaker.svg" />); | ||
expect(prettyHtml(component.html())).toMatchSnapshot(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - maybe it's better to test custom svg rendering with an asset that isn't used as a fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshuarrrr should I raise an issue so that we can revise this unit test or just leave it as it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, if you think it's a worthwhile change.
…on to `Beaker` (#1137) * Revise the logic to handle default icon Signed-off-by: Willie Hung <[email protected]> * Categorize different input icon types Signed-off-by: Willie Hung <[email protected]> * Remove unused code Signed-off-by: Willie Hung <[email protected]> * Update CHANGELOG.md Signed-off-by: Willie Hung <[email protected]> * Use readable parameter name Signed-off-by: Willie Hung <[email protected]> * Handle different input cases and add tests Signed-off-by: Willie Hung <[email protected]> --------- Signed-off-by: Willie Hung <[email protected]> Co-authored-by: Josh Romero <[email protected]> (cherry picked from commit 0d3b6cc) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
…on to `Beaker` (#1137) (#1171) * Revise the logic to handle default icon Signed-off-by: Willie Hung <[email protected]> * Categorize different input icon types Signed-off-by: Willie Hung <[email protected]> * Remove unused code Signed-off-by: Willie Hung <[email protected]> * Update CHANGELOG.md Signed-off-by: Willie Hung <[email protected]> * Use readable parameter name Signed-off-by: Willie Hung <[email protected]> * Handle different input cases and add tests Signed-off-by: Willie Hung <[email protected]> --------- Signed-off-by: Willie Hung <[email protected]> Co-authored-by: Josh Romero <[email protected]> (cherry picked from commit 0d3b6cc) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
Beaker
as the new default icon.Issues Resolved
Resolves #951
Screenshot
For demonstration purposes, when an input iconType is not present in the original
OuiIconType
, theBeaker
icon will be used as a fallback. This behavior can be tested by removing specific keys from thetypeToPathMap
dictionary manually or checkout the test I wrote.Check List
yarn lint
yarn test-unit