Skip to content

Button Re-write #1333

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

Closed
wants to merge 73 commits into from
Closed

Button Re-write #1333

wants to merge 73 commits into from

Conversation

arschmitz
Copy link
Member

This replaces PR #1216

This includes new widget controlgroup which replaces buttonset
Current known issues

  • Checkboxradio testfailure missing default element (@scott_gonzalez said it should not have one because it cant be sane ) this causes common tests to fail
  • Backcompat: Draft this on the wiki
  • Controlgroup icon only buttons 1px too short in chrome, firefox extra weird @jaspermdegroot think you could take a look?
  • demos/controlgroup/default.html As above, labels should demo something
  • demos/checkboxradio/default.html doesn't have the "command line" anymore, but still doesn't look like a demo. Labels should reflect some real world usecase.
  • demos/button/icons.html still looks like a visual test, not a demo

<div class="demo-description">
<p>Some buttons with various combinations of text and icons.</p>
</div>
<div class="widget">
<h1>Widget</h1>
<a>Button with icon only</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing an href attribute. Or it should be a <button> as well.

@jaspermdegroot
Copy link
Member

If you remove the font-size: 62.5%; rule from demos.css you'll see there are some more issues with controlgroups;

  • There is space between the buttons in horizontal controlgroups
  • On Chrome you only get to see ellipsis in the dropdown buttons
  • There is almost no space between the text and the icon in the dropdown button (noticed on Firefox)

Screenshot Chrome 37 / MBP Retina:

image

Screenshot Firefox 32 / MBP Retina:

image

@arschmitz
Copy link
Member Author

@jaspermdegroot this is fixed and also fixed the off by one i mentioned but in firefox icon only buttons are still a little short can you try and take a look at this?

@jaspermdegroot
Copy link
Member

@arschmitz

I pulled the branch this morning and I don't see any commits after that. Where is it fixed?
Yes, I am looking into the icon-only buttons height problem on Firefox.

Update: @arschmitz - Nevermind, I don't know what went wrong but I forked the repo again and checked out the button branch and the problem has been fixed.

@@ -28,81 +29,79 @@
}
/* to make room for the icon, a width needs to be set here */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be removed

Update: We do need to set a width for anchor elements, so the comment should stay and we should revert the change where the width setting has been removed.

@jaspermdegroot
Copy link
Member

PR #1340 contains the fix for the controlgroup icon-only button height problem on Firefox.

@jaspermdegroot
Copy link
Member

I added 2 more commits to #1340 to fix the following issues:

  • When you try to toggle the state of a checkbox too fast you will select the text instead of changing the state. I added user-select: none; (not supported by IE8/9) for all buttons, not just checkbox buttons, to fix this.
  • On IE8 the radio icons were black which looked bad. I changed the opaque fallback background color to grey. Although the semi-transparent background color for browsers that do support rgba can be used across themes, it might be better to move this to theme CSS.
    On IE8 the radio icon gets a black border in the active state because IE8 doesn't follow the specs (text color should have been used as border color if that property hasn't been set). Shouldn't we set the border-color to prevent this issue?

@arschmitz
Copy link
Member Author

@jzaefferer this now includes the commits from @jaspermdegroot to fix controlgroup and various fixes / updates for demos.

