Problem/Motivation

Restyle the details and accordion elements based on the Proposal: A Style Guide for Seven.

Motivation is discussed in more detail in the style guide.

The file and image fields, fieldset, details and accordion are all container elements to some degree, having a number of sub-elements in relation to one another. They all use a background tone and slightly darker border to contain these sub-elements and visually signal their grouping. They do this with as light a touch as possible while remaining distinguishable. To soften them slightly, a 2px border-radius is applied to the outer corners.

Proposed resolution

Restyle the details (fieldset) and accordion elements

User interface changes

Superficial, in line with the style guide.


API changes

n/a

Data model changes

None.

CommentFileSizeAuthor
#74 Screen Shot 2018-06-27 at 17.41.21.png136.66 KBlauriii
#74 Screen Shot 2018-06-27 at 17.40.59.png107.05 KBlauriii
#70 Create Article | Drupal 8.5.4 2018-06-26 11-21-14.png103.93 KBGábor Hojtsy
#68 2854624-67.patch8.67 KBlauriii
#68 interdiff.txt1.28 KBlauriii
#61 interdiff.txt1.01 KBlauriii
#61 2854624-61.patch8.37 KBlauriii
#56 modules-page-after.png92.71 KBlauriii
#55 interdiff.txt1.33 KBlauriii
#55 2854624-55.patch7.87 KBlauriii
#53 Screen Shot 2018-04-24 at 19.35.07.png2.9 KBlauriii
#51 Screen Shot 2018-04-24 at 19.23.11.png55.32 KBlauriii
#50 2854624-50.patch6.3 KBlauriii
#35 Screen Shot 2017-03-24 at 9.41.48 AM.png127.62 KBtkoleary
#34 Screen Shot 2017-03-24 at 9.28.29 AM.png18.05 KBtkoleary
#34 Screen Shot 2017-03-24 at 9.22.27 AM.png14.6 KBtkoleary
#34 Screen Shot 2017-03-24 at 9.17.59 AM.png14.8 KBtkoleary
#33 Status-report-mobile.png18.04 KBckrina
#33 Status-report-desk.png56.3 KBckrina
#33 create-article-mobile.png57.08 KBckrina
#33 create-article-desktop.png41.61 KBckrina
#31 interdiff.txt3.82 KBlauriii
#31 details_and_accordion-2854624-31.patch6.21 KBlauriii
#30 details_and_accordion-2854624-30.patch5.28 KBAaronChristian
#20 interdiff-15-20.txt2.06 KBAnonymous (not verified)
#20 details_and_accordion-2854624-20.patch4.25 KBAnonymous (not verified)
#15 interdiff-2854624-12-15.txt1.13 KByogeshmpawar
#15 details_and_accordion-2854624-15.patch3.42 KByogeshmpawar
#12 details_and_accordion-2854624-12.patch3.93 KBAaronChristian
#8 details_elements-status_report.png31.37 KBchrisrockwell
#6 details_and_accordion-2854624-6.patch4.05 KBAaronChristian
#3 14.details-and-accordion.png47.66 KBAaronChristian
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

Issue summary: View changes
FileSize
47.66 KB
Gábor Hojtsy’s picture

I was about to say this could share some styling with #2113931: File Field design update: Upload field. but the subtle inset styling from the design does not seem to be implemented there (yet?)

AaronChristian’s picture

No your right Gabor, I'll get that cleaned up and implemented. I'm sure we can use some recyclable styles between the two elements.

AaronChristian’s picture

Status: Active » Needs review
FileSize
4.05 KB

Attached is the restyling of the details and accordions sections as outline in the descriptions screenshot above.

Status: Needs review » Needs work

The last submitted patch, 6: details_and_accordion-2854624-6.patch, failed testing.

chrisrockwell’s picture

This looks awesome! The status report uses detail so we'll need a separate issue to clean that up. For example:

I notice the rounded corners, and the title color.

+++ b/core/themes/seven/css/components/details.css
@@ -0,0 +1,35 @@
+  border-radius: 3px;
+  -moz-border-radius: 3px;
+  -webkit-border-radius: 3px;

I don't think prefixes are necessary. If we do use them, shouldn't border-radius be at bottom of list?

AaronChristian’s picture

Ahhh yes i see that now, thanks Chris. I'll take another peek and get that fixed up, I see the patch failed too so I'll have to figure out what the issue is there.

chrisrockwell’s picture

chrisrockwell’s picture

AaronChristian’s picture

A few things fixed up here for some accessibility handling while tabbing/focusing.

Also removed the redundant prefixes as noted in #8, thanks @chrisrockwell

AaronChristian’s picture

