Skip to content
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

Fix buggy placement of icons on buttons #18005

Merged
merged 9 commits into from
Aug 4, 2020

Conversation

agh1
Copy link
Contributor

@agh1 agh1 commented Jul 30, 2020

Overview

Buttons with icons can look funny in a number of circumstances, and CiviCRM wasn't always consistent with itself on how icons were placed. Specifically, icons had absolute positioning 4 pixels from the top and left of the button. For many sites, this would be well above or below the text and could distort the button size.

This standardizes icons as inline blocks with standard padding and a single space between them and any text that follows. In the process, I simplified a lot of how the box model on buttons is managed.

Finally, the WordPress admin CSS gives items with the class button a minimum height of 30 pixels, so this does a reset of that.

Comparison

Context Before After
Stock Drupal image image image image
Drupal w/ button height at 2em image image
Drupal w/ Shoreditch image image
WordPress image image image image

(In the View Contribution screenshots, the first two are <a class="button"> while the third is an actual <input type="submit">.)

Technical Details

There was a special class for buttons with icons, and this makes that unnecessary. There were also some unused or barely-used button and icon related classes that I removed, standardizing the markup if necessary.

@civibot
Copy link

civibot bot commented Jul 30, 2020

(Standard links)

@civibot civibot bot added the master label Jul 30, 2020
@agh1
Copy link
Contributor Author

agh1 commented Jul 30, 2020

@colemanw I wanted to be sure you saw this because it undoes some of what you added back in #7199. Please jump in if you think it's better to position the icons absolutely rather than inline with the text.

agh1 added a commit to agh1/civicrm-dev-docs that referenced this pull request Jul 30, 2020
See civicrm/civicrm-core#18005 for work
to standardize this, but it's already common practice.
@MegaphoneJon
Copy link
Contributor

@agh1 and whoever reviews this - please make sure to check in both Shoreditch and non-Shoreditch. #17295 caused "More" menus to disappear out of Shoreditch, and while it seems to be more about Shoreditch's assumptions than Andrew's PR, we should make an effort to include it in our testing.

homotechsual pushed a commit to civicrm/civicrm-dev-docs that referenced this pull request Jul 30, 2020
See civicrm/civicrm-core#18005 for work
to standardize this, but it's already common practice.
@agh1
Copy link
Contributor Author

agh1 commented Jul 31, 2020

@MegaphoneJon thanks for suggesting--I just added screenshots with Shoreditch, which appears to have nixed the icons all along.

I do think we're in a bit of an unstable situation with regard to the UI. On the one hand, you can reasonably complain that a core change breaks Shoreditch, which has been promoted as "the future" in some circles for a while. Meanwhile, others can reasonably complain that something like #17775 causes core to depend upon Shoreditch, or at least Bootstrap.

Finally, a key effort has been that the work to enable Shoreditch / CiviHR / "new" CiviCase should be modular so that others can write their own themes, and others have been doing just that. It's sort of reasonable to expect that a PR works nicely in four or five CMS contexts plus a second theme for one of them, but it becomes unreasonable to expect testing of a growing number of themes.

One of the driving forces behind dev/user-interface#24 is dissatisfaction with Shoreditch, and I do think it will probably remain a niche thing rather than an emerging standard.

@agh1
Copy link
Contributor Author

agh1 commented Jul 31, 2020

Jenkins retest this please

@eileenmcnaughton
Copy link
Contributor

This is too form-layery to need a test

@eileenmcnaughton
Copy link
Contributor

@agh1 conflict....

@agh1
Copy link
Contributor Author

agh1 commented Aug 3, 2020

@eileenmcnaughton thanks, just rebased

@eileenmcnaughton
Copy link
Contributor

@vingle @christianwach @artfulrobot @colemanw is anyone able to review this?

Regarding shoreditch - affecting shoreditch is non-blocking but we should at least make @jamienovick aware when we think a PR may affect shoreditch so he can adjust shoreditch.

@agh1
Copy link
Contributor Author

agh1 commented Aug 4, 2020

I just reworked the screenshots into a table so it's easier to see changes side-by-side in each context. Also, this is a case where a reviewer might do best by looking at the commits in sequence. Some are more significant than others, and 90% of the file changes are just one commit that cleans up extra non-breaking spaces.

@vingle
Copy link
Contributor

vingle commented Aug 4, 2020

Can confirm that the CSS isn't problematic & the fix works for Joomla:

Before (with 3em height for emphasis)

image

After

image



@seamuslee001
Copy link
Contributor

Merging based on @vingle 's review here

@seamuslee001 seamuslee001 merged commit da6c68c into civicrm:master Aug 4, 2020
@demeritcowboy
Copy link
Contributor

I'm not sure if it's this PR but I'm noticing that one of the icon/button PRs lately changes the clickable surface area of the buttons. So for example if you click on a button in the area where the icon is then nothing happens, but if you click on the word then it clicks. Whereas hovering still covers the whole button surface.

@agh1
Copy link
Contributor Author

agh1 commented Aug 6, 2020

@demeritcowboy ugh you are absolutely right, and this PR caused it. The issue is that the button isn't what you see--it's only the part with the text. This all stems from using <input type="submit"> rather than <button type="submit">: the latter allows content like icons while the former does not. That would be the most natural solution; otherwise, we might need to revert.

@mattwire
Copy link
Contributor

mattwire commented Aug 6, 2020

@agh1 @demeritcowboy We have some good forward-progress on buttons so would be a shame to revert if we can continue to improve. I've noticed that the clickable area is smaller and also once submitted they go a strange hashed colour briefly. I know that @vingle is keen to review button PRs (and see them become more consistent).

@agh1
Copy link
Contributor Author

agh1 commented Aug 6, 2020

@demeritcowboy @mattwire I'm making some progress on getting all of these switched out for real <button> elements. They'll need to be reworked to display right (our CSS doesn't really anticipate actual <button> elements), but the end result will be much more consistent with the other pseudo-buttons since they can have actual content.

@agh1
Copy link
Contributor Author

agh1 commented Aug 6, 2020

@demeritcowboy @mattwire @vingle I have a WIP that replaces all of the <input type="submit"> elements with <button type="submit">. It's not ready to review because I need to fix the appearance. See #18087 if you want to look at what's going on.

@demeritcowboy
Copy link
Contributor

Thanks @agh1

@vingle
Copy link
Contributor

vingle commented Aug 6, 2020

This is very promising - be brilliant to see the end of <input type="submit">.

@eileenmcnaughton
Copy link
Contributor

per recommendation from @mattwire this has been reverted along with the previously reverted one since it seems required to get stable. The plan is to send out an email before the end of the week pointing people to both & aim to merge next week into what will be 5.31

eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Sep 3, 2020
@agh1 agh1 mentioned this pull request Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants