Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Part of the CSS Cleanup: 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 {}
overdiv.style {}
where possible. - Use
.module .style {}
overdiv.module div.somenestedelement .style
where possible.
- Use
- 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.
Comment | File | Size | Author |
---|---|---|---|
#13 | filter_css_cleanup-1217000-13.patch | 3.97 KB | jyve |
#10 | 1217000-filer-10.patch | 4.7 KB | aspilicious |
#6 | filter-1217000-6.patch | 4.02 KB | jyve |
#4 | filter-1217000-4.patch | 3.81 KB | jyve |
#3 | filter-1217000-3.patch | 3.21 KB | jyve |
Comments
Comment #1
marcingy CreditAttribution: marcingy commentedComment #2
jyve CreditAttribution: jyve commentedgoing to have a look at this one...
Comment #3
jyve CreditAttribution: jyve commentedAn overview of the content of this patch:
This only affects the weight dropdown that is hidden by default anyway.
As far as I see, no checkboxes will ever be rendered in the ordering table.
The 100% width is already added by vertical-tabs, so setting it as a default does not seem necessary.
Comment #4
jyve CreditAttribution: jyve commentedForgot to update a reference to filter.css, new patch attached.
Comment #5
xjmThanks for your work on this patch. Note that the Drupal 8.x patch will need to be rerolled, because the core directory structure for Drupal 8 has now changed. (For more information, see #22336: Move all core Drupal files under a /core folder to improve usability and upgrades). When the patch has been rerolled, please set the issue back to "Needs Review."
Tagging as novice for the task of rerolling the Drupal 8.x patch.
If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.
Comment #6
jyve CreditAttribution: jyve commentedPatch rerolled against new Drupal folder structure.
Comment #8
jyve CreditAttribution: jyve commented#6: filter-1217000-6.patch queued for re-testing.
Comment #9
xjmThanks @jyve for the reroll.
Comment #10
aspilicious CreditAttribution: aspilicious commentedSmall change in the rtl section.
Comment #11
aspilicious CreditAttribution: aspilicious commentedNeed to reorder the css (alphabeticly)
Comment #12
xjmI think this is the only class that is out of order.
Comment #13
jyve CreditAttribution: jyve commentedcomment in #12 fixed in this new patch.
Comment #14
timcosgrove CreditAttribution: timcosgrove commentedThis patch (#13) applies cleanly for me. Tested against English, RTL style tested against Arabic. Everything seems to work well.
Comment #15
catchLooks like good clean-up. Committed/pushed to 8.x.
Comment #16
andypostfilter.admin.css is lost in commit
Comment #17
webchickCommitted the missing files.
Comment #18.0
(not verified) CreditAttribution: commentedUpdated issue summary.