Problem/Motivation
Drupal’s CSS coding standards are woefully outdated. They don’t take into account current practices in Drupal core, modern CSS features, and the use of PostCSS.
Several core developers have been working on updating these standards in #3254529: [PLAN] Drupal CSS Modernization Initiative and https://docs.google.com/document/d/1rihTDDGy9-m0TGIadgz16TQ1aONc0OC3u2TkJ8bNaxg/edit. The developers include @lauriii @ckrina @andy-blum and many others.
These standards are intended to completely replace the current CSS coding standards.
Unfortunately we haven’t been following the process laid out in https://www.drupal.org/project/coding_standards. We were made aware of this in #3257287: [Policy] Create CSS standards for core use of CSS custom properties (aka CSS Variables) by @quietone
This issue is intended to start the formal process 🙌
Benefits
If we adopted this change, the Drupal Project would benefit by ...
Three supporters required
Proposed changes
The current documentation structure has the following pages:
- CSS
- CSS coding standards
- CSS formatting guidelines
- CSScomb settings for Drupal (CSS formatting and sort tool)
- CSS architecture (for Drupal 9)
- CSS file organization (for Drupal 9)
- What to look for when reviewing CSS
The new standards are intended to completely replace the current CSS coding standards. The document is https://docs.google.com/document/d/1rihTDDGy9-m0TGIadgz16TQ1aONc0OC3u2Tk...
Remaining tasks
** Someone familiar with the new CSS changes to make, or assist with, the documentation updates. Ping in #coding-standards to help out.
Create this issue in the Coding Standards queue, using the defined templateAdd supportersCreate a Change Recordhttps://www.drupal.org/node/3406417Review by the Coding Standards CommitteeCoding Standards Committee takes action as requiredTagged with 'Needs documentation edits' if Core is not affected(not applicable)Discussed by the Core Committer Committee, if it impacts Drupal Core- Documentation updates
- Convert to md
- Check that gists were copied correctly and remove the link
- Review docs
- fix two spelling errors: componentized, stylelintrc<.li>
- Publish change record
- Remove 'Needs documentation edits' tag
- If applicable, create follow-up issues for PHPCS rules/sniffs changes
For a full explanation of these steps see the Coding Standards project page
Issue fork coding_standards-3324368
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ckrina+1 to this change! I think it's really needed so core can use modern CSS.
Comment #3
prashant varma commentedYeah , i also agree with @cKrina with you it's need more CSS
Comment #4
quietone commentedCan you outline how these changes related to the existing CSS standard pages on d.o? Are there changes in the doc a complete replacement or replacing sections or new additions?
Comment #5
andy-blum+1 on the need to update the standards. I think the doc was written as a full re-write of the standards, but I think there might be some things worth saving from the existing standards. For example, the "what to look for when reviewing CSS" is probably still worth keeping.
Comment #6
mherchelThis would be a complete replacement (updating IS)
Comment #7
mherchelComment #8
quietone commentedUpdate the Issue Summary to include links to the current pages.
It may be helpful to state what is to happen to those pages. Is the format of https://docs.google.com/document/d/1rihTDDGy9-m0TGIadgz16TQ1aONc0OC3u2TkJ8bNaxg/edit related to the pages that will be created/edited? As in, would a 'Heading 2' correspond to a Drupal wiki page?
Comment #9
quietone commentedComment #10
tyler36 commentedNot sure if it's in the scope, but can the standard also include a commitment to review every X years?
Drupal is a PHP framework and requires regular updates to PHP for security and stability.
CSS is constantly eveolving depending on current browser market and trends.
I think we to set a formal timeline for re-evaluating supported browsers, build processes and best practises to prevent CSS standards from becoming "woefully outdated" again.
I would suggest every 4 years, perhaps aligned with every even (or odd) major Drupal release.
Comment #11
mherchelFrom my point of view, they should be replaced.
I'm assuming so. I'm not 100% sure how we'll split the content across separate pages. Most of the work has been just updating and creating the content, as well as organizing it. I'm willing to work with the documentation team or whoever else as needed.
I'm not opposed to this, but not 100% certain its needed. CSS is changing very fast, but the standards don't dictate what rules we use, just how we format it. Additionally, PostCSS will automatically update compiled CSS as it's updated and our supported browsers change. At some point we'll need to discuss things like native CSS nesting (when we won't need PostCSS), when all our supported browsers support this... but that's probably 2-3 years off.
Comment #12
bbralaThis reads as a reasonable change for the css docs. Only one thing I kinda miss in "Format Class Names using BEM". Can we have a state for the button also so we also show a state class structure? I understand there is a paragraph under St that regarding js state changes but shouldn't state also be shown if we are showing the other bem structures?
Perhaps a --primary state or --disabled?
This could be a Followup though to change. It's pretty minor.
Comment #13
quietone commentedI do support regular review of any policy but it is not something built into the existing practices. For myself, it is a long term plan.
Comment #14
mherchelWhat's the next step in this process? From what I gather, the https://www.drupal.org/project/coding_standards process text has changed since the last time I looked at it, so we're in a weird place.
It looks like we need a change record. Should that be on this project, or Drupal core?
I think this already happened. It was announced at https://www.drupal.org/about/core/blog/coding-standards-proposals-for-fi...
Has this happened yet? Is it on the agenda for the next core committer meeting?
Comment #15
quietone commentedThis was discussed #3375432: Coding Standards Meeting 2023-08-15 and there was no objection to proceeding. So that step is done.
No, it hasn't been brought up at a core meeting. The next on is early next month. I have left a note in committer Slack for it to be added to the agenda.
Comment #16
quietone commentedI am updating this to the new process.
The first thing is to set this to RTBC and remove the 'final discussion tag'. This now puts us at Step 6. But since core is affected that moves to step 7, where this needs to go to a committer meeting. It was scheduled to be added to the latest core meeting but instead the issue for updating the process was discussed. I have now re-added that to the schedule.
As for the change record, that should be in this project. I am adding the tag for the change record.
Thanks for you patience!
Comment #17
quietone commentedComment #18
mherchelDid this make it to the core meeting yet? If so when is that scheduled?
Also, what information needs to go in the change record? I don't see any at https://www.drupal.org/list-changes/coding_standards Does the info need to be extensive, or does it just need to note that CSS coding standards have changed?
Comment #19
larowlanThere are open threads in the Google doc
It would be good to resolve them
For the record I'm in support of the changes
Comment #20
mherchel@larowlan
Just resolved all the threads. Thanks for your feedback in there. Let me know what's next.
Comment #21
bbralaGonna set rtbc, and suggest it will be added to core meeting.
We doel still need a change record it seems though. Quietone did point at the correct project in #16
Comment #22
bbralaChange record can be found here: #3406417: Major update to CSS coding standards to include PostCSS and Drupal 10.
Comment #23
bbrala@mherchel there seems to be one line not removed from the document yet, a placeholder for example code, which seems to have examples right above it? Quite minimal imo, so not gonna remove rtbc.
Comment #24
mhercheldone! The code sample was actually there. Just forgot to remove the placeholder!
Change record is at https://www.drupal.org/node/3406417, since the syntax above doesn't work with CR's, I guess.
Comment #25
larowlanThis was discussed at core committers meeting on Wed December 5th (UTC)
There were no objections
There was however a desire to split the tooling (e.g. stylelint) from the standard.
Can we review the document and remove any specific mentions of a particular tooling.
This will make it easier to change tooling without needing to change the standard.
I think is ready for a draft blog post now.
Comment #26
jonathan1055 commentedUpdated the IS for the full new process, so that we can see all steps 1-9.
Comment #27
jonathan1055 commentedDiscussion post is published 11 Dec
coding-standards-proposals-for-final-discussion-on-2-january-2024
Removing the 'Needs announcement for final discussion' tag
Comment #28
catchThis has been ready to go for a while - can someone do the honours of the actual documentation update so we can mark this fixed?
Comment #29
mherchelyeah, this is on me (sorry!). I've been a bit snowed under with both work and personal stuff.
Comment #30
quietone commentedI updated CSS formatting guidelines by replacing content with what is in the google doc. That is available for review. Also, the text is using 'whitespace' which is not in American English dictionaries. Should it be changed to 'white space'?
Comment #31
finnsky commentedhttps://github.com/prettier/stylelint-prettier
in core now. https://www.drupal.org/project/drupal/issues/3409048
Comment #32
bbralaThis still needs documentation updates.
Comment #33
quietone commentedComment #34
quietone commentedLet's try a change of status.
This does need work but we need support from someone familiar with the new CSS standards.
Comment #36
quietone commentedConverted the google doc to 4 pages in the CSS section and removed the existing pages.
To:
Copy the gists instead of linking to external sources.
Remove postCSS, as catch pointed in the doc, this is not a section that need CS Committee approval for changes.
Comment #37
quietone commentedComment #38
mherchelJust pushed some changes. This should be good to go!
Thank you for the heavy lifting on this @quietone!
Comment #39
quietone commented@mherchel, thank you.
Reviewing this again I found that the following needs to be done.
Where to move the PostCSS page? Maybe development tools?