Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have written a number of components for Durandal--DatePicker Widget, Tabs Widget, Radio Widget, etc. I'm having a little conceptual difficulty in how best to balance a styling API with CSS.

For example, in the Tabs Widget, I set up default css classes for the various stylable features of the widget. Those default classes come with a default styling, of course. But they can be restyled, and through the Styling API, can be renamed as well. I use this pattern in all of the components.

Now, if an end user (myself, for now) want fixed-width tab buttons, he only needs to adjust his CSS accordingly (e.g. min-width: 90px, width: 90px, etc.). But, initially, I felt compelled to include configuration properties called isTabsFixedWidth and fixedWidth. When the user passes in the configuration object, using JavaScript I modify the CSS according to properties set on that configuration object. Also, a function on the Tabs Widget called #setWidthPolicy(policy, [width]) is included.

But this seems redundant to me. What are the best practices here? Is it necessary for all styling support to include support for raw CSS, support for configurable CSS through a configuration object, and support for modifying CSS dynamically through member functions?

Does anyone have any recommendations here?

Thank you.

share|improve this question
1  
recommended reading: Why is asking a question on “best practice” a bad thing? –  gnat Mar 25 at 7:05
1  
I don't appreciate the insinuation in that post. If you don't know the answer, then don't comment. For your perusal: amazon.com/s/… –  Eric Taylor Mar 25 at 7:44
1  
There is no insinuation. @gnat is worth listening to. And your question really is very abstract. At a guess, in its current form it will get closed fairly quickly. –  david.pfx Mar 25 at 10:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.