Problem/Motivation
Drupal core's CSS is not properly architected to be Predictable, Reusable, Maintainable, and Scalable. It leads to problems like the pitfalls described at http://drupal.org/node/1887918#pitfalls. It makes our aggregation strategy awkward because we have to artificially force all theme-level CSS after module-level CSS. And it is difficult for Drupal themes to provide lean CSS that doesn't break core functionality.
Proposed resolution
Over in #1891580: [policy] Finally agree on CSS coding standards, the front-end developers of Drupal agreed to attempt a new CSS architecture strategy in Drupal 8. Details of this strategy can be found at http://drupal.org/node/1887918 and http://drupal.org/node/1887922
Some dream mark up has been prototyped as static html in the Seventy Eight Style guide prototype.
Remaining tasks
These tasks are dependent on each other and should be tackled in this order
- #1924368: Rename old CSS constants to CSS_AGGREGATE_* and add new CSS weight constants
- #1924430: Add drupal.base library for base CSS styles
- #1924436: Remove separate CSS_AGGREGATE_SYSTEM aggregate file and fix drupal_add_library() to aggregate CSS properly
- #1109854: Overly aggressive transliteration in drupal_clean_css_identifier removes underscores from classes or #2009584: Allow double underscores to pass through drupal_clean_css_identifier as per new CSS standards
- #1987066: Rename files to match CSS file naming convention - core patch that incorporates all the following work from the Mobile Initiative sandbox:
- #1925320: Rename various CSS files to match new file naming convention
- #1924700: Rename system CSS files to match new file naming convention
- #1981022: Rename book module CSS files to match new file naming convention
- #1981026: Rename comment CSS files to match new file naming convention Assigned to: kim.pepper
- #1981024: Rename contextual CSS files to match new file naming convention
- #1981028: Rename edit CSS files to match new file naming convention Assigned to: echoz
- #1981038: Rename field CSS files to match new file naming convention Assigned to: criticny
- #1981036: Rename forum module CSS files to match new file naming convention Assigned to: akmalfikri
- #1981046: Rename help module CSS files to match new file naming convention Assigned to: carwin
- #1981048: Rename image CSS files to match new file naming convention Assigned to: echoz
- #1981050: Rename node CSS files to match new file naming convention Assigned to: kim.pepper
- #1981020: Rename openid CSS files to match new file naming convention
- #1981054: Rename shortcut module CSS files to match new file naming convention Assigned to: akmalfikri
- #1981072: Rename simple_test CSS files to match new file naming convention Assigned to: svenryen
- #1981080: Rename taxonomy CSS files to match new file naming convention Assigned to: mtift
- #1981074: Rename Tour module CSS files to match new file naming convention
- #1981090: Rename update CSS files to match new file naming convention
- #1981096: Rename user CSS files to match new file naming convention Assigned to: davidseth
- #2015789: Remove language_css_alter() (RTL stylesheets) in favor of HTML 'dir' attribute
- #1839318: Replace drupal.base.css library with normalize.css for all themes
- #1473066: [Meta] Move third-party assets out of core/misc folder
- Update/apply patches left over from the HTML5 initiative's CSS clean-up effort. There may be some useful patches there, but there may not be.
- #1969132: Clean up the CSS for Color module
- #1217002: Clean up the CSS for Forum module
- #1217004: Clean up the CSS for Help module
- #1217008: Clean up the CSS for Locale module
- #1217010: Clean up the CSS for Menu module
- #1217030: Clean up the CSS for Overlay module
- #1217040: Clean up the CSS for Simpletest module
- #1217046: Clean up the CSS for Taxonomy module
- #1217052: Clean up the CSS for Update module
- #1217054: Clean up the CSS for User module
- #1969124: Clean up the CSS for System module
- #1995272: [Meta] Refactor module CSS files inline with our CSS standards ← Current area of focus
- #1924522: Remove separate CSS_AGGREGATE_THEME aggregate file
We should also:
- Issue #: Remove system.admin.css from maintenance_page
- #1924528: Remove aggregator.theme.css deprecated by entity conversion #293318
- #352951: Make JS & CSS Preprocessing Pluggable
API changes
- The 3 CSS constants for the CSS "group" (CSS_SYSTEM, CSS_DEFAULT, CSS_THEME) will be simplified to just a single group constant, CSS_AGGREGATE_DEFAULT. This will reduce our aggregated CSS files from 4 files to just 2.
- drupal_add_css() will use CSS_COMPONENT as the default 'weight' and CSS_AGGREGATE_DEFAULT as the default 'group'.
- We'll add a drupal.base.css library to contain "base" HTML element styling for core which will be loaded using a weight of CSS_BASE. (Those rules that aren't already part of Normalize.css.)
- We'll load the Normalize.css library by default.
- The filenames for modules' CSS will match the pattern: module_name.module.css, module_name.theme.css, module_name.admin.css, module_name.admin.theme.css
- All core CSS will follow the CSS formatting standards.
- All core CSS will follow the CSS architecture standards.
| Comment | File | Size | Author |
|---|
Comments
Comment #1
chrisjlee commentedDraft Proposal here: http://drupal.org/node/1887918
Grouping CSS rulesets: http://drupal.org/node/1887922
Comment #1.0
johnalbinAdd link to 1924368
Comment #1.1
johnalbinAdd proper issue summary.
Comment #1.2
johnalbinAdd link to new issue
Comment #1.3
johnalbinAdd new issue link
Comment #2
johnalbinThe rough outline has x's in front of work I've already done in my sandbox: http://drupalcode.org/sandbox/johnalbin/1488942.git/shortlog/refs/heads/...
Comment #3
sunI don't get this name change. Where was this discussed?
Comment #3.0
sunAdd new issue link
Comment #3.1
johnalbinShow dependencies in remaining tasks.
Comment #3.2
johnalbinRearrange dependency list.
Comment #3.3
johnalbinAdd new issue link
Comment #4
johnalbinDrupalcon Sydney, the Mobile Initiative meetings this week and on http://drupal.org/node/1887922
The BAT (base-admin-theme) was a fantastic idea. It works really well, but its names conflict with the SMACSS categorization we're using in Drupal 8. So we just need to rename them.
MODULE.base.css becomes MODULE.module.css.
MODULE.admin.css stays the same (but requires adding a MODULE.admin.skin.css so admin themes can override the default skin).
And MODULE.theme.css becomes MODULE.skin.css.
Comment #5
sunWhy the rename from .theme to .skin?
.theme seems to be perfectly in line with http://smacss.com/book/type-theme
It's even more clear in Drupal, because we have the "theme" terminology already.
Comment #6
mbrett5062 commented+1 for keeping .theme for the reason @sun put forward, it makes more sense to keep the consistency.
Comment #7
lewisnyman+1 to using .skin because the Drupal definition of theme is not the same as the SMACSS definition. The are completely inconsistent.
In Drupal, a theme can cover:
The mark up output.
CSS for the entire layout and structure of a site, which could include multiple variants of a 'theme' from the SMACSS definition.
Javascript that affects the functionality of the site.
I don't think I've ever seen a Drupal theme that covers only colours and type. A good example of the SMACSS definition of theme would be the theme options for jQuery UI or jQuery Mobile.
Comment #7.0
lewisnymanAdd new issue link
Comment #8
johnalbinAs Lewis said, SMACSS's definition of module and theme is completely different than Drupal's definition of module and theme. It's like Jonathan Snook thought to himself “How can I make this system the most confusing to Drupal people.” ;-)
Our CSS architecture page ( http://drupal.org/node/1887918#separate-concerns ) already notes that we have used alternatives to some of the SMACSS terminology. It's unfortunate; I struggled with this problem for about 6 months and I believe the solution the community reached is the best we can achieve. Fortunately, the alternatives we used (component and skin) are widely used in the larger front-end community and are synonyms for the SMACSS terminology.
Comment #8.0
johnalbinAdd new issue link
Comment #9
shyamala commentedAdding tags
Comment #10
shyamala commentedAdding tags again...
Comment #10.0
shyamala commentedAdd new issue link
Comment #10.1
shyamala commentedAdded issue #1941118: Allow underscores in class names by John Ferris
Comment #10.2
johnalbinAdd link to #1109854
Comment #10.3
johnalbinAdd links to HTML5 initiative CSS clean-up issues.
Comment #10.4
johnalbinAdd link to http://drupal.org/node/1969132
Comment #10.5
rteijeiro commentedAdded the #1969124 issue
Comment #10.6
johnalbinAdd new sub-tasks.
Comment #10.7
johnalbinAdd new issues
Comment #10.8
echoz commentedremove dead issue link
Comment #10.9
johnalbinAdd new issues.
Comment #10.10
johnalbinAdd new issue
Comment #10.11
johnalbinAdd new issue
Comment #11
tim.plunkettWhere does SMACSS specify "skin" over "theme"?
That rename seems absurd.
Also, the first three patches I looked at aren't rolled correctly.
Please read http://drupal.org/documentation/git/configure and use renames = copies
Comment #12
ry5n commented@tim.plunkett SMACSS uses the term 'theme' to refer to non-structural, non-layout styles (the surface colors, borders, padding, backgrounds, etc.). Since the existing Drupal term 'theme' often refers to a much broader set of things, we wanted to avoid confusion. Are you saying that’s not necessary?
Comment #13
tim.plunkettI'm saying that I agree with #5, and I think the name change is a distraction and is even more foreign to Drupal.
I do think the .base.css to .module.css switch makes sense, but let's not blindly switch 100% to a naming convention just because we like 80% of it.
EDIT:
By my grep, the word "skin" appears zero times in core. In fact, "skin" appears zero times on http://smacss.com/book/categorizing too.
We have modules, we have themes, let's call it according to what we have.
Comment #14
tim.plunkettIn the SMACSS book, the word "skin" appears in two places:
The entire section on "Theme Rules" makes me think that .theme.css is EXACTLY what we want to be calling this.
Thanks to @dead_arm for sharing her copy of the SMACSS book with me.
Comment #15
ry5n commentedI want us to use the SMACSS concepts; the labels we use are less important, as long as folks understand them. The BAT convention already uses “theme” in a way that’s more in line with SMACSS that the normal Drupal meaning, so I guess there’s precedent. I’m fine either way.
Comment #16
lewisnymanWhat I think we should avoid is the same kind of confusion we had with tpls and template.php. Two completely different things with the same name.
Comment #17
tim.plunkettThe template.php issue was because there were named exactly the same across themes.
If you can't tell the difference between bartik.theme, bartik.theme.css, garland.theme, and garland.theme.css, that's your problem.
All of the currently RTBC issues need to be knocked to NW.
Comment #18
webchickHm. I don't know that I see enough compelling arguments here to introduce Yet Another Weird Term Into Drupal's Vernacular, personally. #14 is a pretty compelling argument against it, in fact.
Additionally, in a quick search at GitHub, I can't find any other smacss code out there that's using "skin" but several that are using "theme." So it seems like we'd be inventing a Drupalism here, in addition to introducing another term?
I think that Lewis's concerns in #7 and #16 are valid, but only for people with a deep understanding of Drupal's nuances. For most normal people, "theme" == "how it looks," which is probably why SMACSS chose that term.
Comment #19
rteijeiro commentedAs I understand, we refer to "theme" as the whole bunch of files to style our site. But inside our modules we want to have some files as:
- foo.module.css: the minimun styles our module should have to work.
- foo.skin.css: other styles (color, fonts...) that can be overrided by other themes.
The same for admin pages:
- foo.admin.css: base styles (layout, state, component) for the administative pages of our module.
- foor.admin.skin.css: other styles that can be overrided by other themes.
In my opinion, keeping the names foo.theme.css and foo.admin.theme.css will cause confusion with the "theme" term. In other hand, now I am writing this, it seems that the css file names are related to the "theme" term, giving us a the impression that they are part of the theme files.
Late night deliriums...
Comment #20
tim.plunkettI don't think anyone would think that
/modules/pathauto/css/pathauto.admin.theme.csswould be part of a theme, or if they did, that/modules/pathauto/css/pathauto.admin.skin.csswould be an improvement.Comment #21
webchickRight. Or if it were that confusing to lots of people, we should have heard about it by now; D7 shipped with at least system.theme.css for a very similar purpose.
Comment #22
ry5n commentedWell, I guess I’m off the fence. I’m no longer afraid the term 'theme' used this way is really going to cause confusion, and that was really the only reason to introduce it. I’d like to hear from @JohnAlbin though.
Comment #23
echoz commented"skin" on the chopping block again, eh?
I would be happy to not use "skin" as I've voiced before. @tim.plunkett you bring up a fresh perspective in #20.
Unlike "theme", using modular "components" because we have another thing called drupal "modules", makes sense since these can be referred to as nouns, so an imagined mixup in conversation is obvious.
Comment #24
webchickI think we need to do these renames as a single patch, not in separate sub-issues. Because:
#1: It's clobbering up the RTBC queue with individual issues (each carrying their own roll/review/re-roll/re-review/rtbc/re-re-re-review/needs work/commit/etc. overhead), with patches that could easily be scripted and reviewed as a whole.
#2: If they're not all done at once, we introduce inconsistencies in how files are named, which will be confusing to themers. We can't introduce more stuff to "clean up later" at this point in the release cycle. :\
#3: I still am not clear on whether or not this naming convention actually has community buy-in around it, and one place to discuss it would be much easier to determine this than several.
Can we please close these sub-issues as dupes and work at either #1921610: [Meta] Architect our CSS or some other "all in one rename" issue?
Comment #25
webchickAnd just to be clear, I meant this only for renames which are more or less "the exact same changes made for 30K files." I think the CSS clean-up patches make total sense split into their own issues, because they probably do warrant discussing/reviewing independently, and we don't leave D8 in a "half-baked" state if we only manage to clean up half the CSS we meant to. But this is not true of file renames.
Comment #26
akmalfikri commentedIt was separated because we did those issues during a sprint at DrupalCamp SG, just to be clear. Yeah I totally agree with you.
Comment #27
ry5n commentedI’m still worrying about this terminology, although I haven’t changed my mind from #22. The following is just something to keep in mind.
SMACSS theme styles within themes, not modules, is the most likely cause of confusion here (“I heard you like themes in your theme…”). Real use case: dark and light colour scheme (user-switchable via js): now you have
…themename/stylesheets/theme/dark.cssand…themename/stylesheets/theme/light.css. I still think that’s probably OK, because most themes won’t need it. But it is more than a little odd.Comment #28
ry5n commentedAnother likely occurrence of separate theme styles within themes in starter/base themes. That might be the most common case in the wild; in fact, I would recommend all base themes carefully separate their base and structural styles the same way modules do, which means you will have theme.css within themes be quite common.
Comment #29
shyamala commentedCreated a single issue to rename all css files at: #1987066: Rename files to match CSS file naming convention based on request by webchick to make review easier. Refer: http://drupal.org/node/1921610#comment-7375894
Need to clarify naming convention, refer tim.plunkett query at http://drupal.org/node/1921610#comment-7362724
Comment #29.0
shyamala commentedUpdated issue summary.
Comment #30
shyamala commented@johnalbin Comment #20 needs your eyes to resolve the theme vs skin debate :)
Comment #31
jwilson3Cross-post from comment #15on #1987066-15: Rename files to match CSS file naming convention.
With the skin/theme and now module dilema, its clear there is lots of overlap between SMACSS terminology and pre-existing Drupal nomenclature. Thinking outside the box, is there some way to implement and make use of SMACSS layering *concepts* without tying our file names to their naming scheme?
Comment #32
johnalbinWe just discussed this in the latest Mobile Initiative meeting and we are all fine with leaving *.theme.css as is. I am pretty adamant about changing *.base.css to *.module.css, so I'm glad other people are fine with that renaming.
Comment #33
hass commentedI would like to please you guys also to write comments into the CSS files. Today it's impossible to guess how class names are used and for what.
Comment #33.0
hass commentedupdated new issue id at #1987066: Rename files to match CSS file naming convention
Comment #33.1
johnalbinMove issues to sandbox.
Comment #33.2
johnalbinUpdated issue summary.
Comment #33.3
johnalbinAdd #1925320 back to the list
Comment #34
kevin morse commentedPlease see http://drupal.org/node/1987066#comment-7418144... Is there any point in me re-rolling this patch at the moment?
This seems to be an important task remaining but progress seems to be stalled. I am willing to do the work to get it working again if it will be committed before it breaks again.
Comment #35
ry5n commented@Kevin thanks. I assume you mean #1987066. I think a reroll is appropriate, with 'theme' instead of 'skin'. AFAIK we have consensus again on naming, e.g. system.module.css, system.theme.css.
Comment #36
echoz commented@Kevin Morse, all renaming issues are moved to a sandbox, and what I understand from 5 in the issue summary above, that issue will be used to combine them in a larger chunk. Each of those issues in the list under "Mobile Initiative sandbox:" actually link to them where they now are located in the sandbox. So it seems the available renaming issues are in the sandbox, and you're welcome to help over there!
Comment #37
dasjofollowing up on the "skin" vs "theme" discussion, my understanding is that using .theme.css has been agreed upon.
if that's correct, some issues would need updating to match the convention, especially
- the summary of #1217054: Clean up the CSS for User module
- CSS architecture (for Drupal 8) currently uses skin instead of theme
- CSS file organization (for Drupal 8) currently uses skin instead of theme
Comment #37.0
dasjoAdd link to 1995272
Comment #37.1
lewisnymanAdded a link to the ne style guide prototype
Comment #37.2
mtiftUpdated issue summary.
Comment #37.3
mtiftUpdated issue summary.
Comment #37.4
tclerico commentedAdded "@" to add assignation labels for delegation purposes.
Comment #38
dead_armUpdated the related issues by switching "skin" to "theme".
Comment #39
echoz commentedMoved #1995272: [Meta] Refactor module CSS files inline with our CSS standards to the Drupal 8 Mobile Initiative sandbox, made it a meta and changed status to active.
Comment #40
ry5n commented@dead_arm, @echoz: thanks; you rock :)
Comment #41
johnalbinAgreed! Thanks for the help updating the issues. The sub-issues for the file renaming have all been "fixed" in the sandbox and a large combo patch is now sitting on #1987066: Rename files to match CSS file naming convention that needs review. Review please! :-)
+1 billion
Also, it is now part of Drupal's official CSS formatting standards to describe rulesets, so CSS refactoring patches that don't have comments should be knocked down to Needs Work.
Comment #41.0
johnalbinConsensus was reached in both http://drupal.org/node/1921610 and at DrupalconPDX discussions that using "theme" over "skin" in the CSS class renaming effort is more straight-forward.
Comment #41.1
ry5n commentedAdded spin-off (smaller-scope) alternative issue for allowing '__' in classes
Comment #41.2
ry5n commentedWrong issue number
Comment #41.3
johnalbinAdd 2015789 to list
Comment #41.4
johnalbinAdd 1473066 to list.
Comment #41.5
johnalbinAdd 352951 to also haves.
Comment #41.6
johnalbinRemove openID module issue #1217016
Comment #42
hass commented#2029187: [meta] Make sure CSS classes are prefixed properly
Comment #42.0
johnalbinMove HTML5 issues out of component task.
Comment #43
hass commentedWhy not only one?
Comment #44
xjmIn the context of this issue, could we get some feedback on #1363112: Simplify names of "element-x" helper classes? The patch was committed, but a rollback has been requested under the premise that those classes are now unprefixed.
Comment #44.0
xjmAdded #2012020
Comment #45
lewisnymanComment #46
mgiffordComment #49
andeersg commentedI apologise if I'm late to the party. But I'm wondering on something related to the CSS standard in Drupal 8.
I see that Drupal 8 has a BEM-like approach with modifier classes and less nesting.
But in this issue: https://www.drupal.org/node/1968360 the region context for blocks was removed, with the reasons like:
and
Extend can complicate the css: http://csswizardry.com/2014/11/when-to-use-extend-when-to-use-a-mixin/ and make it less maintainable.
To have region available in preprocess_block means that it's easy to for example add a
--smallmodifier to blocks in footer or sidebar. And this keep the CSS DRY, since the modifier is not tied to a region. Doing.region__footer .blockto alter some styles for a block will create much more CSS than being easily able to add modifier classes. The mentioned issue seems counter productive to the current coding standards.Comment #52
joelpittetComment #57
steinmb commentedLooking through this plan, to me it seems mostly done? Issue summary contains these two issue that still are open but they seems a little out of date and not active:
Perhaps it should be closed?
Comment #63
catchThis is mostly done and I'm not sure the meta helps any more, however there are still multiple inconsistent asset libraries in core.
More recent issues:
#2880237: [meta] Refactor system/base library
#3565297: Move 'grid' and 'display link' CSS to their own views libraries
#1924522: Remove separate CSS_AGGREGATE_THEME aggregate file
Also found a couple of extra problems in #3565258: Support library-specific aggregates where the SMACSS categories appear to be wrong for a handful of libraries.
Comment #65
smustgrave commentedJust closed #3034767: Allow custom aggregation groups as it was clear that it was by design, not sure where that documentation should live though.