DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
224 stars 79 forks source link

How to customize TwitterBootstrap MVC HTML Helpers with additional css classes? #442

Open kfinke70 opened 7 years ago

kfinke70 commented 7 years ago

We're working on a project with TwitterBootstrapMVC and we wish to incorporate Google's material design. We've found a nice bootstrap / material implementation: http://fezvrasta.github.io/bootstrap-material-design/.

However, in order to harness the power of this material framework we'd like to add css classes to certain things. For example, a FormGroup() might need to be extended with label-floating and has-warning. We would like to extend or customize some of the default behavior of the TwitterBootstrapMVC extensions.

How should we go about that?

DmitryEfimenko commented 7 years ago

The .FormGroup() has an extension method .Class() so you can apply any class to the wrapping <div class="form-group"...

As far as extensions go, you can extend things in BMVC to a certain degree. See #436 for an example. It might or might not be sufficient for you.

If you require more involved changes, purchasing BMVC's source code might be an option. Some companies have done that. If that option interests you, please contact me via email.

kfinke70 commented 7 years ago

Sorry, I should have mentioned that I know about the .Class() method.

This is the beginning of a port of a huge application to the web. There will be literally thousands of fields. Tens of thousands! For maintainability, brevity, and consistency I would love to make the default behavior of each control the way we want it.

I really don't want to fork the code. You seem to be actively maintaining it and extending it. However, I also don't see any good ways to simply extend it. If I subclass something, say BootstrapControlGroupBase, I would then have to start adding duplicate extension methods, etc. It could get ugly quickly.

Perhaps we could customize it from within? Say for example a way to provide you with default css classes?

DmitryEfimenko commented 7 years ago

We could try add this via adding keys to appSettings similar to how it's done for label position. Something like:

<add key="BMVC.Globals.FormGroup.ExtraCssClass" value="label-floating" />

If you like this approach, please let me know all use cases which you'd require (anything besides FormGroup?)