Skip to content

Alert component#13

Merged
albx merged 7 commits intomainfrom
feature/2-alert
Jul 10, 2025
Merged

Alert component#13
albx merged 7 commits intomainfrom
feature/2-alert

Conversation

@albx
Copy link
Owner

@albx albx commented Jul 10, 2025

This pull request introduces a new BitAlert component to the BitBlazor library, implementing a customizable alert system with various types, dismissible functionality, and support for additional content. It also includes corresponding stories and unit tests to ensure proper behavior and rendering.

New Component Implementation:

  • BitAlert Component:
    • Added the BitAlert component in BitAlert.razor and BitAlert.razor.cs, which supports different alert types (Primary, Info, Success, Warning, Danger) via the AlertType enum. It includes parameters for Title, Dismissible, CloseButtonAriaLabel, and event callbacks (OnClose, OnClosed) to handle dismissible alerts. [1] [2] [3]

User Stories:

  • Storybook Stories:
    • Added stories in BitAlert.stories.razor to demonstrate the component's usage, including examples for alert types, alerts with links, additional content, and dismissible alerts.

Testing:

  • Behavioral Tests:
    • Added unit tests in BitAlertTest.Behaviors.cs to verify OnClose and OnClosed event callbacks are triggered correctly when the close button is clicked.
  • Rendering Tests:
    • Added rendering tests in BitAlertTest.Rendering.razor to ensure the component renders correctly for different alert types, titles, dismissible functionality, and removal of markup when closed.

@albx albx requested a review from Copilot July 10, 2025 15:08
@albx albx linked an issue Jul 10, 2025 that may be closed by this pull request

This comment was marked as outdated.

@albx albx requested a review from Copilot July 10, 2025 15:23

This comment was marked as outdated.

@albx albx requested a review from Copilot July 10, 2025 16:06

This comment was marked as outdated.

@albx albx requested a review from Copilot July 10, 2025 16:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Introduces a new BitAlert component with customizable types, dismissible behavior, Title/child content support, along with accompanying Storybook stories and tests.

  • Added BitAlert component implementation (.razor & .razor.cs) with AlertType, dismissible and close event support
  • Created Storybook stories demonstrating usage scenarios
  • Built unit tests (rendering & behavioral) covering alert types, headings, close button behavior, and default aria-label

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/BitBlazor.Test/Components/Alert/BitAlertTest.Rendering.razor Rendering tests for type classes, headings, close button and removal
tests/BitBlazor.Test/Components/Alert/BitAlertTest.Behaviors.cs Behavioral tests for OnClose and OnClosed callbacks
stories/BitBlazor.Stories/Components/Stories/Components/BitAlert.stories.razor Storybook examples for default, types, links, additional content, and dismissible alerts
src/BitBlazor/Components/Alert/BitAlert.razor Razor markup for BitAlert component
src/BitBlazor/Components/Alert/BitAlert.razor.cs Component logic: CSS computation, parameter defaults, close handling
src/BitBlazor/Components/Alert/AlertType.cs Enum defining available alert types
Comments suppressed due to low confidence (3)

src/BitBlazor/Components/Alert/BitAlert.razor.cs:56

  • [nitpick] Private field dismissibleClasses should follow C# naming conventions (e.g., _dismissibleClasses).
    private List<string> dismissibleClasses = [];

src/BitBlazor/Components/Alert/BitAlert.razor.cs:56

  • Invalid C# syntax: you cannot initialize a List using []. Replace with new List<string>() or new List<string> { }.
    private List<string> dismissibleClasses = [];

src/BitBlazor/Components/Alert/BitAlert.razor.cs:65

  • Invalid C# syntax: to populate a List, use new List<string> { "alert-dismissible", "fade", "show" } instead of [].
        dismissibleClasses = ["alert-dismissible", "fade", "show"];

@albx albx merged commit 829cd3d into main Jul 10, 2025
@albx albx deleted the feature/2-alert branch July 10, 2025 16:15
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.

Add the Alert component

1 participant