Implement new design for checkbox elements (CSS3, backwards compatible)

Based on the design proposed in the Seven styleguide

Checkboxes

Implement new design for radio button elements (CSS3, backwards compatible)

Radio Buttons

CommentFileSizeAuthor
#39 seven_style_guide_checkboxes-2856459-38.patch25.52 KBAaronChristian
#37 seven_style_guide_checkboxes-2856459-37.patch25.66 KBAaronChristian
#34 seven_style_guide_checkboxes-2856459-34.patch25.49 KBAaronChristian
#31 seven_style_guide_checkboxes-2856459-31.patch24.81 KBAaronChristian
#29 seven_style_guide_checkboxes-2856459-29.patch28.5 KBAaronChristian
#27 seven_style_guide_checkboxes-2856459-27.patch21.83 KBsudhanshug
#24 seven_style_guide_checkboxes-2856459-24.patch23.97 KBsudhanshug
#19 Patch #18.png21.17 KBkrina.addweb
#19 Patch #17.png31.93 KBkrina.addweb
#18 seven_style_guide_checkboxes-2856459-18.patch23.96 KBAaronChristian
#18 screenshot-drupalvm.dev 2017-03-31 14-37-41.png13.97 KBAaronChristian
#17 seven_style_guide_checkboxes-2856459-16.patch22.71 KBAaronChristian
#17 screenshot-drupalvm.dev 2017-03-31 14-03-01.png8.23 KBAaronChristian
#17 screenshot-drupalvm.dev 2017-03-31 14-01-35.png7.67 KBAaronChristian
#14 checkboxes.png41.79 KByoroy
seven-checkboxes.png10.28 KBAaronChristian
#3 seven_style_guide_checkboxes-2856459-3.patch2.87 KBAaronChristian
#3 Screen Shot 2017-03-06 at Monday, March 6 - 2017 - 11.07.12 PM.png26.87 KBAaronChristian
#4 Screen Shot 2017-03-07 at 15.11.12.png13.1 KBidebr
#6 seven_style_guide_checkboxes-2856459-6.patch4.35 KBAaronChristian
#6 Screen Shot 2017-03-21 at Tuesday, March 21 - 2017 - 10.57.51 PM.png191.39 KBAaronChristian
#8 seven_style_guide_checkboxes-2856459-8.patch22.72 KBAaronChristian
#9 After-1.png30.48 KBkrina.addweb
#9 After.png25.33 KBkrina.addweb
#9 Before.png32.05 KBkrina.addweb
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AaronChristian created an issue. See original summary.

AaronChristian’s picture

Issue summary: View changes
AaronChristian’s picture

Here's a first stab at this. There seems to be an issue with the bulk edit forms layout with the checkboxes.

Typically the input is outputted, and then it's children after (label, etc.), however it is backwards on the bulk edit forms.

@todo: need to rearrange the output so the label comes after the input element.

idebr’s picture

Component: forms system » Seven theme
Issue summary: View changes
Status: Needs review » Needs work
FileSize
13.1 KB

Hey Aaron, thanks for working on this issue.

I found a few issues while testing your patch:

  1. The description is misaligned with the radio button label
  2. Checkboxes look a little weird on the installation form:

  3. Radio/checkbox form elements no longer have a focus state
AaronChristian’s picture

Ahhhh shoot, I forgot to include the background asset. I'll get that fixed in the next patch I submit.

Also the focus states are now border color changes, perhaps that's not obvious enough though. I can adjust that to the original accessible outline.

Thanks for testing @idebr

AaronChristian’s picture

Alright so this should fix up the issue with the assets as noted in #4. A problem still remains with the main content overview page which currently does not have a label element attached to it.

Missing labels.

AaronChristian’s picture

Status: Needs work » Needs review
AaronChristian’s picture

Alright did some more work on this one. I believe I've captured all places in the seven theme which has checkboxes visible;

- Drupal's main install form
- Bulk Edit Forms (eg. Content, Comments, Users etc.)
- Content Create Forms (eg. Add Content -> Article)
- Form Display (eg. Content Type -> Manage form display)
- Theme settings forms
- Permissions Forms
- Modules Page
- Views
- Administration Pages (eg. A modules admin page)