@@ -11,7 +11,7 @@
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
$( "input[type=submit], a, button" )
$( ".widget input[type=submit], .widget a, .widget button" )
.button()
.click(function( event ) {
event.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's apply the preventDefault() to all buttons on this page, not just the widget buttons.

@jzaefferer
Copy link
Member

One button unit test is currently failing.

<h2>Checkbox</h2>

<fieldset>
<legend>Rating</legend>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an improvement and more demo-like. Though as-is a bit irritating: It looks like its a part of a rating UI, where it wouldn't make sense to select multiple ratings. Maybe change the legend to "Filter by rating"?

As for the markup, shouldn't they all share the same name and have a value attribute? Maybe use "rating" instead of "checkbox"?

@jzaefferer
Copy link
Member

Can checkboxradio also support a "CSS only" mode?

formElement.off( "reset" + this.eventNamespace, formResetHandler );
formElement.on( "reset" + this.eventNamespace, formResetHandler );

// If it is null the user set it explicitly to null so we need to check the dom
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's uppercase "dom" to "DOM".

},

_enhance: function() {
var checked = this.element.is( ":checked" );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it faster to use this.element.prop( "checked" )?

@jaspermdegroot
Copy link
Member

@arschmitz

The negative margin for `ui-button`` in horizontal controlgroups still leaves space between some of the buttons. Which buttons depends on what browser you're on and what font size you use.
Another downside of this solution is that if there is no linebreak or space in the markup between the controlgroup elements it will cause overlap.
Have you looked into making the buttons float?

In case we stick to inline-block and negative margin:

  • Why negative margin left and right and not just right?
  • ui-button shouldn't get negative margin left and right inside vertical controlgroups

The width of the select button in a vertical controlgroup should be auto. Currently it will break when you increase the font size (not only because of the inline width style, also because of the negative margin)

// we don't search against the document in case the element
// is disconnected from the DOM
ancestor = this.element.parents().last();
labelSelector = "label[for='" + this.element.attr("id") + "']";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to selector-escape the ID, in case it contains funky characters which will render the selector invalid:

 ... + this.element.attr( "id" ).replace( /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g, "\\$1" ) + ...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should follow the SOP and put the regex into a variable to the top of the file, so we don't recompile it.

@sfrisk
Copy link
Member

sfrisk commented Dec 17, 2014

I agree with @jaspermdegroot regarding control group issues might be fixed by using floats instead of keeping them inline-blocks with the negative margin adjustment. As much as I like inline-blocks, if you're dealing with a case where elements need to be right up against each other, floats typically are the better solution. The negative margins css hack for inline-blocks can be tricky, and the alternative is making sure there are no spaces between your elements in the html, which tends to make the html look messy.

@arschmitz
Copy link
Member Author

@jaspermdegroot Turns out its actually not possible to set width auto on selectmenu buttons in a vertical controlgroup which is why I was not. Selectmenu sets an actual width on the button via JS no matter what setting auto actually breaks this and makes it tiny. It seems like there should be a way to completely stop the selectmenu from setting a width for cases like this where you want it to fill a containers width. /cc @fnagel

@arschmitz arschmitz mentioned this pull request Jan 8, 2015
@arschmitz
Copy link
Member Author

Closing replaced by #1415

@jaspermdegroot
Copy link
Member

@arschmitz

setting auto actually breaks this and makes it tiny

I don't see that problem. The screenshot below shows the result when I set width: auto important!; for the selectmenu button in the vertical controlgroup and margin: 0; for all buttons in the vertical controlgroup. To illustrate the problem I set font-size: 22px; on the body.

image

With current CSS, changing the font-size to 22px results in this:

image

Using !important to override the width that the JS sets on the button should be avoided, so I agree this should be resolved in the selectmenu widget so it doesn't set a width when the select is in a vertical controlgroup.

Ps. I think you forgot to actually close this PR :)

@arschmitz
Copy link
Member Author

@jaspermdegroot exactly and using !important is not acceptable. It makes it essentially impossible for anyone to override. I'm surprised this is not in the style guide /cc @sfrisk

@arschmitz arschmitz closed this Jan 8, 2015
@jaspermdegroot
Copy link
Member

Well, you can override it. Just need to use !important in your override as well and make sure it comes after the framework CSS. But, like I said, we should avoid using it and it might indeed be good to add a note about that to the style guide.

Will the new selectmenu widget still use JS to set a width as far as you know? I was wondering what problem had to be solved that couldn't be done with CSS only.

@arschmitz
Copy link
Member Author

@jaspermdegroot I'm not sure what you mean by new selectmenu widget? This is the UI widget which just landed in 1.11 ( the current stable version )

@jaspermdegroot
Copy link
Member

@arschmitz - Sorry, I had Mobile in my mind where we didn't adopt the new selectmenu yet.

@arschmitz arschmitz deleted the button branch April 3, 2015 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

9 participants