Skip to content

Commit c4ed948

Browse files
committed
Merge branch 'release/1.7.1'
2 parents 6784176 + 6e1eb64 commit c4ed948

16 files changed

+138
-12
lines changed

tests/behat/features/paragraph.civictheme_promo.fields.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ Feature: Promo fields
2929
And should see an "[name='field_c_n_components[0][subform][field_c_p_vertical_spacing]']" element
3030
And should see an "[name='field_c_n_components[0][subform][field_c_p_vertical_spacing]'].required" element
3131
And should not see an "[name='field_c_n_components[0][subform][field_c_p_vertical_spacing]'][disabled]" element
32+
33+
And I should see an "[name='field_c_n_components[0][subform][field_c_p_background][value]']" element

tests/behat/features/paragraph.civictheme_promo.render.feature

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Feature: Promo render
88
| [TEST] Page Promo test 2 | 1 |
99

1010
@api
11-
Scenario: CivicTheme page content type page can be viewed by anonymous with Promo light with vertical spacing
11+
Scenario: CivicTheme page content type page can be viewed by anonymous with Promo light with vertical spacing without background
1212
Given I am an anonymous user
1313
And "field_c_n_components" in "civictheme_page" "node" with "title" of "[TEST] Page Promo test 1" has "civictheme_promo" paragraph:
1414
| field_c_p_title | [TEST] Promo title |
@@ -22,6 +22,7 @@ Feature: Promo render
2222
And I should see an ".ct-promo" element
2323
And I should see an ".ct-promo.ct-theme-light" element
2424
And I should see an ".ct-promo.ct-vertical-spacing--both" element
25+
And I should not see an ".ct-promo--with-background" element
2526
And I should see the text "[TEST] Promo title"
2627
And I should see the text "[TEST] Content text"
2728
And I should see an ".ct-promo__title" element
@@ -30,21 +31,23 @@ Feature: Promo render
3031
And the response should contain "https://example.com/link1"
3132

3233
@api
33-
Scenario: CivicTheme page content type page can be viewed by anonymous with promo dark without vertical space
34+
Scenario: CivicTheme page content type page can be viewed by anonymous with promo dark without vertical space with background
3435
Given I am an anonymous user
3536
And "field_c_n_components" in "civictheme_page" "node" with "title" of "[TEST] Page Promo test 2" has "civictheme_promo" paragraph:
3637
| field_c_p_title | [TEST] Promo title |
3738
| field_c_p_theme | dark |
3839
| field_c_p_content:value | [TEST] Content text |
3940
| field_c_p_content:format | civictheme_rich_text |
4041
| field_c_p_vertical_spacing | 0 |
42+
| field_c_p_background | 1 |
4143
| field_c_p_link | 0: [TEST] link 2 - 1: https://example.com/link2 |
4244

4345
When I visit "civictheme_page" "[TEST] Page Promo test 2"
4446
And I should see an ".ct-promo" element
4547
And I should not see an ".ct-promo.ct-theme-light" element
4648
And I should see an ".ct-promo.ct-theme-dark" element
4749
And I should not see an ".ct-promo.ct-vertical-spacing--both" element
50+
And I should see an ".ct-promo--with-background" element
4851
And I should see the text "[TEST] Promo title"
4952
And I should see the text "[TEST] Content text"
5053
And I should see an ".ct-promo__title" element

web/modules/custom/cs_generated_content/generated_content/node/civictheme_page_variations/component.promo.inc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ function _cs_generated_content_create_node_civictheme_page__variations__componen
3434
'theme' => $helper::civicthemeThemeDark(),
3535
],
3636

37+
[
38+
'type' => 'promo',
39+
'title' => 'Light, BG, ' . $helper::staticSentence(3),
40+
'link' => $helper::staticLinkFieldValue(),
41+
'theme' => $helper::civicthemeThemeLight(),
42+
'background' => TRUE,
43+
],
44+
[
45+
'type' => 'promo',
46+
'title' => 'Dark, BG, ' . $helper::staticSentence(3),
47+
'link' => $helper::staticLinkFieldValue(),
48+
'theme' => $helper::civicthemeThemeDark(),
49+
'background' => TRUE,
50+
],
51+
3752
[
3853
'type' => 'promo',
3954
'title' => 'Light, Content, Vertical spacing, ' . $helper::staticSentence(3),

web/themes/contrib/civictheme/civictheme.info.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ config_devel:
401401
- field.field.paragraph.civictheme_next_step.field_c_p_theme
402402
- field.field.paragraph.civictheme_next_step.field_c_p_title
403403
- field.field.paragraph.civictheme_next_step.field_c_p_vertical_spacing
404+
- field.field.paragraph.civictheme_promo.field_c_p_background
404405
- field.field.paragraph.civictheme_promo.field_c_p_content
405406
- field.field.paragraph.civictheme_promo.field_c_p_link
406407
- field.field.paragraph.civictheme_promo.field_c_p_theme

web/themes/contrib/civictheme/civictheme.post_update.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,3 +532,49 @@ static function (CivicthemeUpdateHelper $helper) use ($old_field_configs): Trans
532532
},
533533
);
534534
}
535+
536+
/**
537+
* Add Background field to Promo Component.
538+
*/
539+
function civictheme_post_update_add_background_promo_component(array &$sandbox): ?string {
540+
$new_field_configs = [
541+
'field.field.paragraph.civictheme_promo.field_c_p_background' => 'field_config',
542+
];
543+
544+
$new_form_display_config = [
545+
'civictheme_promo' => [
546+
'field_c_p_background' => [
547+
'type' => 'boolean_checkbox',
548+
'weight' => 6,
549+
'region' => 'content',
550+
'settings' => [
551+
'display_label' => TRUE,
552+
],
553+
'third_party_settings' => [],
554+
],
555+
],
556+
];
557+
558+
return \Drupal::classResolver(CivicthemeUpdateHelper::class)->update(
559+
$sandbox,
560+
'paragraph',
561+
['civictheme_promo'],
562+
// Start callback.
563+
static function (CivicthemeUpdateHelper $helper) use ($new_field_configs): void {
564+
$config_path = \Drupal::service('extension.list.theme')->getPath('civictheme') . '/config/install';
565+
$helper->createConfigs($new_field_configs, $config_path);
566+
},
567+
// Process callback.
568+
static function (CivicthemeUpdateHelper $helper): void {
569+
// Noop.
570+
},
571+
// Finished callback.
572+
static function (CivicthemeUpdateHelper $helper) use ($new_form_display_config): TranslatableMarkup {
573+
foreach ($new_form_display_config as $bundle => $config) {
574+
$helper->updateFormDisplayConfig('paragraph', $bundle, $config);
575+
}
576+
577+
return new TranslatableMarkup("Added Background field to Promo Component.\n");
578+
}
579+
);
580+
}

