Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LewisNyman’s picture

FileSize
1.26 KB
LewisNyman’s picture

Issue summary: View changes
joaogarin’s picture

There is some dependency to elements like summary or strong which would be nice to avoid so that these elements could be for example replaced by another element and not getting the layout broken but that would require some HTML modifications to the vertical tabs

LewisNyman’s picture

Yeah that's what I'm thinking. Currently we have:

.vertical-tabs 
.vertical-tabs-list 
.vertical-tab-button
.vertical-tab-button a
.vertical-tab-button.selected strong
.vertical-tab-button .summary 
.vertical-tabs-pane 

My suggestion would be:

.vertical-tabs 
.vertical-tabs__menu 
.vertical-tab__menu-item
.vertical-tab__menu-item a /* Kind of hope we can kind a way to get rid of this */
.vertical-tab__menu-item.is-selected .vertical-tab__menu-item-title
.vertical-tab__menu-item-summary 
.vertical-tabs__pane 
joaogarin’s picture

Yes I like the structure and the naming is much more clear. The fact that right now the list item is called "vertical-tab-button" does not make any sense at all.

Regarding the anchor if it really differs from a general anchor than it would need a class (which could actually be the .vertical-tab__menu-item__button) Looks a bit overdoing it but really its something that can help in case for example some theme wants to extend seven.

Not sure if that is something that for some reason might be more complicated. I will look a bit into this code to get a more clear perception of it.

joaogarin’s picture

Status: Active » Needs review
FileSize
11.49 KB
462.25 KB
460.09 KB
429.76 KB
436.55 KB

Hello,

Making a patch of this issue. I tested in all themes (classy, bartik and seven).I actually made the changes to the following files :

core/misc/vertical-tabs.js
core/themes/seven/css/components/vertical-tabs.css
core/misc/vertical-tabs.css
core/themes/bartik/css/components/vertical-tabs.component.css

I actually had to maintain ul.vertical-tabs__menu in the Bartik override for some reason as stated in the comment that was already there. It needs to override .region-content ul

I added the following naming as suggested :

.vertical-tabs 
.vertical-tabs__menu 
.vertical-tab__menu-item
.vertical-tab__menu-item a /* Kind of hope we can kind a way to get rid of this */
.vertical-tab__menu-item.is-selected .vertical-tab__menu-item-title
.vertical-tab__menu-item-summary 
.vertical-tabs__pane 

And added also these :

.vertical-tab__menu-item-title /* To replace the strong rule */
.vertical-tabs__panes /* For the panes wrapper */

And changed changed some modifiers.

I am attaching some screens, please review. Also I am not sure about the naming of the patch file I put the project name as "drupalcore".

joaogarin’s picture

Hello,

Just making a minor fix to the latest patch there where some "strong" elements that where still not using the proper class name.

Please take a look at line 25 of the js script. I changed this class there but I am not sure about it.

I tested and it seemed okay, also without JS (the default "detail" elements rendered okay).

LewisNyman’s picture

Status: Needs review » Needs work

