This is the first patch in a series to obliterate drupal.css :-)
This patch splits up drupal.css into per module CSS files. It does not change any of the CSS, it's merely an organizational patch.
One issue to debate:
What to do with the remaining drupal.css classes? Should we have an admin.css, forms.css, etc..? Or just one file? In a forthcoming patch I plan to rename this to default.css and put in some sensible CSS defaults (like proper clearing, margins, etc...)
On the horizon, when Moshe's hook_signals() patch lands we'll move the drupal_add_css() calls to a proper location. For now, they make the most sense in hook_menu().
Comments
Comment #1
Crell commentedI'd say classes that are "just needed" and don't go to a specific module should get adopted by system.module. It's the closest to core of all the modules, and by nature is always included. I'd just put them all in a single system.css file.
There should be no css files that are not part of some module or another.
Comment #2
Stefan Nagtegaal commentedNice patch, applies cleanly to HEAD..
I'm tempted to set this RTBC, but lets wait untill someone else reviews this..
Steef
Comment #3
webchickI actually disagree with Crell... to maintain consistency, all rules in module CSS files should be specific to those modules. Stuff like "img" and "table" extend far beyond the system module itself, and thus they should be in the more "global" drupal.css file.
The one thing that still sort of feels "wrong" is having things like #block and #taxonomy in drupal.css. There are also items in drupal.css currently which seem to belong to user and system. I would make the following changes (I tried to do this myself, but have no idea how to roll a patch which requires adding files, so I'll just put this for you for when you get back :P):
Add to block.css:
Add to system.css:
Move into user.css:
There seems to be a fair amount of "dead" CSS that isn't called from anywhere in core (for example, .more-link), but I figure removing that will be a separate patch.
Comment #4
Crell commentedMy reasoning for saying that system.module should adopt non-module-specific classes is as follows:
1) Consistency. We now have a way for modules to add stylesheets and themes to remove them. Great. Let's not also have a non-module stylesheet to worry about. If themes need only worry about module-originating stylesheets, that makes the job easier for theme authors. It's one fewer variable to deal with.
2) I see system as "the core module". Things like img and table are part of the "core system", and therefore make logical sense with the "core system" module.
It wouldn't surprise me in the least if there's some dead cruft in drupal.css. Hopefully by splitting it up completely to the appropriate modules, we'll be able to divide and conquer and remove it. That will likely happen over the course of several patches.
Comment #5
m3avrck commentedAngie, great catches! I moved those CSS classes around and a few more myself.
Crell, in regards to system.css, I disagree--rather, I agree with Angie's comments.
Turning off CSS is *very* easy now in head with my last drupal_add_css() patch, have a read on how to turn off drupal.css.
What *should* live in drupal.css, if anything, is global CSS that applies to everything--like a proper clearing class (this will come in a patch after this one), sensible defaults for HTMl elements, and so forth.
Once this patch lands, I'll have another patch to start refactoring and further cleanup the CSS and remove some cruft and add in some new useful stuff. Till those refactoring patches, this patch is *soley* for re-organization of things.
I think we're pretty solid now in terms of that, I'd like to hear some more comments and see a commit soon ;-)
Comment #6
Frando commentedHmm,
currently all of the module's css files are added in the menu hook, so on every page request.
Wouldn't it be better if some of the files would only be included when they are actually needed?
For example, only including book.css when actuallly viewing a book node, or aggregator.css only on pages where it's needed and so on...
Comment #7
adrian commentedI think it'd be cool if we could manage to get rid of the misc/ directory entirely , actually.
I too see system.module as the core system. In the dependency work, EVERYTHING has a implicit requirement of system.module.
(it's also the module that has the drupal version, and the system.install file)
Comment #8
morbus iff* I agree: /misc should be removed entirely and we should strive for that.
* I agree: /system/system.css for non-specific stylesheet rules.
* Uber generic crap like "img" and "table" should really become theme-specific, I'd think.
Comment #9
morbus iff* I agree with Frando: we should only spit the CSS when the module actually uses it.
Comment #10
kkaefer commentedUpdated the patch and fixed the wrong usage of
drupal_add_css().Comment #11
rickvug commentedKudos for patches such as this! I've had a beef with drupal.css for a while now... here are some further points of contention:
- Too much is defined by the default CSS. While this does make things easier to theme, it also discourages theme creators to think outside of the box and define things for themselves. The system CSS should be kept to an absolute bare minimum to increase creativity and cut down on the time/bytes wasted in over-riding system values.
- The default html created in php template is class/id/div happy. I am all for hooks, but some things can be simplified by using better selectors. For example, .leaf is un-needed for generic menu list items and just creates clutter. A simpler way would be to get rid of all leaf classes and change the CSS selector to
ul.menu li(or something similar).Maybe this complaints go beyond the scope of this patch. Either way, system CSS will be much improved in this release.
Comment #12
m3avrck commentedOk guys, here's a new patch. A couple things...
First everyone can rejoice, drupal.css is *gone* ... bye bye! :-D
Next up, there are 2 core CSS files that live in system module now... system.css and defaults.css ... this doesn't introduce any new CSS, but rather further solidifies the reorganization of CSS.
In terms of organization, I hope we are good. Thanks to timcn for correcting my misuse, really tired when I rolled that patch :-)
After this goes in there will be subsequent patches. Moshe is working on a hook_signals() patch that we would use to control *when* CSS is added, for now we are using the menu structure till that patch is ready.
Second, will come a few refactoring CSS patches, starting with defaults.css. This file will soon hold *useful* CSS classes, like proper clearing. The reason for seperating that out from system.css is that well, I'm create very advanced themes (especially on the admin side) so often I would turn off all of system.css but I would keep defaults.css, since it would actually be useful (it will be, right now it isn't ;-)).
So *only* review this patch in terms of organization, we'll get to more functional and refactorizations in subsequent patches.
Comment #13
rkerr commentedExcellent work! This'll be so nice.
Comment #14
Anonymous (not verified) commentedawesome job ted. i give you soo much credit for taking the time to really organize that - not a fun job :P
Comment #15
rkerr commentedIf this happens, then we can start attacking the styles for the new admin page :)
Comment #16
webchickI kind of don't like losing the useful ability of drupal.css to easily identify a Drupal site, but I'm also not a themer so will defer to others on that.
Comment #17
morbus iffWebchick: Irrelevant, I'd say. There are many other signatures of a Drupal install, such as user/register.
Comment #18
Crell commentedPish. I can usually recognize a drupal site just by its functionality. I don't need drupal.css for that. :-)
That said, when I applied this patch drupal.css didn't disappear. There were also some offsets (big deal), but now that the archive module is gone this patch is out of date because it tries to add an archive.css file. Setting back to needs work for those reasons.
I also did a quick read-through of the post-patch CSS files. profile.css now includes this rule, which probably belongs in the poll module:
In system.css, there are two rules right next to each other:
Unless I'm going blind, there's no reason those shouldn't be a single rule. I know this isn't supposed to be a cleanup patch, but if we're moving them, that one seems just too trivial to not fix. Also, I'm not sure off hand if this rule should be part of the path module, as I'm not sure what it does. :-) Someone who knows check me on this:
I like the system.css / default.css split. Spiffy!
Other that, everything looks good. Fix these up soon, please! So many people have been waiting for the death of drupal.css. :-)
Comment #19
Stefan Nagtegaal commentedIf nobody does the pdate of the patch within the next 24 hours, I'll take a shot at this.
IMO this is a must-have in core..
BTW: Very nice patch m3avrck!
Comment #20
m3avrck commentedCrell, most excellent feedback!
Patch has been updated against HEAD, cleared out archive.css, along with fixing all of the offsets.
Fixed the profile/poll CSS, along with system CSS.
I also grepped all of core for a while and I could not find anywhere that .path class is used, I think it might be a left over from something (perhaps archive module?). I removed it, does not appear to be needed.
Hopefully the last reroll so we can get this in :-)
Comment #21
Crell commentedApplies perfectly against current HEAD, with one caveat. drupal.css itself is not actually removed. :-) Is that something only Dries/drumm/Steven can do?
Assuming yes, and dDS can take care of that part, I'll go on a limb and RTBC this. Yay!
Comment #22
m3avrck commentedYes, I can't create a patch that removes that file directly, Dries/Steven/Neil/Gerhard will have to take care of that one :-)
Comment #23
drummCommitted to HEAD with editing for adding a newline at the end of all the new CSS files and not letting system_menu() break Drupal. Thanks for (hopefully) not trying to sneak in wider changes (removing rules) with this patch.
Comment #24
drummSome image files need to be moved, such as the menu bullets. Please make a complete list and mark ready to commit.
Comment #25
Crell commentedI only found 3 references to images in the new CSS files, all 3 in menu module:
menu-expanded.png
menu-collapsed.png
menu-leaf.png
Which seemed off to me, so I went back and checked drupal.css, and discovered that, erm, a whole bunch of rules went missing. :-( Mostly they relate to JS functionality. They also reference a few other images:
throbber.gif
progress.gif
grippie.png
And also re-reference:
menu-expanded.png
menu-collapsed.png
I'm going to suggest those go to system module (including duplicates of the menu images), and system.css pick up the extra JS classes. I've attached a patch that adds them back in.
Sorry, Neil. We really screwed up on this one. :-(
(Although it does look like there's a bunch of graphics in misc that core doesn't actually use. If they're used by a core theme, they should get moved to the theme. Another time.)
Comment #26
asimmonds commentedI think the css rules for the welcome page and admin page are missing as well
Comment #27
m3avrck commentedNew patch in a few, some issues with paths in Crell's and looks like a few other rules missing.
Comment #28
m3avrck commentedYes Neil, I didn't try to sneak in or get rid of any rules with the patch :-)
However, looks like a few got left out, doh! Working with so many files and CSS classes, bound to happen.
Ok, here's a new patch which adds in the missing styles. Additionally, it adds in one more new file, the admin.css file... as per Earl's original idea, since this CSS is only needed when on /admin pages. I also put in the progress bar CSS into this file, since this CSS is only used when you're on update.php , where I've included this file as well.
Yes, there is still maintenance.css and print.css which need to be dealt with, but those are other patches. This attached patch completes this first cycle of cleanups--the reorganization :-)
Comment #29
m3avrck commentedOh, I didn't address the img issue.
Well yes, never thought about this one. Guess it makes sense for each module to have it's on img/ with images it uses as well? This would put 3 files into modules/menu/img:
menu-expanded.png
menu-collapsed.png
menu-leaf.png
And 3 files into modules/system/img:
throbber.gif
progress.gif
grippie.png
However, if we do that, we need to move these rules to menu.css:
Which begs the question, should modules now have their own img directories too? If that is the case, we can move those watchdog icons into watchdog module to further cleanup.
I think this makes the most sense, and perhaps we need another patch (and issue) address this reorganization or maybe the 4 core committers can just do this, since it's really mostly CVS commands.
Comment #30
morbus iffNot "img/", please. "img" is an abomination abbreviation in HTML. Let's not force it into the fs too. images/ please.
Comment #31
m3avrck commentedIf images are not moved, then I'll update the *.css files so they reference ../../misc to load the image.
Comment #32
m3avrck commentedAgreed, 'images/' makes more sense, in a per module directory and also a global one for like drupal icons and what not.
Let's get the CSS fix in then we worry about where we place those images :-)
Comment #33
dwwsounds like you've already noticed and are working on the menu images problem. that saves me the trouble of one of the screenshots i was going to post. ;) the other i noticed is the login block is no longer centered. see attached .png
also, m3avrck said in #28 "here's a new patch", but he never attached it. ;) so, i'm setting this back to "needs work", since there's definitely nothing in here that's RTBC at the moment.
Comment #34
m3avrck commentedThanks dww, here's the patch, doh!
Comment #35
dwwfresh, clear core test site, applied patch from #34, cleared browser cache, drupal cache, and reset drupal menus. menu icons are still busted (though admin page css is working again). see attached.
Comment #36
m3avrck commentedRight I said above that icons won't work. They either need to be moved into the same module directory, or into an images/ inside each module.
That shouldn't hold up this patch. The images/ and so forth is another issue. This patch is meant to fill in all of the CSS that was lost, the images is another issue, one that can't be directly addressed with a patch until files are moved around on the server.
Comment #37
m3avrck commentedOk here's an updated patch.
Includes all of the missing CSS, along with a new admin.css (since it's only needed on /admin pages).
Also includes a fix for user.css (wasn't being loaded at all), along with a fix for relative paths to the ../../misc for images.
I think this one completes this patch :-)
Next up to debate: should we move images out of misc/ into module specific directories or have an images/? And what about maintenance and print CSS files? ... these are questions for other issues/patches!
Comment #38
dwwyup, patch #37 fixes all the problems i was seeing. login block is right, menu icons are working, and admin pages look reasonable. RTBC, indeed. thanks, m3avrck!
Comment #39
dries commentedCommitted this to CVS HEAD to fix some of the breakage.
Comment #40
m3avrck commentedDries, did you mean to set this fixed?
The other issues I bring up are seperate issues, this was a reorganization issue, should this be marked fixed now?
Comment #41
m3avrck commentedGuess not, found some missing CSS on the install pages.
Comment #42
drummCommitted to HEAD.
Comment #43
(not verified) commented