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

Add smaller versions of radio buttons and checkboxes #1125

Merged
merged 23 commits into from
Apr 11, 2019

Conversation

dashouse
Copy link

@dashouse dashouse commented Jan 10, 2019

Introduces smaller versions of the radios and checkboxes components.

radios

Despite being visually smaller, these have a target size of 44 x 44px, as the input extends outside of the boundaries of the visual control.

To make it clear which control will be activated when hovering in the gap between the controls, we add a hover state.

This PR also simplifies the way that existing checkboxes and radio buttons are rendered in IE8 and increases the touch area of the existing radios and checkboxes to 44x44px.

👉Checkbox examples in the review app
👉Radio examples in the review app
👉Radios and checkboxes, big and small, in all the states
👉A contrived example

Browser and assistive technology testing

  • Internet Explorer 8 (Windows 7, Browserstack)
  • Internet Explorer 9 (Windows 7, Browserstack)
  • Internet Explorer 10 (Windows 8, Browserstack)
  • Internet Explorer 11 (Windows 10, Browserstack)
  • Edge 18 (Windows 10, Browserstack)
  • Edge 17 (Windows 10, Browserstack)
  • Google Chrome 73 (mac)
  • Mozilla Firefox 65 (mac)
  • Safari 12 (mac)
  • Safari 11 (mac, Browserstack)
  • Safari 10 (mac, Browserstack)
  • Safari 9.1 (mac, Browserstack)
  • Safari (iOS 12, iPhone X)
  • Google Chrome (iOS 12, iPhone X)
  • Safari (iOS 11, iPhone X, Browserstack)
  • Safari (iOS 10, iPhone 5c)
  • Safari (iOS 9.3, iPhone 5)
  • Safari (iOS 7, iPhone, iPhone 4)
  • Google Chrome, Android 9, Browserstack
  • Google Chrome, Android 8, Browserstack
  • Samsung Internet, Android 8, Browserstack
  • Samsung Internet, Android 7, Browserstack
  • Google Chrome 73 - mixed input modes (Chromebook)
  • Google Chrome 73 - 400% zoom (macOS)
  • Internet Explorer 11 - high contrast mode (Windows 10)
  • Internet Explorer 11 - ZoomText (Windows 10)
  • Internet Explorer 11 - 400% zoom (Windows 10, Browserstack)
  • Internet Explorer 11 - larger text (Windows 10, Browserstack)
  • Mozilla Firefox 65 – custom colours (mac)
  • Mozilla Firefox 65 – night mode (iOS)

Physical device testing

Chrome 69, Android 7.0 (Galaxy S6)

Works as expected

Chrome 50, Android 5.1.1 (Nexus 10 tablet)

Works as expected

Chrome 71, Android 4.4.2 (Galaxy Note 2)

Tested with stylus and touch. Worked as expected

Android Browser, Android 4.4.2 (Galaxy Note 2)

The stylus triggers hover style
Touch triggers the hover style, and clicking once triggers hover style then after a delay triggers the click. Not ideal but still usable.

Android 2.2 (Galaxy S)

Radios are square – seemingly no support for border-radius – an existing issue.
Small hidden element highlighted on tap. Hover state not visible.

Safari, iOS 10.3.2 (iPhone 5C)

Works as expected

Safari, iOS 9.3.2 (iPhone 5)

Works as expected

Safari, iOS 7.1.2 (iPhone 4)

Hover state is visible and 'sticks', but clicking once still triggers the control

Internet Explorer, Windows Phone 8.1 (Lumia 630)

Works as expected

Screenshots

Chrome 70 (macOS Mojave) macmo_chrome_70 0
Chrome 70 (Windows 10) win10_chrome_70 0
Chrome 71 (macOS Mojave) macmo_chrome_71 0
Chrome 71 (Windows 10) win10_chrome_71 0
Firefox 62 (macOS Mojave) macmo_firefox_62 0
Firefox 62 (Windows 10) win10_firefox_62 0
Safari 9.1 (OS X El Capitan) macelc_safari_9 1
Safari 10.1 (macOS Sierra) macsie_safari_10 1
Safari 11.1 (macOS High Sierra) machs_safari_11 1
Safari 12 (macOS Mojave) macmo_safari_12 0
Internet Explorer 8 (Windows 7) win7_ie_8 0
Internet Explorer 9 (Windows 7) win7_ie_9 0
Internet Explorer 10 (Windows 8) win8_ie_10 0
Internet Explorer 11 (Windows 10) win10_ie_11 0
Edge 18 (Windows 10) win10_edge_18 0
Android 7.1 (Google Pixel) 7 1_Google-Pixel_portrait_real-mobile
Android 8.0 (Google Pixel 2) 8 0_Google-Pixel-2_portrait_real-mobile
Android 9.0 (Google Pixel 2) 9 0_Google-Pixel-2_portrait_real-mobile
iOS 8.3 (iPhone 6) ios_iPhone-6_8 3_portrait
iOS 10 (iPhone 7) 10_iPhone-7_portrait_real-mobile
iOS 11 (iPhone 8) 11_iPhone-8_portrait_real-mobile
iOS 12 (iPhone XR) 12_iPhone-XR_portrait_real-mobile

