Blazor User profile component


I have always found the UI control that allows a user to manage their profile and preferences to be useful and pretty cool.

In this project, I have built this type of control in Blazor.  I think it turned out pretty nice if I say to myself.

The main feature I was looking for was just a visual UI that once clicked on, would allow the user to perform some standard actions like managing their profile settings, their application preferences,  getting help, and even logging out.

As I started designing the control, I realized that building in all the functionality for the actions would be overkill and make it hard to customize.  I solved this by making a collection of actions that can be passed in as a parameter to the control.  Each action has a link to its own page, a link to the icon image, and a title.  This makes it a lot more reusable.  

List of Actions



Alerts

If the application I am using this in has internal alerts or notifications, I wanted the feature to show the number of alerts or notifications that the user has.  It just shows the number.  You can then add an action in the list to view the alerts or notifications.


Parameters

Since I want to be able to reuse this control with minimal work, there are several parameters to help with the customization.

  1. Title => Sets the title of the dialog.  
  2. Subtitle => Sets the wording under the title.
  3. UserProfileMenuItems => the list of actions the user can take from the control.
  4. Alert Count => number of alerts to display, the red number.

        [Parameter]

        public List<UserProfileItems> UserProfileMenuItems{ get; set; }


        [Parameter]

        public int AlertCount { get; set; }


        [Parameter]

        public string Title { get; set; }

        [Parameter]

        public string SubTitle { get; set; }


Calling the Component

        <UserProfileMenu UserProfileMenuItems=items 
                         AlertCount=5
                         Title="Coding with David"
                         SubTitle="Having Blazor Fun"/>


User Interaction

Adding the user interactions was simple.  There are only 2, click on the user profile icon and click on an action in the list.

When the user clicks on the user profile icon, we just set the div class to active, and the dialog is displayed.  The user can then click on an action and the action is just an href that takes them to that action page.

Summary

Building this control was a lot easier than had anticipated it would have been.  I think it looks a lot better than the UI framework canned version as well.  I am very happy with how it turned out.







Comments

Popular posts from this blog

Yes, Blazor Server can scale!

Blazor new and improved Search Box

Blazor Wizard Step Component