Skip to content

Update d2l-alert and d2l-alert-toast to use semantic variables.#6728

Open
dbatiste wants to merge 6 commits intomainfrom
dbatiste/alert-dark-mode
Open

Update d2l-alert and d2l-alert-toast to use semantic variables.#6728
dbatiste wants to merge 6 commits intomainfrom
dbatiste/alert-dark-mode

Conversation

@dbatiste
Copy link
Copy Markdown
Contributor

@dbatiste dbatiste commented Mar 27, 2026

GAUD-9453

This PR:

  • updates d2l-alert to use semantic variables
  • updates d2l-alert-toast to use semantic variables
  • adds visual-diff tests for the dark mode

@dbatiste dbatiste requested a review from GZolla March 27, 2026 19:59
@dbatiste dbatiste requested a review from a team as a code owner March 27, 2026 19:59
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/core/pr-6728/

Note

The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

{ name: 'long-button-text-subtext', template: html`<d2l-alert-toast no-auto-close type="warning" button-text="Perform Lengthy Operation Now" open subtext="More detail explaining the critical issue.">A message.</d2l-alert-toast>` }
].forEach(({ name, template }) => {
{ name: 'long-button-text-subtext', template: html`<d2l-alert-toast no-auto-close type="warning" button-text="Perform Lengthy Operation Now" open subtext="More detail explaining the critical issue.">A message.</d2l-alert-toast>` },
{ name: 'long-button-text-subtext-dark', colorMode: 'dark', template: html`<d2l-alert-toast no-auto-close type="warning" button-text="Perform Lengthy Operation Now" open subtext="More detail explaining the critical issue.">A message.</d2l-alert-toast>` }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just added this one test here, which basically covers everything we need for dark mode d2l-alert-toast.

@dbatiste
Copy link
Copy Markdown
Contributor Author

I am purposefully not updating the shadow because the floating shadow is very slightly different and will result in a bunch of visual-diffs for toasts. I'd rather wait until shadow decisions are finalized.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines +17 to +28
{ name: 'type-default', template: html`<d2l-alert type="default">A default message.</d2l-alert>` },
{ name: 'type-default-dark', colorMode: 'dark', template: html`<d2l-alert type="default">A default message.</d2l-alert>` },
{ name: 'type-success', template: html`<d2l-alert type="success">A success message.</d2l-alert>` },
{ name: 'type-success-dark', colorMode: 'dark', template: html`<d2l-alert type="success">A success message.</d2l-alert>` },
{ name: 'type-critical', template: html`<d2l-alert type="critical">A critical message.</d2l-alert>` },
{ name: 'type-critical-dark', colorMode: 'dark', template: html`<d2l-alert type="critical">A critical message.</d2l-alert>` },
{ name: 'type-warning', template: html`<d2l-alert type="warning">A warning message.</d2l-alert>` },
{ name: 'type-warning-dark', colorMode: 'dark', template: html`<d2l-alert type="warning">A warning message.</d2l-alert>` },
{ name: 'type-error', template: html`<d2l-alert type="error">An error message.</d2l-alert>` },
{ name: 'type-error-dark', colorMode: 'dark', template: html`<d2l-alert type="error">An error message.</d2l-alert>` },
{ name: 'type-call-to-action', template: html`<d2l-alert type="call-to-action">A call to action.</d2l-alert>` },
{ name: 'type-call-to-action-dark', colorMode: 'dark', template: html`<d2l-alert type="call-to-action">A call to action.</d2l-alert>` },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is a good example of what changes if we switch to requesting multiple screenshots in the golden call (like golden({ allColorModes: true }) or whatever). Either it becomes a one word change added to the old test loop above, or the number of new tests here are cut in half.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, I think a second it on that for loop would be cleaner, unless I've missed something.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep. I was sort of on the fence about doing this. Although it doesn't make any difference in this case, I've been finding that the loops inside of loops approach to organizing tests is very inflexible. Having said that, I am content to switch it back for alerts. It was mostly out of dislike for that pattern, and also the conditionally constructing the name that would have been required.

The allColorModes idea means that in theory, if we add another color mode, there should be no changes to our test code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think a second it on that for loop would be cleaner, unless I've missed something.

Yeah, I considered that briefly too. There's like 5 different ways to do this, and something good & bad can be said about each.

Copy link
Copy Markdown
Contributor Author

@dbatiste dbatiste Mar 27, 2026

Choose a reason for hiding this comment

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

Ok, I've switched the other way (with repeated test instead of nested loop).

Copy link
Copy Markdown
Contributor

@svanherk svanherk Mar 27, 2026

Choose a reason for hiding this comment

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

The allColorModes idea means that in theory, if we add another color mode, there should be no changes to our test code.

Yeah that was my thinking. In theory, you'd only do the work of picking which tests need a second, alternative color mode screenshot once. If a new colour mode is added, you should have full test coverage from the get-go. I think this is still up for debate though, whether we'd want golden({ alts: ['allColorModes', 'rtl'] }) or more fexibility like golden({ alts: ['dark', 'vampire', 'rtl'] }). Also, do we want dark + RTL at the same time?

Anyways, looking at @GZolla's refactor PR in testing now and we're gonna try to get this in early next week. We could all meet to discuss the above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also, do we want dark + RTL at the same time?

That's a good question as it informs the golden(...) API, or however it is done. I'm struggling to think of concrete examples where I would want different color modes * RTL, but I suppose it might come up.

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