From b506991955ea4022f13af784c1533a397cd9324a Mon Sep 17 00:00:00 2001
From: Andrii Momotov <62144-Sydneydev@users.noreply.drupalcode.org>
Date: Sat, 28 Jan 2023 15:52:22 +0000
Subject: [PATCH] Issue #3337099 by Andrii Momotov, Panchuk, boddy: Need to
 implement storage for the styles

---
 .../paragraphs_gridstack.optionset.default.yml       |  1 +
 config/schema/paragraphs_gridstack.schema.yml        |  3 +++
 .../install/paragraphs_gridstack.optionset.demo.yml  |  1 +
 src/Entity/ParagraphsGridstack.php                   |  8 ++++++++
 src/Form/ParagraphsGridstackFormBase.php             | 12 ++++++++++++
 5 files changed, 25 insertions(+)

diff --git a/config/install/paragraphs_gridstack.optionset.default.yml b/config/install/paragraphs_gridstack.optionset.default.yml
index b4531ab..9aabe6a 100644
--- a/config/install/paragraphs_gridstack.optionset.default.yml
+++ b/config/install/paragraphs_gridstack.optionset.default.yml
@@ -6,3 +6,4 @@ label: Default
 float: true
 allow_custom_class: false
 breakpoints_provider: 'paragraphs_gridstack'
+styles_list: { }
diff --git a/config/schema/paragraphs_gridstack.schema.yml b/config/schema/paragraphs_gridstack.schema.yml
index 4f38ef5..c93d7ee 100644
--- a/config/schema/paragraphs_gridstack.schema.yml
+++ b/config/schema/paragraphs_gridstack.schema.yml
@@ -27,3 +27,6 @@ paragraphs_gridstack.optionset.*:
     breakpoints_provider:
       type: string
       label: "Breakpoints provider"
+    styles_list:
+      type: string
+      label: "Styles list"
diff --git a/modules/paragraphs_gridstack_demo/config/install/paragraphs_gridstack.optionset.demo.yml b/modules/paragraphs_gridstack_demo/config/install/paragraphs_gridstack.optionset.demo.yml
index f9f9167..f694a95 100644
--- a/modules/paragraphs_gridstack_demo/config/install/paragraphs_gridstack.optionset.demo.yml
+++ b/modules/paragraphs_gridstack_demo/config/install/paragraphs_gridstack.optionset.demo.yml
@@ -6,3 +6,4 @@ label: Demo
 float: true
 allow_custom_class: true
 breakpoints_provider: paragraphs_gridstack
+styles_list: { }
diff --git a/src/Entity/ParagraphsGridstack.php b/src/Entity/ParagraphsGridstack.php
index 0b786df..066ba23 100644
--- a/src/Entity/ParagraphsGridstack.php
+++ b/src/Entity/ParagraphsGridstack.php
@@ -63,6 +63,7 @@ use Drupal\Core\Entity\Annotation\ConfigEntityType;
  *     "allow_custom_class",
  *     "breakpoints_provider",
  *     "template",
+ *     "styles_list",
  *   }
  * )
  */
@@ -117,4 +118,11 @@ class ParagraphsGridstack extends ConfigEntityBase {
    */
   public $template;
 
+  /**
+   * Allows you to select a css class for an element.
+   *
+   * @var string
+   */
+  public $styles_list;
+
 }
diff --git a/src/Form/ParagraphsGridstackFormBase.php b/src/Form/ParagraphsGridstackFormBase.php
index 14e4114..ea1caff 100644
--- a/src/Form/ParagraphsGridstackFormBase.php
+++ b/src/Form/ParagraphsGridstackFormBase.php
@@ -127,6 +127,18 @@ class ParagraphsGridstackFormBase extends EntityForm {
       '#default_value' => $paragraphsGridstack->allow_custom_class ?? FALSE,
     ];
 
+    $form['styles_list'] = [
+      '#type' => 'textarea',
+      '#title' => $this->t('Styles list'),
+      '#default_value' => $paragraphsGridstack->styles_list ?? FALSE,
+      '#description' => $this->t('Enter one or more classes on each line in the format: element.classA.classB|Label.'),
+      '#states' => [
+        'visible' => [
+          ':input[name="allow_custom_class"]' => ['checked' => TRUE],
+        ],
+      ],
+    ];
+
     // Load the list of the breakpoints providers.
     // Get the default provider and validate available provider.
     $options = $this->gridstackBreakpointsManager->getBreakpointsProvidersList();
-- 
GitLab