Follow-up to #1342054: [META] Clean up templates and CSS
Problem/Motivation
Bartik's code needs to follow Drupal's CSS Coding Standards.
Proposed resolution
Follow the guidance in the META to cleanup the code for the "skip-link" component.
skip-link's CSS can be found in css/component/skip-link.css in Bartik.
Remaining tasks
Write a patch
Visual review of the patch - check nothing is broken or introduced any CSS regressions.
Code review of the patch - check the work being carried meets standards and the changes make sense.
User interface changes
None, we are not changing the design/UI of Bartik, this is a code cleanup task.
API changes
n/a
Comment | File | Size | Author |
---|---|---|---|
#33 | Screen Shot 2015-02-21 at 09.45.14.png | 71.71 KB | emma.maria |
#32 | rtl-screenshot.png | 175.63 KB | andybroomfield |
#32 | ltr-screenshot.png | 178.44 KB | andybroomfield |
#31 | 2409069-31.patch | 1.43 KB | idebr |
#29 | 2409069-28-rtl-after.png | 19.26 KB | idebr |
Comments
Comment #1
Schnitzel CreditAttribution: Schnitzel commentedComment #2
Schnitzel CreditAttribution: Schnitzel commentedUsing this as an example on how to commit a patch at #SprintWeekend Switzerland
Comment #3
Schnitzel CreditAttribution: Schnitzel commentedFor a start, added correct file description. Needs more review!
Comment #4
emma.mariaUnassigning so someone can review.
Comment #5
zach.bimson CreditAttribution: zach.bimson commentedNoticed issue with commenting standards, patch attached
Comment #6
Kathode CreditAttribution: Kathode commentedI reviewed the code in patch #3 with CSS coding standards and it looked fine to me.
Comment #7
theMusician CreditAttribution: theMusician commentedI agree about removing the whitespace after the comment that zach.bimson posted.
The patch still applies cleanly and the skip-link functionality still works well.
Marking as RTBC
Comment #8
zach.bimson CreditAttribution: zach.bimson commentedAfter having a similar patch reviewed and an update suggested, I've created new patches in accordance to the suggestions. The second comments seems unnecessary but ive provided so we can get this though the queue.
Comment #9
theMusician CreditAttribution: theMusician commentedLooks good here. The @file docblock does make sense. It states in the manual it should be there, I apologize for missing that on the initial review. https://www.drupal.org/node/1887862#comments
I agree that the second comment is not necessary. The preceding docblock declares that the file contains styles for the skip-link rule sets.
Comment #10
zach.bimson CreditAttribution: zach.bimson commentedThanks for the clarity, i guess comments can never be too informative!
Comment #11
zach.bimson CreditAttribution: zach.bimson commentedCreated this... can someone check itIssue
Comment #12
LewisNymanThis is redundant when we have the comment above.
I think there is also more we could do to clean up this file. See What to look for when reviewing CSS. I've attached a text file of the whole file so we can review the code using Dreditor
Comment #13
LewisNymanDo we need this additional selector? I'm not sure we do
I don't know why we are resetting margin top here because it's not set anywhere
I don't see the need for important here.
Width auto is the default value, I don't know why we have this
Do we need these selectors? It would be to remove them and see if it affects anything.
Also, is there any reason why we can't merge these properties into the selector above?
We should add an em unit to the end of here
Text-decoration: none is already set for links in Bartik. I don't htink we need this
Can we also try and merge this in to the selector and see if it still works?
I also noticed that we need to unset the border bottom that is being set on all links.
Comment #14
andybroomfield CreditAttribution: andybroomfield commentedPatch following up on LewisNyman comments.
I've had to keep the .skip-link.visually-hidden.focusable selector in place, as without it, the position is overridden with position:static !important by
visually-hidden.focusable:focus in system.module.css. This is also why position: absolute needs the !important at the end.
Comment #15
LewisNymanThat is annoying, but I guess we have to live with it in this issue. I'm happy with the improvements we've made here.
Comment #16
alexpottThe hover and focus states now look completely different.
Comment #17
andybroomfield CreditAttribution: andybroomfield commentedTested on Chrome and Firefox, seems to be ok, will try looking at some other browsers.
Might have to add the :visited and :hover selectors.
Chrome Screenshots
Firefox Screenshots
Comment #18
emma.mariaThe visual change is the border bottom on the skip link component. We did not anticipate finding any css regressions in these issues but as the skip link is mostly hidden, this was a discovery during the work carried out.
The change was suggested in #13 as a regression that has been missed previously.
The border comes from this code..
The border bottom on the skip link should not exist. Why would we have just a border bottom on a curved element? It does not come from the skip link styles, it is a regression introduced from the generic link styles overpowering this component and no one has picked up on this.
As the skip link does not need a hover state, only appears on focus and it's popping up on the screen is enough visual cue alone as an action, I agree with removing the border. Therefore this issue will contain a visual change for Bartik.
Before:
After:
The skip link still functions as it should. If @LewisNyman is happy with the code cleanup aspect, this issue is RTBC.
But first the patch no longer applies so it needs a reroll!!!
Comment #19
andybroomfield CreditAttribution: andybroomfield commentedI spent some time trying to remember how to do re rolling from the Sprint at Drupal Camp Brighton.
I think this should be the correct patch.
Comment #20
LewisNymanThanks! Almost there
We need a blank line at the end of every file, there's a way to set up your text editor config to automatically add a blank line
Comment #21
andybroomfield CreditAttribution: andybroomfield commentedOk, newline added.
Comment #22
idebr CreditAttribution: idebr commentedThis comment could use a preposition, eg. 'Styles for the skip link.'
This selector is very specific and only overrides the position attribute. Let's move it to a separate selector, so it becomes clear why it is so specific.
This margin can be removed, since the
<a>
tag has no margin by default.All elements that are
position:absolute;
are automatically treated asdisplay: block;
, so this attribute can be removed.This attribute is trying to center the element, but only takes an approximation. I suggest using transform: translateX(-50%) to actually center the element.
Comment #23
andybroomfield CreditAttribution: andybroomfield commentedNew Patch following on from idebr's comments.
I had to also move the border-bottom: none and color: #fff into the .skip-link.visually-hidden.focusable
I'm unsure about translateX(-50%) on the margin-left since I don't know how far back browser support is needed, Particularly as Bartick is the default theme. If I can use it i'll make a new patch.
Comment #24
idebr CreditAttribution: idebr commentedDrupal 8 supports IE9+ and the usual suspects. For reference on transform, see http://caniuse.com/#feat=transforms2d
Comment #25
idebr CreditAttribution: idebr commentedA few pointers if you are still working on this:
The last 10px can be removed, since it is inferred so it becomes
padding: 1px 10px 2px;
These styles overrides
a:focus
. The appropriate selector to override this selector would be.skip-link:focus
. Alternatively you can remove the border with a single attributeborder-bottom-width: 0;
on.skip-link
Comment #26
andybroomfield CreditAttribution: andybroomfield commentedThanks idebr, New patch attached.
Comment #27
idebr CreditAttribution: idebr commentedThanks for picking this up, andybroomfield! Just a few more things and then this is good to go :)
This selector needs to stay at
.skip-link.visually-hidden.focusable:focu
s to win specificity over.visually-hidden.focusable:focus
The declaration has to be separated with a space, eg.
border-bottom-width: 0;
The RTL declarations can be removed entirely, since the element is centered anyway. This means the /* LTR */ comments can be removed from the other attributes as well.
Comment #28
andybroomfield CreditAttribution: andybroomfield commentedThanks idebr, amended patch attached.
Comment #29
idebr CreditAttribution: idebr commentedThat's quite a cleanup, thanks andybroomfield:). I'll leave this for emma.maria to sign off as she is the maintainer for Bartik.
Screenshots after to prove nothing broke:
Comment #30
emma.mariaI could not get the patch to apply. Needs a reroll.
Comment #31
idebr CreditAttribution: idebr commentedReroll after #2398447: Remove the "typography" CSS file in Bartik was committed.
Comment #32
andybroomfield CreditAttribution: andybroomfield commentedPatch applies ok now.
Adding screenshots to show new patch is working.
Comment #33
emma.mariaPatch applies cleanly.
The skip-link appears on focus and looks as it should, both LTR and RTL as shown by the screenshots in #32.
Visual changes within this issue have been discussed in #18.
The code looks so much cleaner and we have stripped out everything not needed by skip link to function correctly.
I think this issue can be set to RTBC.
Comment #34
webchickWow, great work all! I tried this out and indeed only saw the skip content link when it received focus.
Committed and pushed to 8.0.x. Thanks!