-
Notifications
You must be signed in to change notification settings - Fork 31
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(Alert): add Alert component which uses @digdir/design-system-react #1289
Conversation
369162f
to
09b2fda
Compare
I see that I might need to update this PR and split out the schema for |
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 work! 🏅 Just a thought about the useAsAlert
property name 😁
src/layout/Alert/types.d.ts
Outdated
|
||
export interface ILayoutCompAlertBase { | ||
severity: AlertSeverity; | ||
useAsAlert?: boolean; |
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 feel this property maybe needs a new name as the components name is Alert
. 🤔 What about useAriaLive
or something similar?
Side thought that might not work: Maybe it is possible to check if the Alert components required
property in the layout file contains a boolean value or an expression(which is written as a string) and set this value to true
if an expression is used?
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.
Agree! 💯 But I assume you mean the hidden
property? An Alert
is not a form component, so it cannot have any functionality for required
.
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.
@olemartinorg, Yes thats what i meant! Sorry 😄
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.
Yeah that seems like a good idea. I'll see if that is possible 😅
This has a striking resemblance to the Also, this reminds me of #1023, which we closed because we wanted to introduce validations using expressions instead via #726. Does this Alert component have to be a component, or the use-case really just the same as soft validations? In that case, I think we should probably consider updating the visuals for the soft validations instead of making a new component. |
Thanks for the feedback! Regarding #1023 @Febakke was involved in the startup meeting of this new component, and I think we said that this new component should take over the role of Panel in displaying messages which appear as some sort of user input. Please correct me if I am wrong here @Febakke This component could also be used to display static messages which do not appear/disappear based on user input. Soft validations seem to me like they only appear as a validation message whenever the user provides some input. Maybe we should have a chat about this component again @Febakke @olemartinorg @Magnusrm |
I see! 🤔
The
Ah, yes - so Maybe implementing an 'initial' trigger for validations could be an alternative (worryingly, validation messages disappear right now if you refresh the app, and you won't get them back until you hit a trigger), or reworking the way triggers on validations work could be another option. Tagging @RonnyB71 as well. |
The thinking is that For instance, in our specific use case in DGM we want to display this piece of extra information to the users when they select "Ja, jeg har informert de andre etterlatte", even though this is not a validation message.
Yes, In any case, it seems we need to discuss this component a little more in detail before we introduce it to the codebase. |
@olemartinorg Alert NB: I see that NAV has changed their documentation to say that you should not give the alert component: Summary:
Panel The panel should be a grouping of elements that make it stand out from the rest of the page. It has no limitations on what it can contain. Example of uses, highlight parts of a paragraph you want to stand out or grouping form components with a text that is relevant. The color should only be a stylistic choice, it should not inform the user of a grade of severity. If it is presented to the user with dynamics it might need a I have to 🏃, but there is also some overlap with soft validations that I have to think about in this context. |
After a discussion in todays daily meeting, we have decided that we will introduce the new |
4c9dd43
to
625b5e1
Compare
Kudos, SonarCloud Quality Gate passed! |
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 work! This looks good to me 🚀
…'hidden' property is set
625b5e1
to
8bed79d
Compare
Kudos, SonarCloud Quality Gate passed! |
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.
Looks good, thank you! 🚀
Description
Added a new
Alert
component, with options forseverity
- sets the style of the alert, and has four valid values"success" | "info" | "danger" | "warning"
.title
- sets the title viatextResourceBindings
.description
- sets the description viatextResourceBindings
.This option is removed and rather determined automatically based on theuseAsAlert
- A boolean which specifies whether the component should haverole="alert"
or not. It should not have this for static elements displaying information, but should have it for dynamic elements that appear after a certain user input. I currently implemented thearia-live
attribute withpolite
, but I think maybe this should be configurable. Or maybe it should be based on severity label. ifuseAsAlert
is set, andseverity
is >=warning
,aria-live
should be set toassertive
.hidden
property ofGenericComponent
. Ifhidden
is explicitly set tofalse
we appendrole="alert"
to theAlert
component. There is however one problem with this. If an element is hidden with an expression, but the expression evaluates tofalse
on page load,role="alert"
will be appended to theAlert
component on load. The same problem would exist for the old API, where the app developers used auseAsAlert
flag.Screenshot:
Related Issue(s)
Verification/QA
@testing-library/cypress
selectors for testing the content of alert messages instead.src/layout/layout.d.ts
andlayout.schema.v1.json
, and these are all backwards-compatiblekind/*
label to this PR for proper release notes grouping