Tested with;

Windows 10
- IE 9/10/11
- Firefox (Latest)
- Chrome (Latest)

Mac
- Safari 9/10
- Firefox (Latest)
- Chrome (Latest)

krina.addweb’s picture

FileSize
32.05 KB
25.33 KB
30.48 KB

@AaronChristian, Thanks for your contibution for patch, it works well for me i checked it over simplytest.me with Browser compatibility, resizing & responsive.

Thanks again.

krina.addweb’s picture

Status: Needs review » Reviewed & tested by the community
AaronChristian’s picture

Awesome thanks for testing @krina.addweb! Much appreciated :)

yoroy’s picture

Assigned: Unassigned » lauriii
yoroy’s picture

Issue summary: View changes
yoroy’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#2487027: Fix the vertical rhythm
FileSize
41.79 KB

Hmm, looking a bit closer I do wonder if the space between checkbox and label is maybe a bit too wide. That horizontal gap is (almost) the same size as the vertical spacing between lines. This just about makes the label and checkbox lose touch with eachother:

The example design from the style guide uses a taller line-height. Looks like that design was implemented to spec but the vertical spacing currently in Seven is less than in that example. I think we need to ensure that the horizontal spacing between label and checkbox is clearly less than the vertical spacing between lines.

Reducing the horizontal margin would be in scope of this issue. For increasing the vertical space there's #2487027: Fix the vertical rhythm.

ckrina’s picture

I totally agree with @yoroy, it'll be easier to relate checkboxes with their own labels if they are closer.

dmsmidt’s picture

Could someone post a screenshot of how this looks with an error on a field with a checkbox?

