-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Proposal: add semantic classes to datepicker directive (and possibly others as well) #2428
Comments
@TiddoLangerak I see your point but in my view overriding default templates is the best curse of action. I'm not big fan of "semantic classes" as:
I think that targeting specific elements ( Thoughts? |
Common practice to prevent this is to use a vendor prefix, just like with module names for angular. In this case we could use
Although this is true, I think this is definitely worth it. I think that about 90% of the (professional) users of this library want to customize the look and feel of the date picker, but only a very small percentage needs to customize the html. The website also advertises "A clean, flexible and fully customizable date picker.". Adding proper CSS classes vastly improves the customizability and the size overhead is minimal. (In case size is critical users can still override the templates) As a side note, adding classes might make the library bigger but it will improve rendering speed. Long selectors can have a significant performance impact on large pages since matching those elements is much harder for a browser. In real world scenarios the performance impact due to a slightly larger library will probably be smaller than the rendering penalty due to longer selectors[citation needed]. This is especially true when the templates are properly cached after initial load.
I fully agree that it should not be overdone, but that's in my opinion not a reason to not use classes. With a well designed set of classes you don't need many to allow the user to style everything.
Targeting specific elements is generally considered to be an anti-pattern. CSS best practice dictates to use classes for styling. The main reason for this is separation of concerns: when targeting specific elements such as |
+1 It would be nice if there were clear CSS classname hooks for customizing the datepicker. I do not believe http://api.jqueryui.com/theming/css-framework/
And I think if someone is serious about using this datepicker, Using @TiddoLangerak's 2nd suggestion,
|
+1 for semantic class names. At the very least a few carefully chosen elements could be chosen, and then developers could style the rest using CSS child selectors. There is still some risk of breaking that CSS if the markup structure changes in future versions, but at least those changes could be isolated within these carefully selected elements. |
+1 |
Forgot to add in commit - this is addressed by 97c4333 |
I recently wanted to style the datepicker using custom css. Unfortunately I found that styling the datepicker cannot be done cleanly. Since the datepicker only has default bootstrap classes assigned to elements there are 2 options for styling the datepicker:
[datepicker-popup-wrap] table .btn
to target the calendar buttons).The first option is fragile because it requires manually keeping the copied template up-to-date with upstream, and the second option is fragile since it gives little control and it has a very high coupling with the html structure, which again might be changed upstream.
Common practice is to include semantic class names in the html, such that these can be targeted very precisely using css only (proper separation of concerns). This technique should be applied to this directive as well.
This problem is likely not limited to the datepicker alone, but I simply have not checked the other directives.
The text was updated successfully, but these errors were encountered: