-
Notifications
You must be signed in to change notification settings - Fork 75
All: Document classes option #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
A couple general things i noticed right off. In the widget documentation, it never mentions the concept of the option, which is to map structural classes to theme classes, that might help understanding. Second in the widget documentation the auto destroy functionality is never mentioned we want to include that for sure. One thing that might help clear up the difference between keys, values, and extra along with their proper usage is to explain how we use them and the naming convention we use.
On the example of getting and setting, we want to make sure that people understand if they pass an object, it will over ride the whole option, not just the values they pass. If we add an example of a deep option getter/ setter this should help clear that up.
I think this still adds value because it avoids scrolling back and forth when your trying to understand the whole flow of the added classes stuff
Can we parse this and try to do some type checking? Kind of like what core does when you use
Yes i think we should write a single description and share on every widget it will never change |
Updated, with lots of improvements. Take a look, I think I've addressed everything you commented on. Smashed examples are still a problem. |
Once I got a review of my last update, jquery/grunt-jquery-content#63 is merged and published, and the full list of defaults is reviewed, I'll add the remaining methods and update the other widgets. |
</ul> | ||
<p>In addition to the structural and theme classes, there are also extra classes that are required for layout or other reasons and can't be removed. These are specified in the <code>extras</code> argument to <code>_addClass()</code>, but aren't part of this option.</p> | ||
<p>As long as the <code>_addClass()</code>, <code>_removeClass()</code> and <code>_toggleClass()</code> methods are used, any added classes are automatically removed when the widget is destroyed. This can heavily simplify the implementation of custom <code>_destroy()</code> methods.</p> | ||
<p class="warning">Setting the <code>classes</code> option will override all default properties. To only change specific values, use deep setters, e.g. <code>.option( "classes.ui-accordion-header", null )</code>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only AFTER init when using the getter / setter methods, on init its a deep extend. Might want to make that clear here.
@arschmitz I've addressed both your comments and fixed the grunt-jquery-content issue. If you could take another look and confirm my list ( #256 (comment) ), I can write the rest. |
@jzaefferer have not had a chance to go through all of this yet but some things i wanted to put down so i don't forget 1.) we have added new 2.) While working on the markup structure tests @scottgonzalez and i had talked about if maybe we should also add the |
@@ -192,6 +192,21 @@ | |||
<xi:include href="../includes/widget-option-disabled.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/> | |||
<xi:include href="../includes/widget-option-hide.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/> | |||
<xi:include href="../includes/widget-option-show.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/> | |||
<option name="classes" default="{}" example-value='{ "custom-header": "icon-warning" }'> | |||
<desc> | |||
<p>Extra classes to add to the widget. See the <a href="#method-_addClass"><code>_addClass()</code> method</a> for using this in custom widegts. Check out the documentation of individual widgets to see which classes they support.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: widegts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps provide more context upfront:
Additional (thematic) classes to add to the widget, in addition to the structural classes.
Updated, addressing Scott's review and the last comment from Alex. Preview: This depends on jquery/grunt-jquery-content#67 for the styling of I'd like to avoid having to create custom examples for each widget, but that's currently blocked by jquery/grunt-jquery-content#66 |
Also updates grunt-jquery-content to fix multiple examples for _addClass method.
I still think the default value should be the actual default value (i.e., none of the |
Let's update the |
<desc> | ||
Add classes to an element of the widget. | ||
<p>This provides a hook for the user to add additional classes or replace default styling classes, through the <a href="#option-classes"><code>classes</code> option</a>.</p> | ||
<p>It also provides automatic removal of these classes when a widget is destroyed, as long as you're using <code>_addClass()</code>, <code>_removeClass()</code> and <code>_toggleClass()</code> together. This can heavily simplify the implementation of custom <code>_destroy()</code> methods.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add links to the methods.
The missing links also apply to the other methods. |
<desc>Additional classes to toggle, required for layout or other reasons. Unlike the <code>keys</code> argument, these aren't associated with any properties of the <code>classes</code> option. Just like <code>keys</code>, they will also be automatically removed when destroying the widget.</desc> | ||
</argument> | ||
<argument name="add" type="Boolean"> | ||
<desc>Indicates whether to add or remove the specified classes, where a boolean <code>true</code> indicates that classes should be added, a boolean <code>false</code> indicates that classes should be removed.</desc> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though the docs show that this is required, it's probably worth an explicit mention that unlike .toggleClass()
, this method requires the boolean.
Thoughts on whether this should just be a regular sentence in the description or highlighted as a warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally i would say this is a big enough deviation from the potentially "expected" behavior that it merits a warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a warning to the method description.
Added three separate commits, that should address everything. For the |
The updates look good. I'll do another full review to see how everything looks at this point. |
Did another round of review and everything looked good. I guess the next step is updating the individual widget docs for the remaining widgets? |
I just finished reviewing again as well and everything looks good to me. |
Updated to include docs for all components. Turned out that theming information was missing or incomplete in many places. That was responsible for most of the effort. |
Updated, addressed all of Scott's comments. I've changed the nesting for |
Looks good. |
LGTM 👍 |
Turns out I based this on master, instead of 1-12, and sent this PR against master as well. Will rebase against 1-12 and create a new PR with squashed commits. |
This document the default
classes
option and the_addClass
method on$.Widget
, and theclasses
option on accordion and draggable. There's a bunch of issues that need to be addressed. I'm including screenshots here to make previewing easier.classes
option on $.Widget:Okay, but not very useful. Looking for suggestions how to improve this.
_addClass
method:<method>
only supports a single<example>
element, so the three descriptions are all mashed together, same for the code snippets. I think having multiple examples here is important enough to justify a change to grunt-jquery-content.classes
option a link, but since that references this method, we end up with circular references without adding any value. Ignore?Accordion
classes
option:Default
has to be specified as an attribute, so it can't be formatted properly, so it looks really bad. Only alternative I can think of is to put the default into the<desc>
element.null
for the example. I'm not sure if that is a good idea. See below for what I've used for draggable.Draggable
classes
option:Once these issues are addressed, I can add the docs for
_removeClass
,_toggleClass
and the remaining widgets.