Skip to content

Commit 29e985d

Browse files
Merge branch 'develop' into feature/GOVCMSCT2-121
2 parents ac0c3a1 + 23b4c06 commit 29e985d

27 files changed

+294
-121
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"@civictheme/uikit": "github:civictheme/uikit#fd4cbae4cf41ed780011c7e4f2366a3685561071"
3+
"@civictheme/uikit": "github:civictheme/uikit#921eef60baf3dc4bd1aef23beb5c429d199e49b8"
44
},
55
"scripts": {
66
"uikit-change": "node scripts/civictheme-uikit-version-manager/index.mjs"

web/modules/custom/civictheme_sdc/tests/src/Unit/SingleDirectoryComponentValidatorTest.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,92 @@ protected static function loadComponentDefinitionFromFs(string $component_name):
279279
);
280280
}
281281

282+
/**
283+
* Loads all component definitions from the civictheme components folder.
284+
*
285+
* @return array<int, array<mixed>>
286+
* An array of component definitions.
287+
*/
288+
public static function loadAllComponentDefinitionsFromCivicTheme(): array {
289+
$components_dir = dirname(__DIR__, 6) . '/themes/contrib/civictheme/components';
290+
$definitions = [];
291+
if (!is_dir($components_dir)) {
292+
return $definitions;
293+
}
294+
foreach (new \DirectoryIterator($components_dir) as $fileinfo) {
295+
if ($fileinfo->isDot() || !$fileinfo->isDir()) {
296+
continue;
297+
}
298+
$subdir = $fileinfo->getPathname();
299+
foreach (new \DirectoryIterator($subdir) as $subfileinfo) {
300+
if ($subfileinfo->isDot() || !$subfileinfo->isDir()) {
301+
continue;
302+
}
303+
$component_file = $subfileinfo->getPathname() . '/' . $subfileinfo->getFilename() . '.component.yml';
304+
if (file_exists($component_file)) {
305+
try {
306+
$definition = Yaml::parseFile($component_file);
307+
// Merge with additional required keys.
308+
$component_name = $subfileinfo->getFilename();
309+
$definition = array_merge(
310+
$definition,
311+
[
312+
'machineName' => $component_name,
313+
'extension_type' => 'theme',
314+
'id' => 'civictheme:' . $component_name,
315+
'library' => ['css' => ['component' => ['foo.css' => []]]],
316+
'path' => '',
317+
'provider' => 'civictheme',
318+
'template' => $component_name . '.twig',
319+
'group' => 'civictheme-group',
320+
'description' => 'CivicTheme component',
321+
]
322+
);
323+
$definitions[] = $definition;
324+
}
325+
catch (\Exception) {
326+
// Ignore invalid YAML files for this loader.
327+
continue;
328+
}
329+
}
330+
}
331+
}
332+
return $definitions;
333+
}
334+
335+
/**
336+
* Tests that all CivicTheme component definitions don't cause errors.
337+
*
338+
* @dataProvider dataProviderValidateAllCivicThemeDefinitionsValid
339+
*
340+
* @throws \Drupal\Core\Render\Component\Exception\InvalidComponentException
341+
*/
342+
public function testValidateAllCivicThemeDefinitionsValid(array $definition): void {
343+
$component_validator = new ComponentValidator();
344+
$component_validator->setValidator();
345+
$this->assertTrue(
346+
$component_validator->validateDefinition($definition, TRUE),
347+
sprintf(
348+
'The CivicTheme component definition "%s" did not pass validation.',
349+
$definition['machineName'] ?? '[unknown]'
350+
)
351+
);
352+
}
353+
354+
/**
355+
* Data provider with all CivicTheme component definitions.
356+
*
357+
* @return array<int, array<int, array<mixed>>>
358+
* The data.
359+
*/
360+
public static function dataProviderValidateAllCivicThemeDefinitionsValid(): array {
361+
$definitions = static::loadAllComponentDefinitionsFromCivicTheme();
362+
$result = [];
363+
foreach ($definitions as $definition) {
364+
$key = $definition['machineName'] ?? uniqid('component_', TRUE);
365+
$result[$key] = [$definition];
366+
}
367+
return $result;
368+
}
369+
282370
}

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

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,101 @@ function civictheme_post_update_update_editor_allowed_field(): string {
865865
return (string) new TranslatableMarkup('Allowed tags setting not set, aborting update.');
866866
}
867867