Known issues

The hover state 'sticks' on devices that support both touch and pointer based interaction, such as Chromebooks and Surfaces.

Video showing issue

If you try to use a hint with the smaller radios and checkboxes, moving the cursor over the hint will trigger the hover state, but clicking the hint won't actually select the control.

Video showing issue

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 January 10, 2019 15:49 Inactive
@joelanman
Copy link
Contributor

Nice work Dave! Feels pretty good on mobile Chrome. After selecting, the hover colour remains, is that expected?

@NickColley
Copy link
Contributor

@dashouse can you explain the technical requirement to have them block?

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 January 10, 2019 15:59 Inactive
@NickColley
Copy link
Contributor

NickColley commented Jan 10, 2019

@joelanman this could be the same issue we saw when we looked to add ghost hover states before: alphagov/govuk_elements#570 (comment)

@dashouse
Copy link
Author

dashouse commented Jan 10, 2019

Updated with a quick override class to block the hover state for the second example to see how we feel about the difference.

@joelanman Hover colour should not remain no... I wasn't seeing this initially on iOS, but I don't see the normal focus either

@NickColley It's hard to explain in words, but also near impossible to screenshot because of the cursors but... the .govuk-radios__item is hovered in order to add the box shadow...if we make the .govuk-radios__label inline-block then the hover state appears when .govuk-radios__item is hovered when away from the label. The checkbox or radio isn't actually selectable but the hover state gives a false impression that it could be. I may have to show you.

@NickColley
Copy link
Contributor

I think... if you do, it works as we want?

.govuk-checkboxes--small .govuk-checkboxes__label {
-   display: block;
-   margin-top: -2px;
    padding: 11px 15px 9px 0;
}
.govuk-checkboxes--small .govuk-checkboxes__item {
    min-height: 0;
    padding-left: 35px;
+   float: left;
+   margin-top: -2px;
}

@dashouse
Copy link
Author

dashouse commented Feb 5, 2019

I think... if you do, it works as we want?

.govuk-checkboxes--small .govuk-checkboxes__label {
-   display: block;
-   margin-top: -2px;
    padding: 11px 15px 9px 0;
}
.govuk-checkboxes--small .govuk-checkboxes__item {
    min-height: 0;
    padding-left: 35px;
+   float: left;
+   margin-top: -2px;
}

Yes, this is perfect 👍

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 5, 2019 09:32 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 7, 2019 15:02 Inactive
@govuk-design-system-ci govuk-design-system-ci requested a deployment to govuk-frontend-review-pr-1125 March 12, 2019 14:45 Abandoned
//
// (If you do use them, they won't look completely broken... but seriously,
// don't use them)
.govuk-radios__hint {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if 'pointer-events: none' would ensure it doesnt trigger the hover state...

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd had a similar thought, but sadly not, as the pointer events just 'go through' the hint and find the label.

@govuk-design-system-ci govuk-design-system-ci requested a deployment to govuk-frontend-review-pr-1125 March 12, 2019 15:41 Abandoned
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 13, 2019 09:17 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 13, 2019 11:12 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 14, 2019 15:47 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 14, 2019 15:53 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 18, 2019 14:03 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 18, 2019 14:13 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 18, 2019 14:26 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 18, 2019 15:05 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 18, 2019 15:20 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1125 March 19, 2019 13:37 Inactive
@36degrees 36degrees changed the title WIP - Small radios and checkboxes Add smaller versions of radio buttons and checkboxes Mar 20, 2019
Copy link
Member

@hannalaakso hannalaakso left a comment

Choose a reason for hiding this comment

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

Great work everyone 🙌

@aliuk2012 aliuk2012 merged commit c7b6ef8 into master Apr 11, 2019
@aliuk2012
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

7 participants