Currently the module implements a select list which only allows you to select a single class. We should allow users to select multiple classes via a checkbox list or multi select list.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dabbor’s picture

Attaching patch that allowes multiple CSS classes to be applied entities by modified the logic to add all classes to the paragraph item.

The field cardinality must be set unlimited in order to make the multiple classes to work (to get multi select list widget).

dabbor’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: classy_paragraphs-select_multiple_classes-2424795-1.patch, failed testing.

dabbor’s picture

Status: Needs work » Needs review
FileSize
1.81 KB

Fixed patch to have relative diff paths.

dabbor’s picture

Fixed patch comment number :D

Ivan Zugec’s picture

Status: Needs review » Needs work
  1. +++ b/classy_paragraphs.module
    @@ -4,7 +4,6 @@
    -
    

    Leave this return in.

  2. +++ b/classy_paragraphs.module
    @@ -35,21 +34,21 @@ function classy_paragraphs_get_options($field, $instance) {
    + * Get classes names from paragraph item.
    

    Change to "Get class names from paragraph item."

- Currently the only widget available on the CP field is "Select list", we should also allow the checklist widget.
- It'll be good to write a test for the multi classes.

dabbor’s picture

Attaching modified patch.

Changes:

  • Changed "Get classes names from paragraph item" to "Get class names from paragraph item."
  • Added possibility of "Check boxes/radio buttons" (machine name: options_buttons) widget for the CP field.
  • Wrote a test for the multi classes (modified classy_paragraphs_test feature too) + refactored classy_paragraphs.test a little bit.

dabbor’s picture

Status: Needs work » Needs review
Ivan Zugec’s picture

Status: Needs review » Reviewed & tested by the community

Good work.

Ivan Zugec’s picture

Assigned: Unassigned » Ivan Zugec

Ivan Zugec’s picture

Status: Reviewed & tested by the community » Fixed

Code committed.

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

groovedork’s picture

I haven't played with this hands-on yet, so take this with a lot fo salt, but I am wondering: is heaping classes on top of each other a good idea from a usability standpoint? Front-end developers understand how different CSS stylings can work together, but a layman probably doesn't. Adding just a single 'visual accent' to a paragraph might be easier to conceptualize.