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(EmptyState): support icons passed directly to EmptyStateHeader #612

Merged
merged 5 commits into from
Mar 27, 2024

Conversation

adamviktora
Copy link
Contributor

Uses helpers from #602 which should be merged first before this PR.

Closes #595

Copy link
Collaborator

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

Lookin 🔥!

I just have one type question and a small refactor request.

};

const emptyStateIconComponent = iconPropIsEmptyStateIconComponent()
? (iconPropValue as JSXElement)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this type assertion definitely valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is quite indirect, but the iconPropIsEmptyStateIconComponent function also checks that iconElementIdentifier is not undefined, which is true when iconPropValue?.type === "JSXElement".

Copy link
Collaborator

Choose a reason for hiding this comment

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

What if there is no EmptyStateIcon import? Would that cause emptyStateIconImport to be undefined and iconPropIsEmptyStateIconComponent to incorrectly return true (since undefined === undefined is true)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, good catch, that could cause some trouble, thanks for finding that!

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's what I'm here for! 🙂

Comment on lines 192 to 196
? context
.getSourceCode()
.getText(emptyStateIconComponentIconAttribute)
: iconPropIsIconElement()
? `icon={${iconElementIdentifier!.name}}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way to refactor this logic to avoid the nested ternary?

@thatblindgeye thatblindgeye merged commit b5d2340 into patternfly:main Mar 27, 2024
3 checks passed
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.

EmptyState - support icons passed directly to EmptyStateHeader
3 participants