Blazored / Menu

A JavaScript free menu library for Blazor and Razor Components applications.
https://blazored.github.io/Menu
MIT License
176 stars 32 forks source link

Menu images? #16

Open ZedZipDev opened 4 years ago

ZedZipDev commented 4 years ago

How to use images in menu like menu in the VS2019 Blazor default app?

i.e. how to add images in this sample?

<BlazoredMenu MenuBuilder="@MenuBuilder" />
@functions {
    MenuBuilder MenuBuilder = new MenuBuilder();

    protected override void OnInit()
    {
        MenuBuilder.AddItem(1, "Home", "/")
                   .AddSubMenu(2, "Sub Menu", new MenuBuilder().AddItem(1, "Counter", "counter")
                   .AddItem(3, "FetchData", "fetchdata");
    }
}
chrissainty commented 4 years ago

We don't have support for this feature right now. But I can add it to the backlog, this library needs some time spent on it but I've just not had the chance for a while.

ZedZipDev commented 4 years ago

Thank you @chrissainty , it will be good feature

ThaRaven403 commented 4 years ago

@chrissainty did you have an idea of how images could be integrated?

A first step could be to support a string specifying the icon class(es) to use that would add a span. But I could see this going in all directions with custom markup, svg images, and so on...

There's also the question of positioning the icon. Again, default could be on the left of the text, but customization could go far here also.

I'd be interested in working on this one (more work than small bug fixes for a change 😂), but I'd like to confirm your vision on this.

chrissainty commented 4 years ago

Hey @ThaRaven403 - If I'm honest I've not had the chance to give it any thought. This library is in desperate need of some TLC and probably needs a full redesign as it's not really been touched since I built it. Do you have any thoughts on it?

ThaRaven403 commented 4 years ago

@chrissainty Maybe going full blown on the builder pattern would help. With individual builder properties for each of the menu settings, it would then be easy to then build it using a certain logic depending on what options you set. Like with any builder, someone could go and add a SVG and icon class for example, but the build method could manage that and the behavior would be self explanatory.

And with that in place, it would be easy to add new features without revamping the whole thing; only a new builder method, the implementation in the Build and the HTML.

(edited to tag you, didn't know if notifications are going through)

chrissainty commented 4 years ago

@ThaRaven403 Sounds good. I'm happy for you to take the lead on this if you want to?

ThaRaven403 commented 4 years ago

@chrissainty I'd be glad to!