Problem/Motivation
The shortcut module has CSS that doesn't follow the guidelines set forth by the CSS Cleanup effort (http://drupal.org/node/1089868).
Proposed resolution
Generalize CSS selectors and remove styling where it should be left to the theme to style.
Remaining tasks
None
User interface changes
None. CSS in the Core module is simplified, but does not affect the look of the interface.
API changes
None
Original report by johnvsc
// This is a copy/paste from the CSS Cleanup page
Part of the CSS Cleanup effort: http://drupal.org/node/1089868
Overview of Goals
- Make it easy to remove unwanted design assumptions in the theme layer, while maintaining critical functionality (such as functional JavaScript widgets).
- Prevent uneeded administrative styles from loading on the front end.
- Give modules the ability to include a generic design implementation with their module, without burdening themers.
- Make CSS and related markup more efficient and less intrusive to improve the themer experience.
The CSS Clean-up Process
Use the following guidelines when writing patches for the core issues listed below.
- Put CSS is in the appropriate file: CSS should be moved to separate files, using the following
name spacing conventions based on their purpose:
- module.base.css
- Should hold structural and behavior related styling. CSS should be coded against the Stark theme. The absolute bare minimum CSS required for the module to function should go here. If there is no CSS required, this file should be omitted.
- module.theme.css
- Should hold generic design-related styles that could be used with Stark and other themes. It's where all design assumptions like backgrounds, borders, colors, fonts, margins, padding, etc, would go.
- module.admin.css
- Should hold styles that are only applicable to administrative pages.
To see an example of this in practice, look at Drupal's system module.
- Remove Assumptions: Styles that make too many assumptions, introduce superflous margins, padding and add things like font settings are not necessary and don't belong in core module CSS files. In cases where core themes depend on these properties, they should be moved to the CSS stylesheet of the respective theme.
- Reduce Selector Specificity: CSS code that resides in modules should be written in a way that's easily overridable in the theme layer. To improve the Themer Experience and make core CSS more efficient, CSS selectors should be made as general and short as possible. For example:
- Use
.style {} over div.style {} where possible.
- Use
.module .style {} over div.module div.somenestedelement .style where possible.
- Don't use IDs in selectors: Use of ID's in core CSS selectors requires more specificity in the theme layer, making it harder and more annoying to deal with. It makes achieveing consistency in complex design implementations much harder than it needs to be. We need to stop making life hard for theme developers.
- Don't be afraid to change markup: There's lots of overlap between using proper and semantic markup and doing CSS right. If you come across a case where CSS is being applied where using a more semantic elements would solve the problem, then change the markup in your patch to make it right. For more information, see the Drupal 8 Markup Gate rules.
- Start with Stark and cross-browser test.
- "Design" markup and CSS for the Stark theme.
- If applicable, adapt the styles to match the core themes afterward.
- Finally, test the changes in all supported browsers and ensure no regressions are introduced.
Comments
Comment #1
David_Rothstein commentedThere's already an issue for cleaning up the CSS at #724782: Clean up the shortcut module's CSS.
I'm retitling this to describe what sounds like the main goal of this issue that makes it different from that one.
Comment #2
jyve commentedComment #3
jyve commentedCleaned up the css and renamed the css files to indicate the difference between frontend and backend.
Most of the feedback in #742184: Shortcut.module integration was incorporated into this patch.
To answer the question in #724782: Clean up the shortcut module's CSS: the separation between front and backend seems indeed wrong, but the fact that adding/removing a shortcut can be done from the front- and the backend makes it necessary for most of the css to be in shortcut.theme.css.
Comment #4
jacineI closed #724782: Clean up the shortcut module's CSS, so we can continue to work here.
Also, linking the issue where @sun had done some work per David in the closed issue: #742184-2: Shortcut.module integration
Thanks for getting started on this @jyve!
Comment #5
jyve commentedI had another look at this patch, and with the feedback on other patches, learned that seperation between theme and base.css was needed.
Comment #6
idflood commentedPatch in #5 looks nice and is working well. Here is a little bit more cleanup, maybe too much but it doesn't break anything in firefox and chrome as far as I've tested.
Summary of changes made to the patch in #5:
-
span.icon andspan.text- some "ul li" became simply "li"
Comment #8
idflood commented#6: shortcut-1217038-6.patch queued for re-testing.
Comment #10
jyve commentedhi idflood, your changes seem to make sence to me!
Comment #11
idflood commentedHere is a reroll of patch in #6.
Comment #12
jyve commentedJust tested the patch in #11, and looks great.
Since we are ironing out the details, I fixed three missing spaces between properties and values.
Comment #13
idflood commentedThe last patch is missing the new file, judging the filesize. I think that you need to do something like this:
git add -N modules/*
git diff HEAD > tmp.patch
Comment #14
jyve commentedow shoop, this should be better.
Comment #16
xjmTagging as novice for the task of rerolling the Drupal 8.x patch on account of #22336: Move all core Drupal files under a /core folder to improve usability and upgrades.
If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.
Comment #17
jyve commentedRerolled the patch against the new folder structure, and added @file headers.
Comment #18
xjmUntagging since it was rerolled. :)
Comment #19
aspilicious commentedNeeds reroll
Comment #20
jacineTagging for the next sprint.
Comment #21
aspilicious commentedUpdated patch
Comment #22
dcmouyard commented/* LTR */comment on all properties changed in RTL style sheets.Comment #23
aspilicious commentedkLmnoP
L before P
17 days to next Drupal core point release.
We don't need webkit border radius anymore. We decided that in an other issue. Border works fine on every webkit browser these days.
17 days to next Drupal core point release.
Comment #24
dcmouyard commentedComment #25
jyve commentedPatch in #24 tested, and looks perfect to me.
Comment #26
kenwoodworth commentedI tested the patch in #24 and it looks good to me.
Comment #26.0
kenwoodworth commentedAdd the CSS cleanup documentation.
Comment #27
catchThis looks like good cleanup. Committed/pushed to 8.x.
Comment #29
abdul24 commentedClosed #666698: Add-remove-shortcut link issues as a duplicate of this issue.
Comment #29.0
abdul24 commentedAdded issue summary