Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Add option to 'remove class cruft' #20

Open
wants to merge 1 commit into
base: 7.x-1.x
Choose a base branch
from

Conversation

stevetweeddale
Copy link
Contributor

Generally, the nicer the CSS, the less 'standard' css classes we'll use. So ideally we'll like to be able to remove all those default classes from things. D8 goes a long way toward this (choose the classy base theme if you want the classes) but in D7 we're kind of on our own.

So we normally would remove them in a preprocess. Oftentimes that means we end up with something like this:

$variables['classes_array'] = array();

… before then adding just the nice custom classes we want. Whilst this is tempting because it's quick and easy to get a 'clean slate', it's a pretty nuclear solution, and totally breaks certain things (such as contextual links regions).

A nicer way would be to methodically remove all the uber-generic crufty classes we don't want eg. for paragraphs:

  cm_tools_array_remove_values($variables['classes_array'], array(
    'entity',
    'entity-paragraphs-item',
    'paragraphs-item-' . drupal_clean_css_identifier($variables['elements']['#entity']->bundle),
    'paragraphs-item-' . $variables['view_mode'],
    'paragraphs-item-' . drupal_clean_css_identifier($variables['elements']['#entity']->bundle) . '-' . $variables['view_mode'],
  ));

… but as you can see that's a long way from quick and easy.

So, the suggestion is we have a global opt-in setting for cm_tools that just does this for common theme hooks (preprocesses away the stock classes). We'll need to module_implements_alter each of our preprocess functions to be late (specifically, later than whatever module defines the hook).

@darthsteven
Copy link
Member

Looks good to me! Resolve the conflict, and we're good to merge!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants