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

[MessageBar] Add an optional toggle for the fade in animation. #2716

Merged
merged 6 commits into from
Sep 26, 2024

Conversation

yspanj
Copy link
Contributor

@yspanj yspanj commented Sep 25, 2024

Pull Request

πŸ“– Description

Add a options to disable the animation in the MessageBar component.

πŸ‘©β€πŸ’» Reviewer Notes

πŸ“‘ Test Plan

Existing message bar tests have been updated with the new animation CSS class. And a new test has been added.

βœ… Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

  • I have added a new component
  • I have added Unit Tests for my new component
  • I have modified an existing component
  • I have validated the Unit Tests for an existing component

⏭ Next Steps

Enhanced the FluentMessageBar component by adding the
`fluent-messagebar-animation` class to `div` elements with the
`fluent-messagebar` class across multiple test files. Updated
`FluentMessageBar_AllowDismiss.verified.html`,
`FluentMessageBar_Default.verified.html`,
`FluentMessageBar_DisableFadeIn.verified.html`, and
`FluentMessageBar_WithId.verified.html` to reflect this change.

Added a new `div` structure for the `fluent-messagebar` in
`FluentMessageBarTests.FluentMessageBar_DisableFadeIn.verified.html`.

Introduced a new test method `FluentMessageBar_DisableFadeIn` in
`FluentMessageBarTests.cs` to verify the component's behavior with
the `FadeIn` parameter set to `false`.

Included MIT License and copyright information at the top of
`FluentMessageBarTests.cs`.
@yspanj
Copy link
Contributor Author

yspanj commented Sep 25, 2024

@yspanj please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term β€œYou” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@dvoituron
Copy link
Collaborator

Great work.

Just a quick discussion on "how the browser can detect when to apply the animation?".
In general, I prefer to use an HTML element attribute like this. I found the code cleaner and easier for future updates.
What are your thoughts?

<div class="fluent-messagebar intent-info" animation="fadein">
   ...
</div>
.fluent-messagebar[animation="fadein"] {
  animation: fadein 1.5s;
}

@yspanj
Copy link
Contributor Author

yspanj commented Sep 25, 2024

animation

Thanks!

I agree that the HTML element attribute looks cleaner. But I think that that would resolve in a bigger change is how the components is created.

Are you thinking about implementing something like an AnimationBuilder similar to the CssBuilder? Or am I missing something that's already in the library that can be used for this?

@dvoituron
Copy link
Collaborator

Are you thinking about implementing something like an AnimationBuilder similar to the CssBuilder? Or am I missing something that's already in the library that can be used for this?

No, nothing exists about that. And I don't think we need to use an AnimationBuilder: FluentUI Blazor uses the WebComponents which will do this part.

A MessageBar is a component to "Communicates important information about the state of the entire application". By default, it is not necessary to display an animated message like explained in the FluentUI React components. Probably a difference between the Toast.

But we already display the MessageBar using this animation :-(
Si I think the code should be clean (using a attribute) and keeping the existing behavior (FadeIn=true like you did).

@vnbaaij
Copy link
Collaborator

vnbaaij commented Sep 26, 2024

@yspanj we are pulling this PR in now so it will be available in v4.10.1.

Please submit a follow-up PR to change the behavior to use an attribute so we can include that for a later version. Thanks!

I agree that the HTML element attribute looks cleaner. But I think that that would resolve in a bigger change is how the components is created.

Are you thinking about implementing something like an AnimationBuilder similar to the CssBuilder? Or am I missing something that's already in the library that can be used for this?

You can just set the attribute to the fadein value if the parameter is true and otherwise make it null. Empty attributes won't be rendered. Something like:

<div class="fluent-messagebar intent-info" animation="@( FadeIn ? "fadein" : null )">
   ...
</div>

@vnbaaij vnbaaij added this to the v4.10.1 milestone Sep 26, 2024
@vnbaaij vnbaaij merged commit 5d57a1b into microsoft:dev Sep 26, 2024
4 checks passed
@yspanj
Copy link
Contributor Author

yspanj commented Sep 26, 2024

@yspanj we are pulling this PR in now so it will be available in v4.10.1.

Please submit a follow-up PR to change the behavior to use an attribute so we can include that for a later version. Thanks!

I agree that the HTML element attribute looks cleaner. But I think that that would resolve in a bigger change is how the components is created.
Are you thinking about implementing something like an AnimationBuilder similar to the CssBuilder? Or am I missing something that's already in the library that can be used for this?

You can just set the attribute to the fadein value if the parameter is true and otherwise make it null. Empty attributes won't be rendered. Something like:

<div class="fluent-messagebar intent-info" animation="@( FadeIn ? "fadein" : null )">
   ...
</div>

Thanks.
Opened the pull request #2723 for this.

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