Update CSS coding standards to include PostCSS and Drupal 10

Created on 29 November 2022, almost 2 years ago
Updated 23 July 2024, 4 months ago

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 ๐ŸŒฑ [PLAN] Drupal CSS Modernization Initiative Active 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

  1. https://www.drupal.org/u/lauriii โ†’
  2. https://www.drupal.org/u/ckrina โ†’
  3. https://www.drupal.org/u/andy-blum โ†’

Proposed changes

The current documentation structure โ†’ has the following pages:

  1. CSS โ†’
  2. CSS coding standards โ†’
  3. CSS formatting guidelines โ†’
  4. CSScomb settings for Drupal (CSS formatting and sort tool)
  5. CSS architecture (for Drupal 9) โ†’
  6. CSS file organization (for Drupal 9)
  7. 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

This postponed because we need someone familiar with the CCS changes to make the documentation updates. Ping in #coding-standards for your questions.

  1. https://www.drupal.org/node/3406417 โ†’
  2. (not applicable)
  3. Documentation updates
    1. Edit all pages
    2. Publish change record
    3. Remove 'Needs documentation edits' tag
  4. If applicable, create follow-up issues for PHPCS rules/sniffs changes

For a full explanation of these steps see the Coding Standards project page โ†’

๐Ÿ“Œ Task
Status

Postponed

Component

Coding Standards

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US

Live updates comments and jobs are added and updated live.
  • CSS

    It involves the content or handling of Cascading Style Sheets.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    Update 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?

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone
  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan tyler36 Osaka

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

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US

    It may be helpful to state what is to happen to those pages.

    From my point of view, they should be replaced.

    Is the format of https://docs.google.com/document/d/1rihTDDGy9-m0TGIadgz16TQ1aONc0OC3u2Tk... related to the pages that will be created/edited? As in, would a 'Heading 2' correspond to a Drupal wiki page?

    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.

    Not sure if it's in the scope, but can the standard also include a commitment to review every X years?

    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.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

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

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    I would suggest every 4 years, perhaps aligned with every even (or odd) major Drupal release.

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

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US

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

    The issue should have a change record.

    It looks like we need a change record. Should that be on this project, or Drupal core?

    If the committee agrees to the change the issue is tagged โ€œNeeds documentation updatesโ€ and is announced on https://www.drupal.org/about/core โ†’ with a consideration period of 14 days. If there are concerns or conversation is ongoing, the issue consultation time may be extended. If the committee does not agree to the change the status may be set to "Won't fix" or to "Needs work" with an explanatory comment.

    I think this already happened. It was announced at https://www.drupal.org/about/core/blog/coding-standards-proposals-for-fi... โ†’

    If the issue affects core it is discussed at the next core committer meeting.

    Has this happened yet? Is it on the agenda for the next core committer meeting?

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

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

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

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

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US

    Did 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?

  • Status changed to Needs review 12 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    There are open threads in the Google doc

    It would be good to resolve them

    For the record I'm in support of the changes

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US

    @larowlan

    Just resolved all the threads. Thanks for your feedback in there. Let me know what's next.

  • Status changed to RTBC 12 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    Gonna 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

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    Change record can be found here: [#3406417].

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

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

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US

    done! 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.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

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

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jonathan1055

    Updated the IS for the full new process, so that we can see all steps 1-9.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jonathan1055

    Discussion post is published 11 Dec so removing the 'Needs announcement for final discussion' tag
    https://www.drupal.org/about/core/blog/coding-standards-proposals-for-fi... โ†’

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    This has been ready to go for a while - can someone do the honours of the actual documentation update so we can mark this fixed?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US

    yeah, this is on me (sorry!). I've been a bit snowed under with both work and personal stuff.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

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

  • ๐Ÿ‡ท๐Ÿ‡ธSerbia finnsky
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    This still needs documentation updates.

  • Status changed to Postponed 4 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone
Production build 0.71.5 2024