Great work! I went of the CSS in all the themes and found a few optimisations we could make.

  1. +++ b/core/misc/vertical-tabs.css
    @@ -1,3 +1,7 @@
    + * Vertical Tabs
    

    We need a full stop at the end of this comment.

  2. +++ b/core/misc/vertical-tabs.css
    @@ -15,52 +19,52 @@
     /* Layout of each tab */
    

    We also need a full stop here

  3. +++ b/core/misc/vertical-tabs.css
    @@ -15,52 +19,52 @@
    +.vertical-tabs__menu-item {
       margin: 0;
       padding: 0;
    

    It looks like we can remove these properties as they don't do anything

  4. +++ b/core/themes/bartik/css/components/vertical-tabs.component.css
    @@ -1,9 +1,14 @@
    + * Vertical tabs Component
    

    'Component' should be lowercase, we also need a full stop here.

  5. +++ b/core/themes/bartik/css/components/vertical-tabs.component.css
    @@ -1,9 +1,14 @@
    -ul.vertical-tabs-list {
    +ul.vertical-tabs__menu {
    ...
    -[dir="rtl"] ul.vertical-tabs-list {
    +[dir="rtl"] ul.vertical-tabs__menu {
    

    We can remove the element from this selector

  6. +++ b/core/themes/seven/css/components/vertical-tabs.css
    @@ -17,32 +19,32 @@
    +.vertical-tabs__menu-item {
    ...
       margin: 0;
       list-style: none;
       list-style-image: none;
    

    These three properties don't see to do anything

  7. +++ b/core/themes/seven/css/components/vertical-tabs.css
    @@ -50,60 +52,60 @@
       text-decoration: none;
    ...
       text-decoration: none;
    

    We can remove text-decoration: none from the links as that is the default styling

joaogarin’s picture

for some reason in Bartik theme I cant remove the element from the selector or it gets overriden.

I will try again and provide some screens.

joaogarin’s picture

Status: Needs work » Needs review
FileSize
11.67 KB
357.71 KB
358.18 KB

Hello,

I am attaching a patch with these fixes. On the bartik theme I had to put the following selector :

.vertical-tabs .vertical-tabs__menu

otherwise it would be overriden with the .region-content ul selector and misplace the tabs adding a different margin.

I am also attaching some images.

Also by removing the

text-decoration: none;

from the :hover effect it now has a underline effect on hover but I guess that is also common behaviour?

idebr’s picture

Status: Needs review » Needs work

@joaogarin Thanks for working on this; it is looking much better already!

  1. I am attaching a patch with these fixes. On the bartik theme I had to put the following selector :

    .vertical-tabs .vertical-tabs__menu

    otherwise it would be overriden with the .region-content ul selector and misplace the tabs adding a different margin.

    Yes, this is fine. The selector already has a comment mentioning the selector is overqualified:
    /* This is required to win specificity over [dir="rtl"] .region-content ul */

  2. Also by removing the

    text-decoration: none;

    from the :hover effect it now has a underline effect on hover but I guess that is also common behaviour?

    The proposed resolution for this patch is to leave the design as is, but only update the CSS in line with our coding standards. The text-decoration is also currently in line with the style guide for Seven, so let's leave it as is currently in HEAD.

Otherwise, this seems ready to go :)

LewisNyman’s picture

Issue tags: +Novice

Seems like this one-line change is a novice task

pjbaert’s picture

Assigned: Unassigned » pjbaert
pjbaert’s picture

Status: Needs work » Needs review
FileSize
11.66 KB
484 bytes

I added the 'text-decoration: none;' line.

pjbaert’s picture

Assigned: pjbaert » Unassigned
geertvd’s picture

Status: Needs review » Reviewed & tested by the community

Feedback in #11 has been taken care of, I think this can go to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#2431671: [meta] Add in js- prefixed classes for separation of JS & CSS functionality
  1. +++ b/core/misc/vertical-tabs.js
    @@ -21,8 +21,8 @@
    -        var $this = $(this).addClass('vertical-tabs-panes');
    ...
    +        var $this = $(this).addClass('vertical-tabs__panes');
    

    Shouldn't this class be prefixed by js- because it is javascript only. Also is actually needed can't we just use [data-vertical-tabs-panes]

  2. +++ b/core/misc/vertical-tabs.js
    @@ -48,7 +48,7 @@
    -            .addClass('vertical-tabs-pane')
    +            .addClass('vertical-tabs__pane')
    

    Also this appears to be javascript only. Isn't all of vertical tabs JS only? Perhaps we should be thinking about #2431671: [meta] Add in js- prefixed classes for separation of JS & CSS functionality

joaogarin’s picture

Yes the vertical tabs are really js only so I guess adding a js prefix is not a bad idea at all!

I will try to have a look into this today or tomorrow and get a patch here.

LewisNyman’s picture

Also see the discussion in #2278473: Simplify Dropbutton markup in line with our CSS standards:

The coding standards provide specific directions on this:

/**
* Functional JavaScript Hooks
*
* When querying or manipulating the DOM from JavaScript, prefer dedicated
* classes not used for styling (or the id attribute).
* If using classes, prefix them with 'js-' to mark them for JS use.
* These 'js-' classes should not appear in stylesheets.
*/
.js-behaviour-hook /* e.g. .js-slider, .js-dropdown */

Which means, if we need a class for js functionality, we should use a new class that is only used for functionality, not just adapt the classes we use for styling. We shouldn't have any .js- prefixed classes in stylesheets.

LewisNyman’s picture

If javascript is adding a class for styling purposes, then it should not be prefixed with .js-, if it adds a class for functional purposes, then it should be prefixed with .js (or a data attribute)

joaogarin’s picture

;) good.

So can you can check the patch to see if there is something missing? I will take another look as well to see if something comes up

joaogarin’s picture

Status: Needs work » Needs review

Had a look into #14. Look good to me

krisp1’s picture

Investigating this @ Drupal South.

krisp1’s picture

Patch #14 applied without error. Now I must study the new CSS coding standards in depth .

joaogarin’s picture

Hello,

I applied the patch just two days ago and It was okay. I will give a crack at it today as well to see if its okay.

My brother is in @ Drupal South nickname kyuubi! Have fun =)

joaogarin’s picture

resubmitting #10 with that extra one line of text-decoration: none;

LewisNyman’s picture

Status: Needs review » Needs work
FileSize
494.71 KB
593.44 KB
553.87 KB

Ok, this is looking good! I've attached some screenshots from Seven, Bartik, and Classy.

+++ b/core/themes/bartik/css/components/vertical-tabs.component.css
@@ -1,9 +1,14 @@
-ul.vertical-tabs-list {
+.vertical-tabs .vertical-tabs__menu {
...
-[dir="rtl"] ul.vertical-tabs-list {
+[dir="rtl"] .vertical-tabs .vertical-tabs__menu {

We can remove the .vertical-tabs class from these selectors

Maninders’s picture

Status: Needs work » Needs review

This issue is looked resolved, changing status from needs work to needs review.

Maninders’s picture

Issue tags: +SprintWeekend2015

Adding SprintWeekend2015 tag.

LewisNyman’s picture

Status: Needs review » Needs work

@Maninders The comment in #27 is not resolved

Anonymous’s picture

Assigned: Unassigned »

I'll make this cleanup fix.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
704 bytes

I have cleaned css selectors. Please review.

LewisNyman’s picture

Status: Needs review » Needs work

The latest patch is missing the changes from the patch in #26

rpayanm’s picture

LewisNyman’s picture

Assigned: » Unassigned
Status: Needs review » Reviewed & tested by the community

Nice, thanks for all the hard work in this issue.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 34: 2408511-34.patch, failed testing.

Status: Needs work » Needs review

rpayanm queued 34: 2408511-34.patch for re-testing.

rpayanm’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Manually tested - looks like nothing has changed which is great. However considering we are renaming all the classes here I think we should be prefixing them all with js- as per the standards.

LewisNyman’s picture

Status: Needs work » Reviewed & tested by the community

@alexpott the standards state that js- prefixes should only be used when they are required for JS functionality. If a class is added with Javascript for styling purposes than it should not be prefixed with js-. There should be no js- prefixed classes in CSS:

Separate style from behavior by using dedicated classes for JavaScript manipulation rather than relying on classes already in use for CSS. This way, we can modify classes for style purposes without fear of breaking JS, and vice versa. To make the distinction clear, classes used for JavaScript manipulation should be prefixed with 'js-'. These JavaScript hooks must never be used for styling purposes. See the section ‘Formatting Class Names’ for more information on naming conventions.

+++ b/core/misc/vertical-tabs.js
@@ -21,8 +21,8 @@
       $(context).find('[data-vertical-tabs-panes]').once('vertical-tabs', function () {

We are already using a data attribute to initialise JS functionality

alexpott’s picture

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

@LewisNyman - ah good - thanks for letting me know that - makes complete sense to me. I think other issues have been attempting to add js- to classes incorrectly then. I'll be on the look out. Given that all the browsers we support also support data attributes should we ever see any js- classes?

Needs a reroll.

pjbaert’s picture

Status: Needs work » Needs review
FileSize
11.64 KB
677 bytes

Rerolled the patch.

LewisNyman’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll

The reroll after #2348321: Upgrade to jQuery Once 2.x looks correct. Thanks!

The last submitted patch, 34: 2408511-34.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 42: 2408511-42.patch, failed testing.

rpayanm queued 42: 2408511-42.patch for re-testing.

rpayanm’s picture

Status: Needs work » Reviewed & tested by the community

Again

LewisNyman’s picture

Given that all the browsers we support also support data attributes should we ever see any js- classes?

I am unsure on the official policy, but it seems that the preference is data attributes where possible: #1090592: [meta] Use HTML5 data-drupal-* attributes instead of #ID selectors in Drupal.settings #2180921: [META] Use data attributes rather than classes wherever possible

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

CSS and JS is not frozen in beta. Committed e73ce6e and pushed to 8.0.x. Thanks!

  • alexpott committed e73ce6e on 8.0.x
    Issue #2408511 by joaogarin, pjbaert, rpayanm, bobrov1989: Rewrite...
nod_’s picture

Issue tags: +JavaScript
idebr’s picture

+++ b/core/themes/seven/css/components/vertical-tabs.css
@@ -50,60 +49,59 @@
-.vertical-tab-button.selected a,
-.vertical-tab-button a:hover,
-.vertical-tab-button a:focus {
+.vertical-tabs__menu-item.is-selected a,
+.vertical-tabs__menu-item a:hover,
+.vertical-tabs__menu-item a:focus {
   background: #fcfcfa;
   text-shadow: none;
-  text-decoration: none;
 }

This change is unintended (see #11.2) and introduced a regression where vertical tabs text is underlined in the hover/focus/selected state. I have opened a followup at #2459607: Seven vertical tabs have underlined links in hover/focus state.

Status: Fixed » Closed (fixed)

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