Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: New Component SiteAlert #1099
feat: New Component SiteAlert #1099
Changes from 14 commits
ac34b15
c1d88db
8fa9302
379cbbf
46bd6f7
255d10d
61f326a
1fcd8f3
6d06203
08f2d38
a1d396d
bf5355b
c90bd6a
5454a4e
d1c50cc
0f0cdb2
69737ff
6f658dd
2b66fcf
87de42f
bb32c87
c164a87
8aab95c
6e1db38
eb7d678
485b301
7315713
a1e709f
9a023c6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
At initial glance, this
<p>
is something I would want to encapsulate similar to #1100 (generifying theusa-alert__text
class into anAlertText
component could be used for a child of both Alert and SiteAlert). That can be an enhancement.I'm also thinking about how Alert (which is very similar) is very rigid, while SiteAlert has this flexible approach. I think the
SiteAlert
approach is in line with our current design philosophy.Does that then mean we should add a backlog item for a breaking release where we change
Alert
to be a bit more flexible like SiteAlert, and allow things like lists to be passed in? Mostly just thinking out loud and noticing some things that would be nice for us to decide how to be consistent about.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.
Good call out. Another idea: I could see the children of
SiteAlert
(and honestlyAlert
as well) accepting children of typestring | JSX.element
. If a string is passed in we put the string in a<p>
tag with theusa-alert
class) but if a component is passed in we just display that component. What do folks think of that approach?In terms of refactoring Alert - I think that could be a good task for the backlog. It probably should be handling flexible content. Right now it uses the
validation
prop to adjust classes but also to be more flexible (validations are lists) which is quite weird. I think I wrote that code too 😆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.
I like that approach! We might need to expand to accept
string | JSX.Element | JSX.Element[]
in the event of multiple child elements.I think the only advantage of making the
<AlertText />
subcomponent is for the scenario where someone wanted to do something like:The
string | JSX.Element | JSX.Element[]
approach doesn't preclude that so we could proceed that route and always leaveAlertText
as an enhancement should the need arise.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.
Nice.
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.
Suggestion: This test could include a check that the heading text is indeed rendered. Right now we just check that a heading exists, but not its text content.
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.
ooo and a quick follow up on these lines since I didn't notice on my first pass:
@SirenaBorracha if you ever find yourself doing
getBy___
orqueryBy___
for the same thing multiple times in a test you can factor that out into a const, e.g:I'm not sure if the performance impact of querying the dom for a specific element is high, but its an easy optimization we can do to keep the tests efficient.