See error styling on checkboxes issues:
#2687251-17: Radios / Checkboxes focus styling wrong when marked as having an error
[#222380-66

AaronChristian’s picture

@yoroy, attached a new patch that resolves the horizontal spacing of the labels.

@dmsmidt, i've attached a few screenshots of the focus state.

AaronChristian’s picture

Sorry forgot to attach error handling styles in the new patch. New patch and screenshot applied.

krina.addweb’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
31.93 KB
21.17 KB

@AaronChristian, I tested your patch #17 & #18 both over simplytest.me & it works for me, yes in #17 it didn't show error handling styles but it resolves the issue of horizontal spacing of the labels(#14).
For#18 it solves both the issues error handling styles & the horizontal spacing of the labels(#14).
PFA for the results of #17 & #18.

Thanks again..!!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 18: seven_style_guide_checkboxes-2856459-18.patch, failed testing.

AaronChristian’s picture

Status: Needs work » Reviewed & tested by the community

Switching back to RTBC since the last failed patch was due to a CI error; https://www.drupal.org/pift-ci-job/638828

Thank you all for testing!

AaronChristian’s picture

Title: Seven Style Guide: Checkboxes » Seven Style Guide: Checkboxes & Radio Buttons
Issue summary: View changes
Related issues: +#2856460: Seven Style Guide: Radio Buttons
tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/themes/seven/css/components/form.css
@@ -147,15 +159,117 @@ ul.tips li {
+	content: '';
...
+	background-color: #cdebfe;
+	background-position: left center;
+	background-repeat: no-repeat;
+	background-size: 100%;
...
+	background-image: url(../../../../../core/misc/icons/808080/check.svg);
+	background-position: left center;
+	background-repeat: no-repeat;
+	background-size: 100%;

This patches contains tab characters. Let's use spaces instead.

sudhanshug’s picture

Status: Needs work » Needs review
FileSize
23.97 KB
tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

This is the interdiff, so re-RTBC-ing per #19. (I can't actually say anything meaningful about the patch itself...)

diff --git a/core/themes/seven/css/components/form.css b/core/themes/seven/css/components/form.css
index b03fabf..e2e6329 100644
--- a/core/themes/seven/css/components/form.css
+++ b/core/themes/seven/css/components/form.css
@@ -211,12 +211,12 @@ ul.tips li {
 }
 
 .form-checkbox:checked + label:before {
-       content: '';
+  content: '';
   background-image: url(../../../../../core/misc/icons/001826/check.svg);
-       background-color: #cdebfe;
-       background-position: left center;
-       background-repeat: no-repeat;
-       background-size: 100%;
+  background-color: #cdebfe;
+  background-position: left center;
+  background-repeat: no-repeat;
+  background-size: 100%;
   border-color: #5b7d93;
 }
 
@@ -228,10 +228,10 @@ ul.tips li {
 }
 
 .form-checkbox[disabled]:checked + label:before {
-       background-image: url(../../../../../core/misc/icons/808080/check.svg);
-       background-position: left center;
-       background-repeat: no-repeat;
-       background-size: 100%;
+  background-image: url(../../../../../core/misc/icons/808080/check.svg);
+  background-position: left center;
+  background-repeat: no-repeat;
+  background-size: 100%;
 }
 
 /* radios */
star-szr’s picture

Status: Reviewed & tested by the community » Needs work

Nice to see Seven style guide things happening, thank you everyone who has worked on this so far :)

  1. +++ b/core/themes/seven/css/components/form.css
    @@ -49,6 +49,18 @@ fieldset:not(.fieldgroup) > legend {
    +/* checkboxes without a label */
    
    @@ -147,15 +159,117 @@ ul.tips li {
    +/* Checkboxes & Radio buttons */
    ...
    +/* make the trigger area a bit bigger for mobile tap */
    ...
    +/* checked */
    ...
    +/* disabled */
    ...
    +/* radios */
    ...
    +/* disabled */
    

    Minor: Most of these comments are not necessary, and most don't follow our documentation coding standards:

    All documentation and comments should form proper sentences, use proper grammar and punctuation, and generally follow the same style guidelines as Drupal.org content…

    Per https://www.drupal.org/docs/develop/coding-standards/api-documentation-a...

    The "make the trigger area a bit bigger for mobile tap" comment might be useful.

    Instead of a lot of these comments I'd recommend grouping similar selectors together visually per https://www.drupal.org/docs/develop/standards/css/css-formatting-guideli... (Blank lines).

  2. +++ b/core/themes/seven/css/components/form.css
    @@ -147,15 +159,117 @@ ul.tips li {
    -  margin-left: 1.5em; /* LTR */
    +  margin-left: 22px; /* LTR */
    ...
    -  margin-right: 1.5em;
    +  margin-right: 22px;
    

    Sorry if I missed this in the comments, but can we keep these as em units?

sudhanshug’s picture

Status: Needs work » Needs review
FileSize
21.83 KB
AaronChristian’s picture

Discussing with @laurri regarding the CSS changes;

  • Implement a label element class to easily define the element in the CSS stylesheet. (ie. .form_element_label__checkbox) through a theme hook suggestion. This should remove the need for and pseudo elements selectors -> + label declarations.
  • Remove the need to override the icons paths in the system.admin.css that are added by default.

Should be able to get working on this as soon as I have some down time this weekend. Thanks for all the work everyone!

AaronChristian’s picture

Hopefully this should do the trick for finishing this one up.

Additions: Adding of a class to the label elements with the $element['#type'] for styling purposes.

Status: Needs review » Needs work

The last submitted patch, 29: seven_style_guide_checkboxes-2856459-29.patch, failed testing.

AaronChristian’s picture

Whoops, must have been too late at night, made a crappy patch.

Tested this one, should apply cleanly.

AaronChristian’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 31: seven_style_guide_checkboxes-2856459-31.patch, failed testing.

AaronChristian’s picture

Fixed up a few coding standards. The others seem to have been pulled right out of stable.

AaronChristian’s picture

Status: Needs work » Needs review
Gábor Hojtsy’s picture

Status: Needs review » Needs work

Just reviewing the part of code I feel eligible to review, AKA code style and PHP. I also looked at whether RTL CSS is taken care of and that seems to be the case, so great :)

  1. +++ b/core/misc/icons/001826/check.svg
    @@ -0,0 +1 @@
    +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#001826"><path d="M6.464 13.676c-.194.194-.513.194-.707 0l-4.96-4.955c-.194-.193-.194-.513 0-.707l1.405-1.407c.194-.195.512-.195.707 0l2.849 2.848c.194.193.513.193.707 0l6.629-6.626c.195-.194.514-.194.707 0l1.404 1.404c.193.194.193.513 0 .707l-8.741 8.736z"/></svg>
    \ No newline at end of file
    
    +++ b/core/misc/icons/808080/check.svg
    @@ -0,0 +1 @@
    +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#808080"><path d="M6.464 13.676c-.194.194-.513.194-.707 0l-4.96-4.955c-.194-.193-.194-.513 0-.707l1.405-1.407c.194-.195.512-.195.707 0l2.849 2.848c.194.193.513.193.707 0l6.629-6.626c.195-.194.514-.194.707 0l1.404 1.404c.193.194.193.513 0 .707l-8.741 8.736z"/></svg>
    \ No newline at end of file
    

    Should have newlines at end files :)

  2. +++ b/core/themes/seven/css/components/form.css
    @@ -140,13 +155,97 @@ div.description,
    +/* make the trigger area a bit bigger for mobile tap */
    

    Make this a sentence IMHO.

  3. +++ b/core/themes/seven/seven.theme
    @@ -186,3 +186,24 @@ function seven_form_node_form_alter(&$form, FormStateInterface $form_state) {
    +/**
    + * The contents of $variable['label'] will be passed to the preprocess
    + * hook of the element's label.
    + */
    +function seven_preprocess_form_element(array &$variables) {
    ...
    +/**
    + * Now we need to merge the array element we created in the previous hook
    + * with the label's attributes.
    + */
    +function seven_preprocess_form_element_label(array &$variables) {
    

    We should have the regular boilerplate text here Implements hook_blabla... and the actual docs should go into the function body.

    Also we don't do "now" and "we" in comments, just "Merge the form element type class from seven_preprocess_form_element() with the label's attributes." or somesuch.

AaronChristian’s picture

Status: Needs work » Needs review
FileSize
25.66 KB

Fixes for #36.

We need to use the "+" selector in some cases as we can't target the element without making extremely long selectors.

However I have added label classes which have cleaned up the selector roots quite a bit.

Status: Needs review » Needs work

The last submitted patch, 37: seven_style_guide_checkboxes-2856459-37.patch, failed testing.

AaronChristian’s picture

Status: Needs work » Needs review
FileSize
25.52 KB

Whoops! Looks like my core version was a bit out of date.

Here's an updated patch with the latest dev branch.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andrewmacpherson’s picture

Issue tags: +Accessibility

Just spotted this on Slack. For accessibility QA - do the checkbox and radio designs have focus styles?

Update: I've seen this in the latest patch...

+.form-checkbox:focus + .form_checkbox-label:before,
+.form-radio:focus + .form_radio-label:before {
+  border-color: #001826;
+}

This looks like the focus indication might be a failure of WCAG 2.0 SC 1.4.1 Use of Color at level A. Is border colour the only thing that changes?

andrewmacpherson’s picture

Status: Needs review » Needs work

Comment #5 says the focus style is just a border colour change. Going by the screenshots in #17, focus isn't very easy to spot at all.

For users who rely on focus styles, subtle changes just don't work.

Going by what I've seen, the focus styles:

  1. Fail WCAG 2.0 Use of color, level A
  2. Technically they pass WCAG 2.0 "Focus Visible", level AA. But a problem with that success criterion is that it doesn't require any level of clarity at all.

There's also a new "Non-text contrast" criterion in WCAG 2.1, which calls for focus states to have a 3:1 colour contrast compared to the non-focused state. WCAG 2.1 has just reached Proposed Recommendation stage, so is stable enough to use now. If we can satisfy this one, all the better.

A shape change is a much clearer focus indicator than a colour-only change. I recommend an offset border or outline around the input, with a colour contrast of 3:1 against the page background. Probably blue.

andrewmacpherson’s picture

The error style in comment #19 screenshot also fails WCAG 2.0 Use of color.

lauriii’s picture

Assigned: lauriii » Unassigned

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

Project: Drupal core » Seven
Version: 9.5.x-dev » 1.0.0-alpha1
Component: Seven theme » Code