Status: Needs work » Needs review
chrisrockwell’s picture

Status: Needs review » Needs work
+++ b/core/themes/seven/css/base/elements.css
@@ -167,8 +167,5 @@ details summary {
\ No newline at end of file

Needs a newline at end

Other than that, this looks good to me. I've tested on Simplytest with #2857662: Update Status Report to account for Details and Accordion styling bringing fixed and everything looks great!

yogeshmpawar’s picture

Status: Needs work » Needs review
FileSize
3.42 KB
1.13 KB

Updated patch which removes some coding standard issues of #12 & also added interdiff.

Status: Needs review » Needs work

The last submitted patch, 15: details_and_accordion-2854624-15.patch, failed testing.

Anonymous’s picture

lauriii credited vaplas.

lauriii’s picture

(Updating commit credit)

Anonymous’s picture

Status: Needs work » Needs review

@lauriii, thank you for caring :)

I'm added @AaronChristian's patch from #2857662: Update Status Report to account for Details and Accordion styling bringing fixed + next changes:

+++ b/core/themes/seven/css/components/entity-meta.css
 .entity-meta details {
+  margin: 0;
   border-left: 0;
   border-right: 0;
   border-top: 1px solid #fff;
-  margin: 0;
   border-radius: 0;
-  -moz-border-radius: 0;
-  -webkit-border-radius: 0;

Because we haven't -moz-border-radius and -webkit-border-radius in other part of drupal core :)

+ nit reorder rules for better grouping by name.

Anonymous’s picture

AaronChristian’s picture

Status: Needs review » Reviewed & tested by the community

Awesome thanks @vaplas. Looks good to me, no issues with the patch.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/themes/seven/css/components/details.css
@@ -0,0 +1,32 @@
+/* @todo Regression: The summary of uncollapsible details are no longer
+     vertically aligned with the .details-wrapper in browsers without native
+     details support. */

We should still take care of the open @todo's

AaronChristian’s picture

Hey @laurriii is this an issue with the current patch or more related to the fact that tag's aren't fully supported in some browsers?

http://caniuse.com/#search=%3Cdetails%3E

lauriii’s picture

@AaronChristian if the regression is introduced in this patch, we should fix it. If not, we should file another bug report for that, as long as it can be worked without committing this patch first. If we just add a todo comment, it is highly unlikely that it gets fixed.

AaronChristian’s picture

@lauriii, yep it looks like <details> components are built right into core.

As far as I can see this patch doesn't make regression any worse, so I think it's safe to say this could roll out without regression being completed.

That being said, I've created another issue to handle older browser support for <details>.

AaronChristian’s picture

Status: Needs work » Reviewed & tested by the community

Moving back to RTBC due to the nature of the regression being a different issue.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/themes/seven/css/components/details.css
    @@ -0,0 +1,32 @@
    +details {
    ...
    +details summary:hover,
    

    Let's create classes for details and details__summary so it is possible to use these styles for other types of elements as well. This also allows us to write better CSS.

  2. +++ b/core/themes/seven/css/components/details.css
    @@ -0,0 +1,32 @@
    +details > .details-wrapper {
    

    Why do we have to use > here? We should document it with an inline comment if it is needed.

  3. +++ b/core/themes/seven/css/components/details.css
    @@ -0,0 +1,32 @@
    +/* @todo Regression: The summary of uncollapsible details are no longer
    +     vertically aligned with the .details-wrapper in browsers without native
    +     details support. */
    

    If we have created issue for this, let's remove the @todo since it is reduntant. Please reference the issue to this issue.

  4. +++ b/core/themes/seven/css/components/entity-meta.css
    @@ -51,9 +56,9 @@
     .entity-meta details > summary {
    ...
    +  padding: 0.95em 1.45em;
    

    I think this padding should be applied more globally for details summary elements because currently summary elements that are not inside .entity-meta look a bit awkward..

AaronChristian’s picture

Adding related issue.

AaronChristian’s picture

AaronChristian’s picture

Status: Needs work » Needs review
FileSize
5.28 KB

I'm not so sure that we should add more selectors for .details & .details_summary. It looks like core/themes/classy/css/components/collapse-processed.css handles all the backwards compatibility for expanding/collapsing fieldsets.

So long as new elements that use <details> and <summary> elements are rendered as such, the regression support that has been accounted for from modernizr & the stylesheet referenced above.

I've attached a new patch with the removal of the @todo, and added a comment as you suggested in #2. #4 is actually accounted for at the bottom of the details.css, however it doesn't need to be defined twice, so I've moved it from entity-meta.css over to elements.css.

lauriii’s picture

@AaronChristian I added the classes and rewrote the CSS accordingly. This allows us to do a few clean ups which I think is nice. What do you think about this?

AaronChristian’s picture

Status: Needs review » Reviewed & tested by the community

Hey @lauriii, awesome yeah I can see the scalability of this now. Nice addition!

Patch looks good, no problems with it's application.

ckrina’s picture

That's ok for me too. Both in the status page and in other places where details appear, like in node creation. Here are some screenshots (Chrome & iOS, but tested Firefox too).

tkoleary’s picture

One detail. There's not enough contrast now on checkboxes and radios with the darker background:

Can be solved with this:

input[type="checkbox"], 
input[type="radio"] {
    box-sizing: border-box;
    padding: 0;
    box-shadow: 0 1px 1px 2px rgba(0,0,0,0.3);
    border-radius: 4px;
}
input[type="radio"] {
  border-radius: 50%;
}

Which produces:

tkoleary’s picture

Issue summary: View changes
FileSize
127.62 KB

One other thing. There'a a bug where margin is being added to the top of the page:

It's because—for some reason—html has the details class.

You can fix it with:

html.details {
  margin: 0;
}

Or perhaps:

body .details {
  margin-top: 1em;
  margin-bottom: 1em;
  background-color: #fcfcfa;
  border: 1px solid #bfbfbf;
  border-radius: 3px;
}

Both of them work. I don't know why the details class is being added to <html>, but there must be a good reason so I would not remove it.

After these I think this can go back to RTBC.

AaronChristian’s picture

Cool thanks everyone for testing & feedback. @tkoleary, i agree the contrast is an issue. I have another issue going for restyling the checkboxes and radio buttons, these should fix the contrast problems.

Seven Style Guide: Checkboxes
Seven Style Guide: Radio Buttons

Some feedback on direction we should take would be good on the checkboxes issue I'm facing.

https://www.drupal.org/node/2856459#comment-11999010

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/themes/seven/templates/details.html.twig
@@ -0,0 +1,47 @@
+<details{{ attributes.addClass('details') }}>

I would suggest that we don't use a class name details. The class "details" is added to html because of how we have it configured. Is there any reason to add a class and not jsut theme the details element itself? I.e. do we envisage this css not applying to other details elements and do we want to apply it to things other than a details element?

Setting back to needs review to get opinions.

lauriii’s picture

Status: Needs review » Needs work

It is a bad practice to theme HTML tags directly since it forces that HTML tag always to have the same styles without proper variations or future support. If we would choose to style details HTML tag directly and we would have to introduce a new details element in the future, we would have to add a class for the details element, reset the default styles set for the tag and then apply any new styles.

There are few exceptions where not styling HTML tags directly would be very inconvenient (headings, paragraph etc) but even in these cases using classes would be more robust. I've themed elements directly in projects and in almost every case I've regretted it later because it makes refactoring or changing CSS more complicated than it should be.

In this case, I don't see any downsides in using classes. In my opinion, the only problem we have is to name this in a way it doesn't clash with the HTML element class.

lauriii’s picture

I postponed #2279049: Add a CSS animation to expanding of details elements on this one since it is applying styles that should belong to the component we are creating here.

alexpott’s picture

@lauriii totally happy to defer to your decision here - the main point of #37 was to point out why html was having the details class added. Not targeting HTML tags directly makes sense. So now we have to come up with a good class name...

AaronChristian’s picture

@lauriii @alexpott, what if we went with the "accordion" approach since it resembles that sort of component.

.accordion
.accordion__title
.accordion__details

or back to the basics...

.fieldset
.fieldset__title
.fieldset__details

Thoughts?

ben833’s picture

I would go with accordion, because that describes what it is.

lauriii’s picture

I think details is the best name for the component. Why don't we just prefix details with something? For example, something like .seven-details, or .drupal-details would work. I know it's a weird pattern but I think it's also weird if we call it to something else than what it is. We could also add a @todo about renaming it back to .details after we've managed to fix the polyfill (with a link to an issue where that would be done).

andrewmacpherson’s picture

.fieldset sounds like <fieldset>, which is a completely different thing semantically. So <details class="fieldset"> would be a bit mixed up IMO.

Accordion usually describes a group of (related?) collapsible elements, often having constraints such as only allowing one open at a time, or requiring at least one to be open. One details element on its own doesn't sound like an accordion.

.accordion doesn't sound match any HTML5 element name, like fieldset does, but the WAI-ARIA Authoring Practices 1.1 working draft uses the term accordion to refer to a stacked set of collapsible groups.

Why not generalize Seven's .entity-meta details {} as .accordion details {}? The style is only used on node forms just now, but it could be used elsewhere later on. The block placement UI had a similar looking accordion sidebar during 8.x-dev, before it was changed to use a dialog.

AaronChristian’s picture

Hey @andrewmacpherson, totally agree with everything you've said I pretty much reiterated everything you noted in your comment in our slack channel. Glad to see we're on the same track though!

What are everyone's thoughts on the terms "panel-set" & "panel". This sounds like it would be a bit more descriptive on what the component and sub-components entail. Also it removes the illusion of only have 1 "panel/pane" open at a given time (like "accordion" does).

Thanks for everyone's input on this issue.

lauriii’s picture

I'm fine with the panel. However, I still think we could revert to #43 to avoid bikeshed about the naming :)

tacituseu’s picture

Core already uses "panel" class for those admin blocks at /admin/config (see: core/modules/system/templates/admin-block.html.twig), it would make it even more confusing. ;)

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.

lauriii’s picture

Status: Needs work » Needs review
FileSize
6.3 KB

Rerolled to 8.6.x and changed the classname from details to seven-details.

lauriii’s picture

Issue summary: View changes
FileSize
55.32 KB

Just realized that this does make the modules page look a bit odd:

Anonymous’s picture

#50 looks nice!

#51: what is odd, dark-blue color of the for group labels? Was it not planned for detail labels?

lauriii’s picture

@vaplas I think the dark grey used on the rows looks a bit strange when placed on top of the other grey. Also between the rows, there's white which doesn't match with the details background color.

Here's another screenshot demonstrating all different shades of grey we have there:

andrewmacpherson’s picture

This was mentioned in the #ux Slack channel today. Could do with checking we still have focus states indicated clearly. Cross browser testing is important there, because default browser focus styles vary.

lauriii’s picture

This should address my feedback on the modules page.

lauriii’s picture

FileSize
92.71 KB

Here's still a screenshot of the modules page after.

mgifford’s picture

@lauriii do you have any idea why I can't install that patch on SimplyTest.me - that's generally how I quickly whip up a demo to test.

Alternatively, even posting the new HTML as a sample might be sufficient to see if it is following best practices.

andrewmacpherson’s picture

Status: Needs review » Needs work

Review of patch #55 follows. It introduces a regression, and I figured out why. The new details.html.twig template in Seven breaks the collapse.js polyfill.

Things work fine in latest desktop versions of Chrome, Opera, Firefox. I didn't test Safari.

However in IE11 and Edge, the details/summary behaviour stopped working:

  • After loading a page, all details elements were open.
  • Clicking the summary did NOT cause the details to open/close correctly. It remained open.
  • The <details open> attribute did toggle correctly, as did the aria properties from details-aria.js
  • The disclosure triangle icon toggled correctly between horizontal and down directions.

I reckoned it could be something to do with the collapse.js polyfill, which is used by IE11 and Edge. Chrome, Opera, and Safari have supported details/summary since long before D8.0.0 was released, and Firefox supported it from v49 onwards.

Before Firefox 49, details/summary was experimental, and could be enabled with the dom.details_element.enabled preference. Old Firefox releases are still available (very cool), and sure enough, patch #55 causes a regression in Firefox 48, but enabling the experimental details/summary report made the problem go away.

After lots of summary toggling and rooting around in dev tools, I found the problem. We have this rule in Stable theme's CSS, which controls whether the open details when using the polyfill:

.js details:not([open]) .details-wrapper {
    display: none;
}

The new .seven-details__wrapper in the new template doesn't match this. We can fix the regression by adding this style rule:

.js details:not([open]) .seven-details__wrapper {
  display: none;
}

It worked when I shoved this rule into browser dev tools. I'm pleased I caught this, I feel like a proper front-end developer today :-)

@lauriii - can you update the patch, and I'll retest?

@mgifford - maybe the simplytest.me failure you're experiencing is #2946730: Spawned instances get "The website encountered an error" message? If you get the message "The website encountered an unexpected error. Please try again later", that appears to be a timing issue while simplytest.me does a composer install. I experienced it today, and when I tried again immediately afterwards, I managed to install Drupal successfully.

andrewmacpherson’s picture

Forgot, I had another review point for patch #55:

diff --git a/core/themes/seven/css/components/details.css b/core/themes/seven/css/components/details.css

+.seven-details__summary:hover,
+.seven-details__summary:focus,
+.seven-details[open] > .seven-details__summary {
+  color: #004f80;
+}

I don't understand why we change the summary text colour when the details are open, but are not currently being interacted with hover or focus. That seems to diminish the usefulness of changing the colour for the hover and focus styles. The open details are already very clear, just from showing the content, and the disclosure triangle icon helps this. I suggest removing the .seven-details[open] > .seven-details__summary selector here, unless there's a special reason I've missed?

It's not really an accessibility issue though, because we're not relying on colour to tell the states apart.

andrewmacpherson’s picture

Patch #55:

What's the text-shadow for here? It's very hard to notice. The dark text colour has very good contrast against the background, so I don't understand what this text-shadow is for. It's in all the patches here, but isn't explained.

+.seven-details__summary {
+  cursor: pointer;
+  text-shadow: 0 1px 0 white;
+  color: #0074bd;
+}
lauriii’s picture

Status: Needs work » Needs review
Issue tags: -sprint +@sprint
FileSize
8.37 KB
1.01 KB

Thank you for the feedback! 😻It seems like there's some other styles attached to that element as well. Even though this is not the cleanest approach for solving this, I think this would be the least likely to break something.

@andrewmacpherson those design decision has been made a long time ago so it might be difficult to track down the specific reasons for those decisions.

lauriii’s picture

Issue tags: -@sprint, -SprintWeekend2017

Removing some old tags

andrewmacpherson’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs accessibility review +Needs followup

RTBC:
The patch in #61 fixes the issues I found in #58 with the collapse.js polyfill.

I tested in IE11 (win 10), Edge (Win 10), Opera (linux, mac, win), Chrome (mac, win), Safari (mac), Safari (iOS), Chrome (Android).
Open closed box size, and disclosure triangle icon all work right.

Needs follow-up:
I noticed inconsistency with focus styles - sometimes there was a focus indicator, sometimes not. In some browsers (chrome + opera on mac) the summary element got an underline on when it was focused, but in others (safari on mac?) it didn't. I noticed this halfway though the long list of browsers, and didn't go back to check them all over again ;-)

We need a clear visual focus style for the summary element. In the case where the focused summary doesn't get an underline, the only indication is a slight colour change, which is a failure of WCAG 1.4.1 Use of Color (level A). Since the colour change on focus is so slight, it's also a failure of WCAG 2.4.7 Focus Visible and 1.4.11 Non-text contrast (both level AA).

Now, Proposal: A Style Guide for Seven doesn't actually have a focus style for the summary element. We definitely need to make summary focus visible in all browsers, so lets investigate an fix that in a follow-up.

andrewmacpherson’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 61: 2854624-61.patch, failed testing. View results

Gábor Hojtsy’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs followup

Looks like the followup was opened. Also @lauriii sent it for a retest.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs followup

Reviewed for commit. There are two @todo comments, the second one does not even sounds actionable. Since neither has an issue link, completing them blocks this issue. If there are issues and they are referenced in the patch (and briefly explained) then this would be good to go.

lauriii’s picture

Good catch! 🕵️‍♂️ I improved the comments and linked them to follow-up issues.

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

#67 has been done as requested.

Gábor Hojtsy’s picture

Thanks! I wanted to go check what does this patch do, now that I was done with code review. This is what the issue summary suggests:

I did not expect exactly that given the lack of applying that font in core. However the issue summary says this issue is to restyle radio buttons and checkboxes. All changes that I managed to notice were that these triangles are now there. Coloring is still as before, radio buttons are still as before, etc:

lauriii’s picture

@Gábor Hojtsy did you clear caches after applying the patch? It should indeed look like the issue summary.

andrewmacpherson’s picture

I don't see any change to the radio button styling either, testing with a brand new simplytest.me installation. Checked on latest Firefox, Chrome, Opera, Edge, and IE11; not Safari though.

In earlier testing I didn't actually realize we we changing the radio buttons; I thought it was just the details/summary elements.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

Checkboxes and radio buttons are/were in #2856459: Seven Style Guide: Checkboxes & Radio Buttons which is why I asked what should we be looking for here. Issue summary is definitely not up to date yet.

lauriii’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update
FileSize
107.05 KB
136.66 KB

Updated the proposed resolution.

Gábor Hojtsy’s picture

Issue summary: View changes
Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the update and guidance on where to look. I removed the misleading prior screenshot from the summary. Verified the patch looks like what the issue summary says *now* :)

Gábor Hojtsy’s picture

Gábor Hojtsy’s picture

Title: Details and Accordion » Details and accordion update based on Seven Style Guide
Status: Reviewed & tested by the community » Fixed

Committed 4e8c573 and pushed to 8.6.x. Thanks!

  • Gábor Hojtsy committed 4e8c573 on 8.6.x
    Issue #2854624 by lauriii, AaronChristian, vaplas, yogeshmpawar,...
lauriii’s picture

🚀🙌🎉

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.