868+
/**
869+
* Update civictheme_side_navigation to use civictheme_sidebar_navigation.
870+
*
871+
* @SuppressWarnings(PHPMD.StaticAccess)
872+
*/
873+
function civictheme_post_update_update_sidebar_navigation_suggestion(): string {
874+
$config_factory = \Drupal::configFactory();
875+
$editable = $config_factory->getEditable('block.block.civictheme_side_navigation');
876+
if ($editable->isNew()) {
877+
return 'Sidebar navigation block config does not exist.';
878+
}
879+
$settings = $editable->get('settings') ?? [];
880+
if (empty($settings['suggestion']) || $settings['suggestion'] !== 'civictheme_sidebar_navigation') {
881+
$settings['suggestion'] = 'civictheme_sidebar_navigation';
882+
$editable->set('settings', $settings);
883+
$editable->save();
884+
return 'Updated civictheme_side_navigation block to use civictheme_sidebar_navigation suggestion.';
885+
}
886+
return 'No update needed for civictheme_side_navigation block.';
887+
}
888+
889+
/**
890+
* Add civictheme_message paragraph type and enable it for civictheme page.
891+
*
892+
* @SuppressWarnings(PHPMD.StaticAccess)
893+
*/
894+
function civictheme_post_update_add_civictheme_message_paragraph(): string {
895+
$new_configs = [
896+
// Paragraph type definition.
897+
'paragraphs.paragraphs_type.civictheme_message' => 'paragraphs_type',
898+
'field.storage.paragraph.field_c_p_message_type' => 'field_storage_config',
899+
'field.field.paragraph.civictheme_message.field_c_p_background' => 'field_config',
900+
'field.field.paragraph.civictheme_message.field_c_p_content' => 'field_config',
901+
'field.field.paragraph.civictheme_message.field_c_p_message_type' => 'field_config',
902+
'field.field.paragraph.civictheme_message.field_c_p_theme' => 'field_config',
903+
'field.field.paragraph.civictheme_message.field_c_p_title' => 'field_config',
904+
'field.field.paragraph.civictheme_message.field_c_p_vertical_spacing' => 'field_config',
905+
'core.entity_form_display.paragraph.civictheme_message.default' => 'entity_form_display',
906+
'core.entity_view_display.paragraph.civictheme_message.default' => 'entity_view_display',
907+
];
908+
909+
$config_path = \Drupal::service('extension.list.theme')->getPath('civictheme') . '/config/install';
910+
\Drupal::classResolver(CivicthemeUpdateHelper::class)->createConfigs($new_configs, $config_path);
911+
912+
// Enable civictheme_message for civictheme_page.
913+
$field_config_name = 'field.field.node.civictheme_page.field_c_n_components';
914+
$field_config = \Drupal::configFactory()->getEditable($field_config_name);
915+
916+
if (!$field_config->isNew()) {
917+
$handler_settings = $field_config->get('settings.handler_settings') ?: [];
918+
// Ensure target_bundles exists.
919+
if (!isset($handler_settings['target_bundles'])) {
920+
$handler_settings['target_bundles'] = [];
921+
}
922+
$handler_settings['target_bundles']['civictheme_message'] = 'civictheme_message';
923+
924+
// Ensure target_bundles_drag_drop exists.
925+
if (!isset($handler_settings['target_bundles_drag_drop'])) {
926+
$handler_settings['target_bundles_drag_drop'] = [];
927+
}
928+
$handler_settings['target_bundles_drag_drop']['civictheme_message'] = [
929+
'weight' => -52,
930+
'enabled' => TRUE,
931+
];
932+
933+
$field_config->set('settings.handler_settings', $handler_settings);
934+
$field_config->save();
935+
}
936+
937+
return (string) new TranslatableMarkup('Added civictheme_message paragraph type and enabled it for civictheme page.');
938+
}
939+
940+
/**
941+
* Update the field description for field_c_p_background.
942+
*/
943+
function civictheme_post_update_update_field_c_p_background_description(): string {
944+
$field_configs = [
945+
'field.field.paragraph.civictheme_accordion.field_c_p_background',
946+
'field.field.paragraph.civictheme_content.field_c_p_background',
947+
'field.field.paragraph.civictheme_map.field_c_p_background',
948+
'field.field.paragraph.civictheme_promo.field_c_p_background',
949+
'field.field.paragraph.civictheme_webform.field_c_p_background',
950+
];
951+
foreach ($field_configs as $field_config_name) {
952+
$field_config = \Drupal::configFactory()->getEditable($field_config_name);
953+
954+
if (!$field_config->isNew()) {
955+
$field_config->set('description', 'Apply a themed background colour and provide horizontal spacing to the component');
956+
$field_config->save();
957+
}
958+
}
959+
960+
return (string) new TranslatableMarkup('Updated field description for field_c_p_background.');
961+
}
962+
868963
/**
869964
* Add civictheme_fast_fact_card paragraph type and enable it for manual list.
870965
*

web/themes/contrib/civictheme/civictheme.theme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ require_once __DIR__ . '/includes/primary_navigation.inc';
4545
require_once __DIR__ . '/includes/promo.inc';
4646
require_once __DIR__ . '/includes/search.inc';
4747
require_once __DIR__ . '/includes/secondary_navigation.inc';
48+
require_once __DIR__ . '/includes/sidebar_navigation.inc';
4849
require_once __DIR__ . '/includes/system_main_block.inc';
4950
require_once __DIR__ . '/includes/site_section.inc';
5051
require_once __DIR__ . '/includes/skip_link.inc';
@@ -214,7 +215,6 @@ function civictheme_preprocess_block(array &$variables): void {
214215
_civictheme_preprocess_block__system_main_block($variables);
215216
_civictheme_preprocess_block__civictheme_banner($variables);
216217
_civictheme_preprocess_block__navigation($variables);
217-
_civictheme_preprocess_block__civictheme_footer_menu($variables);
218218
_civictheme_preprocess_block__content($variables);
219219
_civictheme_preprocess_block__civictheme_mobile_navigation($variables);
220220
_civictheme_preprocess_block__civictheme_social_links($variables);

web/themes/contrib/civictheme/config/install/editor.editor.civictheme_rich_text.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ settings:
7676
- '<figure class data-component-id>'
7777
- '<div class>'
7878
- '<iframe width height src title allowfullscreen>'
79+
- '<video controls class width height>'
80+
- '<source src type>'
81+
- '<a hreflang target title data-dialog-type data-dialog-options class="ct-content-link ct-content-link--external use-ajax ct-button--button ct-button--prompt ct-button--link ct-promo__button ct-theme-dark">'
82+
- '<table class="ct-theme-dark">'
7983
ckeditor5_style:
8084
styles:
8185
-

web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_accordion.field_c_p_background.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ field_name: field_c_p_background
99
entity_type: paragraph
1010
bundle: civictheme_accordion
1111
label: Background
12-
description: 'Apply a themed background color and provide horizontal spacing to the component'
12+
description: 'Apply a themed background colour and provide horizontal spacing to the component'
1313
required: false
1414
translatable: true
1515
default_value:

web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_content.field_c_p_background.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ field_name: field_c_p_background
99
entity_type: paragraph
1010
bundle: civictheme_content
1111
label: Background
12-
description: 'Apply a themed background color and provide horizontal spacing to the component'
12+
description: 'Apply a themed background colour and provide horizontal spacing to the component'
1313
required: false
1414
translatable: false
1515
default_value:

web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_map.field_c_p_background.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ field_name: field_c_p_background
99
entity_type: paragraph
1010
bundle: civictheme_map
1111
label: Background
12-
description: 'Apply a themed background color and provide horizontal spacing to the component'
12+
description: 'Apply a themed background colour and provide horizontal spacing to the component'
1313
required: false
1414
translatable: true
1515
default_value:

web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_message.field_c_p_background.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ field_name: field_c_p_background
99
entity_type: paragraph
1010
bundle: civictheme_message
1111
label: Background
12-
description: 'Apply a themed background color and provide horizontal spacing to the component'
12+
description: 'Apply a themed background colour and provide horizontal spacing to the component'
1313
required: false
1414
translatable: false
1515
default_value:

0 commit comments

Comments
 (0)