web/themes/contrib/civictheme/config/install/core.entity_form_display.paragraph.civictheme_promo.default.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ langcode: en
22
status: true
33
dependencies:
44
config:
5+
- field.field.paragraph.civictheme_promo.field_c_p_background
56
- field.field.paragraph.civictheme_promo.field_c_p_content
67
- field.field.paragraph.civictheme_promo.field_c_p_link
78
- field.field.paragraph.civictheme_promo.field_c_p_theme
@@ -16,6 +17,13 @@ targetEntityType: paragraph
1617
bundle: civictheme_promo
1718
mode: default
1819
content:
20+
field_c_p_background:
21+
type: boolean_checkbox
22+
weight: 6
23+
region: content
24+
settings:
25+
display_label: true
26+
third_party_settings: { }
1927
field_c_p_content:
2028
type: text_textarea
2129
weight: 2

web/themes/contrib/civictheme/config/install/core.entity_view_display.paragraph.civictheme_promo.default.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ langcode: en
22
status: true
33
dependencies:
44
config:
5+
- field.field.paragraph.civictheme_promo.field_c_p_background
56
- field.field.paragraph.civictheme_promo.field_c_p_content
67
- field.field.paragraph.civictheme_promo.field_c_p_link
78
- field.field.paragraph.civictheme_promo.field_c_p_theme
@@ -17,6 +18,16 @@ targetEntityType: paragraph
1718
bundle: civictheme_promo
1819
mode: default
1920
content:
21+
field_c_p_background:
22+
type: boolean
23+
label: above
24+
settings:
25+
format: default
26+
format_custom_false: ''
27+
format_custom_true: ''
28+
third_party_settings: { }
29+
weight: 5
30+
region: content
2031
field_c_p_content:
2132
type: text_default
2233
label: above
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
langcode: en
2+
status: true
3+
dependencies:
4+
config:
5+
- field.storage.paragraph.field_c_p_background
6+
- paragraphs.paragraphs_type.civictheme_promo
7+
id: paragraph.civictheme_promo.field_c_p_background
8+
field_name: field_c_p_background
9+
entity_type: paragraph
10+
bundle: civictheme_promo
11+
label: Background
12+
description: 'Apply a themed background color and provide horizontal spacing to the component'
13+
required: false
14+
translatable: false
15+
default_value:
16+
-
17+
value: 0
18+
default_value_callback: ''
19+
settings:
20+
on_label: 'On'
21+
off_label: 'Off'
22+
field_type: boolean

web/themes/contrib/civictheme/includes/promo.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ function civictheme_preprocess_paragraph__civictheme_promo(array &$variables): v
1616
_civictheme_preprocess_paragraph__paragraph_field__link($variables);
1717
_civictheme_preprocess_paragraph__paragraph_field__theme($variables);
1818
_civictheme_preprocess_paragraph__paragraph_field__vertical_spacing($variables);
19+
_civictheme_preprocess_paragraph__paragraph_field__background($variables);
1920
}

web/themes/contrib/civictheme/src/CivicthemeColorManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ protected function saveMatrixToConfig(): static {
521521
* @SuppressWarnings(MissingImport)
522522
*/
523523
protected static function validateMatrixStructure(array $matrix): void {
524-
if (!is_array($matrix) || count($matrix) != 2) {
524+
if (count($matrix) != 2) {
525525
throw new \Exception(sprintf('Invalid color matrix structure: should be an array with exactly 2 elements keyed by "%s" and "%s"', self::COLOR_TYPE_BRAND, self::COLOR_TYPE_PALETTE));
526526
}
527527

0 commit comments

Comments
 (0)