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

Crell’s picture

I'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.

Stefan Nagtegaal’s picture

Nice patch, applies cleanly to HEAD..
I'm tempted to set this RTBC, but lets wait untill someone else reviews this..

Steef

webchick’s picture

I 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:

#blocks td.region {
  font-weight: bold;
}
#blocks td.block {
  padding-left: 1.5em;
}

Add to system.css:

img.screenshot {
  border: 1px solid #808080;
  display: block;
  margin: 2px;
}
.theme-settings-left {
  float: left;
  width: 49%;
}
.theme-settings-right {
  float: right;
  width: 49%;
}
.theme-settings-bottom {
  clear: both;
}

Move into user.css:

#permissions td.module {
  font-weight: bold;
}
#permissions td.permission {
  padding-left: 1.5em;
}
#access-rules .access-type, #access-rules .rule-type {
  margin-right: 1em;
  float: left;
}
#access-rules .access-type .form-item, #access-rules .rule-type .form-item {
  margin-top: 0;
}
#access-rules .mask {
  clear: both;
}
#user-login-form {
  text-align: center;
}

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.

Crell’s picture

My 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.

m3avrck’s picture

StatusFileSize
new34.79 KB

Angie, 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 ;-)

Frando’s picture

Hmm,
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...

adrian’s picture

I 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)

morbus iff’s picture

* 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.

morbus iff’s picture

* I agree with Frando: we should only spit the CSS when the module actually uses it.

kkaefer’s picture

StatusFileSize
new34.85 KB

Updated the patch and fixed the wrong usage of drupal_add_css().

rickvug’s picture

Kudos 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.

m3avrck’s picture

StatusFileSize
new27.28 KB

Ok 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.

rkerr’s picture

Excellent work! This'll be so nice.

Anonymous’s picture

awesome job ted. i give you soo much credit for taking the time to really organize that - not a fun job :P

rkerr’s picture

If this happens, then we can start attacking the styles for the new admin page :)

webchick’s picture

I 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.

morbus iff’s picture

Webchick: Irrelevant, I'd say. There are many other signatures of a Drupal install, such as user/register.

Crell’s picture

Status: Needs review » Needs work

Pish. 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:

.node-form .poll-form fieldset {
  display: block;
}

In system.css, there are two rules right next to each other:

tr.even, tr.odd {
  background-color: #eee;
  border-bottom: 1px solid #ccc;
}
tr.even, tr.odd {
  padding: 0.1em 0.6em;
}

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:

.path {
  padding-bottom: 0.7em;
  font-size: 1.1em;
}

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. :-)

Stefan Nagtegaal’s picture

If 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!

m3avrck’s picture

StatusFileSize
new25.67 KB

Crell, 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 :-)

Crell’s picture

Status: Needs work » Reviewed & tested by the community

Applies 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!

m3avrck’s picture

Yes, I can't create a patch that removes that file directly, Dries/Steven/Neil/Gerhard will have to take care of that one :-)

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed 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.

drumm’s picture

Priority: Normal » Critical
Status: Fixed » Needs work

Some image files need to be moved, such as the menu bullets. Please make a complete list and mark ready to commit.

Crell’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new2.28 KB

I 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.)

asimmonds’s picture

I think the css rules for the welcome page and admin page are missing as well

m3avrck’s picture

Status: Reviewed & tested by the community » Needs work

New patch in a few, some issues with paths in Crell's and looks like a few other rules missing.

m3avrck’s picture

Status: Needs work » Reviewed & tested by the community

Yes 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 :-)

m3avrck’s picture

Oh, 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:

html.js fieldset.collapsible legend a {
  padding-left: 15px;
  background: url(menu-expanded.png) 5px 50% no-repeat;
}
html.js fieldset.collapsed legend a {
  background-image: url(menu-collapsed.png);
}

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.

morbus iff’s picture

Not "img/", please. "img" is an abomination abbreviation in HTML. Let's not force it into the fs too. images/ please.

m3avrck’s picture

If images are not moved, then I'll update the *.css files so they reference ../../misc to load the image.

m3avrck’s picture

Agreed, '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 :-)

dww’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new43.8 KB

sounds 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.

m3avrck’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new4.9 KB

Thanks dww, here's the patch, doh!

dww’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new146.57 KB

fresh, 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.

m3avrck’s picture

Status: Needs work » Reviewed & tested by the community

Right 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.

m3avrck’s picture

StatusFileSize
new6.44 KB

Ok 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!

dww’s picture

yup, 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!

dries’s picture

Status: Reviewed & tested by the community » Needs work

Committed this to CVS HEAD to fix some of the breakage.

m3avrck’s picture

Dries, 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?

m3avrck’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new667 bytes

Guess not, found some missing CSS on the install pages.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)