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

"Alert" + "Toast" components - Finalize implementation in code (feature branch) #245

Merged
merged 165 commits into from
May 11, 2022

Conversation

didoo
Copy link
Contributor

@didoo didoo commented Apr 25, 2022

📌 Summary

This is the "feature branch" used to finalize the implementation of the Alert and Toast components. The implementation of these components has not followed the usual process (for [reasons]) so it's a single large PR for both the components. This PR contains the previous #56 and #91, and the follow-up changes were merged directly in this branch (for development convenience).

🛠️ Detailed description

This PR contains these changes.

Alert

  • added the Alert component (HTML/HBS + JS + CSS)
  • added the documentation for the Alert component - page preview here
  • added testing (Percy + integration) for the Alert component

Toast

  • added the Toast component (HBS + CSS) as specialized Alert(inline) instance
  • added the documentation for the Toast component - page preview here
  • added testing (Percy + integration) for the Toast component

👩‍🔧 Things to know

Alert & Toast

At the beginning there was a single component, Alert, that covered all the possible types of notification (Page, Inline, Compact and Toast). Later in the process, it was decided to "extract" the Toast in a distinct component, for many reasons (among them, it was much easier to write documentation, because these two kind of notifications have very different usages, logics, etc).

The Toast component in Figma is a distinct component, in a distinct page.

Similarly in code the Toast component is a distinct component, with a distinct documentation page. But under the hood is just using the Hds::Alert(Inline) component (with just a couple of extra styles in CSS).

APIs

There have been a few back & forth around the API for the component, in particular around using named blocks and/or contextual components (see for example this discussion: #104).

When we tested the integration of the components in Cloud UI (see below) we run into a few issues around how Ember was treating whitespace and yielded components inside named blocks, see these threads for more details:

You can see a writeup of what we did and what we learned in the process here: #104 (comment)

At the end we decided to get rid of the named blocks, and use only contextual components, to avoid (part of) these problems (and follow the same code pattern used in the dropdown).

Spike for adoption test in Cloud UI

We did a spike to test the integration of the Hds::Alert and Hds::Test components in Cloud UI, to reduce as much as possible friction in the adoption phase. You can see the results of this test here: https://github.com/hashicorp/cloud-ui/pull/2429

🔗 External links


👀 How to review

👉 Review by files changed (don't even try to go commit by commit :) )

Reviewer's checklist:

  • +1 Percy if applicable
  • Confirm that PR has a changelog update via Changesets if needed

💬 Please consider using conventional comments when reviewing this PR.

amyrlam and others added 30 commits March 21, 2022 19:07
Made tweaks along the way:
-Change title to required, body optional
- Clarify icon is set at 24
Was debugging the failed test
From looking at the other components, we don't want to include <p> (and makes sense with all the globals on <p> e.g. in cloud-ui)
Made tweaks along the way:
-Change title to required, body optional
- Clarify icon is set at 24
Was debugging the failed test
@vercel vercel bot temporarily deployed to Preview – hds-flight-website May 6, 2022 13:55 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components May 6, 2022 13:56 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-flight-website May 6, 2022 14:04 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components May 6, 2022 14:04 Inactive
assert.dom('.flight-icon-alert-diamond').exists();
});

test('if an icon is declared, the icon should render in the component and override the default one', async function (assert) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[suggestion] should there be a test here to ensure that the "Default one" renders?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the previous test ('it should render an icon by default depending on the type and color')

assert.dom('.hds-alert__title').hasText('This is the title');
assert.dom('.hds-alert__description').hasText('This is the description');
});
test('it should render rich HTML when the @description argument contains HTML tags', async function (assert) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[comment] I'm surprised that we are even offering this.

Copy link
Contributor Author

@didoo didoo May 6, 2022

Choose a reason for hiding this comment

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

[comment] I'm surprised that we are even offering this.

we have multiple of this cases in the audit, we have to support them. and we're (more correctly, we'll be) supporting basic HTML elements like a, strong, em, code (see CSS and comments)

….hbs

Co-authored-by: Melanie Sumner <melanie@hashicorp.com>
@vercel vercel bot temporarily deployed to Preview – hds-components May 6, 2022 18:06 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-flight-website May 6, 2022 18:06 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-flight-website May 6, 2022 18:08 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components May 6, 2022 18:09 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-flight-website May 9, 2022 13:06 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components May 9, 2022 13:06 Inactive
@didoo didoo requested a review from cveigt May 9, 2022 13:06
Co-authored-by: Christian Veigt <cveigt@gmail.com>
@vercel vercel bot temporarily deployed to Preview – hds-components May 10, 2022 12:50 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-flight-website May 10, 2022 12:50 Inactive
Copy link
Contributor

@MelSumner MelSumner left a comment

Choose a reason for hiding this comment

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

I think this is good enough to ship, let's keep an eye out for how the accessibility shakes out when it's implemented. 👍

Copy link
Contributor

@cveigt cveigt left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@didoo didoo merged commit 0210b99 into main May 11, 2022
@didoo didoo deleted the alert/finalize-implementation branch May 11, 2022 11:10
@Dhaulagiri Dhaulagiri mentioned this pull request May 11, 2022
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.

7 participants