diff --git a/package-lock.json b/package-lock.json index 6b86ca754..4946d0726 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "civictheme", + "name": "monorepo-drupal", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/tests/behat/features/paragraph.civictheme_fast_fact_card.fields.feature b/tests/behat/features/paragraph.civictheme_fast_fact_card.fields.feature new file mode 100644 index 000000000..d00ffdc34 --- /dev/null +++ b/tests/behat/features/paragraph.civictheme_fast_fact_card.fields.feature @@ -0,0 +1,26 @@ +@p1 @civictheme @civictheme_card @civictheme_fast_fact_card +Feature: Fast fact card fields + + @api + Scenario: Fields appear as expected + Given I am logged in as a user with the "Site Administrator" role + When I visit "node/add/civictheme_page" + And I fill in "Title" with "[TEST] Page fields" + When I press "Add Manual list" + And I press "Add Fast fact card" + + Then I should see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_title][0][value]']" element + And I should see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_title][0][value]'].required" element + And I should not see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_title][0][value]'][disabled]" element + + And I should see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_icon][media_library_selection]']" element + + And I should see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_summary][0][value]']" element + And I should not see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_summary][0][value]'].required" element + And I should not see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_summary][0][value]'][disabled]" element + + And I should see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_link][0][uri]']" element + And I should not see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_link][0][uri]'].required" element + And I should not see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_link][0][uri]'][disabled]" element + + And I should see an "[name='field_c_n_components[0][subform][field_c_p_list_items][0][subform][field_c_p_theme]']" element diff --git a/web/themes/contrib/civictheme/civictheme.info.yml b/web/themes/contrib/civictheme/civictheme.info.yml index 158c3ffd2..da93e9373 100644 --- a/web/themes/contrib/civictheme/civictheme.info.yml +++ b/web/themes/contrib/civictheme/civictheme.info.yml @@ -154,6 +154,7 @@ config_devel: - core.entity_form_display.paragraph.civictheme_event_card.default - core.entity_form_display.paragraph.civictheme_event_card_ref.default - core.entity_form_display.paragraph.civictheme_iframe.default + - core.entity_form_display.paragraph.civictheme_fast_fact_card.default - core.entity_form_display.paragraph.civictheme_manual_list.default - core.entity_form_display.paragraph.civictheme_map.default - core.entity_form_display.paragraph.civictheme_message.default @@ -216,6 +217,7 @@ config_devel: - core.entity_view_display.paragraph.civictheme_event_card.default - core.entity_view_display.paragraph.civictheme_event_card_ref.default - core.entity_view_display.paragraph.civictheme_iframe.default + - core.entity_view_display.paragraph.civictheme_fast_fact_card.default - core.entity_view_display.paragraph.civictheme_manual_list.default - core.entity_view_display.paragraph.civictheme_map.default - core.entity_view_display.paragraph.civictheme_message.default @@ -379,6 +381,11 @@ config_devel: - field.field.paragraph.civictheme_iframe.field_c_p_url - field.field.paragraph.civictheme_iframe.field_c_p_vertical_spacing - field.field.paragraph.civictheme_iframe.field_c_p_width + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_icon + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_link + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_summary + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_theme + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_title - field.field.paragraph.civictheme_manual_list.field_c_p_background - field.field.paragraph.civictheme_manual_list.field_c_p_content - field.field.paragraph.civictheme_manual_list.field_c_p_list_column_count @@ -602,6 +609,7 @@ config_devel: - paragraphs.paragraphs_type.civictheme_event_card - paragraphs.paragraphs_type.civictheme_event_card_ref - paragraphs.paragraphs_type.civictheme_iframe + - paragraphs.paragraphs_type.civictheme_fast_fact_card - paragraphs.paragraphs_type.civictheme_manual_list - paragraphs.paragraphs_type.civictheme_map - paragraphs.paragraphs_type.civictheme_message diff --git a/web/themes/contrib/civictheme/civictheme.post_update.php b/web/themes/contrib/civictheme/civictheme.post_update.php index b2f29ad39..e8bee20fd 100644 --- a/web/themes/contrib/civictheme/civictheme.post_update.php +++ b/web/themes/contrib/civictheme/civictheme.post_update.php @@ -960,6 +960,55 @@ function civictheme_post_update_update_field_c_p_background_description(): strin return (string) new TranslatableMarkup('Updated field description for field_c_p_background.'); } +/** + * Add civictheme_fast_fact_card paragraph type and enable it for manual list. + * + * @SuppressWarnings(PHPMD.StaticAccess) + */ +function civictheme_post_update_add_fast_fact_card_paragraph_type(): string { + $new_configs = [ + // Paragraph type definition. + 'paragraphs.paragraphs_type.civictheme_fast_fact_card' => 'paragraphs_type', + 'field.field.paragraph.civictheme_fast_fact_card.field_c_p_icon' => 'field_config', + 'field.field.paragraph.civictheme_fast_fact_card.field_c_p_link' => 'field_config', + 'field.field.paragraph.civictheme_fast_fact_card.field_c_p_summary' => 'field_config', + 'field.field.paragraph.civictheme_fast_fact_card.field_c_p_theme' => 'field_config', + 'field.field.paragraph.civictheme_fast_fact_card.field_c_p_title' => 'field_config', + 'core.entity_form_display.paragraph.civictheme_fast_fact_card.default' => 'entity_form_display', + 'core.entity_view_display.paragraph.civictheme_fast_fact_card.default' => 'entity_view_display', + ]; + + $config_path = \Drupal::service('extension.list.theme')->getPath('civictheme') . '/config/install'; + \Drupal::classResolver(CivicthemeUpdateHelper::class)->createConfigs($new_configs, $config_path); + + // Enable civictheme_fast_fact_card for civictheme_manual_list. + $field_config_name = 'field.field.paragraph.civictheme_manual_list.field_c_p_list_items'; + $field_config = \Drupal::configFactory()->getEditable($field_config_name); + + if (!$field_config->isNew()) { + $handler_settings = $field_config->get('settings.handler_settings') ?: []; + // Ensure target_bundles exists. + if (!isset($handler_settings['target_bundles'])) { + $handler_settings['target_bundles'] = []; + } + $handler_settings['target_bundles']['civictheme_fast_fact_card'] = 'civictheme_fast_fact_card'; + + // Ensure target_bundles_drag_drop exists. + if (!isset($handler_settings['target_bundles_drag_drop'])) { + $handler_settings['target_bundles_drag_drop'] = []; + } + $handler_settings['target_bundles_drag_drop']['civictheme_fast_fact_card'] = [ + 'weight' => -54, + 'enabled' => TRUE, + ]; + + $field_config->set('settings.handler_settings', $handler_settings); + $field_config->save(); + } + + return (string) new TranslatableMarkup('Added civictheme_fast_fact_card paragraph type and enabled it for manual list.'); +} + /** * Removes 'field_c_p_attributes' from civictheme_iframe paragraph. * diff --git a/web/themes/contrib/civictheme/config/install/core.entity_form_display.paragraph.civictheme_fast_fact_card.default.yml b/web/themes/contrib/civictheme/config/install/core.entity_form_display.paragraph.civictheme_fast_fact_card.default.yml new file mode 100644 index 000000000..04d1ebe98 --- /dev/null +++ b/web/themes/contrib/civictheme/config/install/core.entity_form_display.paragraph.civictheme_fast_fact_card.default.yml @@ -0,0 +1,58 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_icon + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_link + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_summary + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_theme + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_title + - paragraphs.paragraphs_type.civictheme_fast_fact_card + module: + - link + - media_library +id: paragraph.civictheme_fast_fact_card.default +targetEntityType: paragraph +bundle: civictheme_fast_fact_card +mode: default +content: + field_c_p_icon: + type: media_library_widget + weight: 2 + region: content + settings: + media_types: { } + third_party_settings: { } + field_c_p_link: + type: link_default + weight: 4 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + field_c_p_summary: + type: string_textarea + weight: 3 + region: content + settings: + rows: 5 + placeholder: '' + third_party_settings: { } + field_c_p_theme: + type: options_select + weight: 5 + region: content + settings: { } + third_party_settings: { } + field_c_p_title: + type: string_textfield + weight: 1 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } +hidden: + created: true + status: true diff --git a/web/themes/contrib/civictheme/config/install/core.entity_view_display.paragraph.civictheme_fast_fact_card.default.yml b/web/themes/contrib/civictheme/config/install/core.entity_view_display.paragraph.civictheme_fast_fact_card.default.yml new file mode 100644 index 000000000..f4ce3a590 --- /dev/null +++ b/web/themes/contrib/civictheme/config/install/core.entity_view_display.paragraph.civictheme_fast_fact_card.default.yml @@ -0,0 +1,61 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_icon + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_link + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_summary + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_theme + - field.field.paragraph.civictheme_fast_fact_card.field_c_p_title + - paragraphs.paragraphs_type.civictheme_fast_fact_card + module: + - link + - options +id: paragraph.civictheme_fast_fact_card.default +targetEntityType: paragraph +bundle: civictheme_fast_fact_card +mode: default +content: + field_c_p_icon: + type: entity_reference_label + label: above + settings: + link: true + third_party_settings: { } + weight: 2 + region: content + field_c_p_link: + type: link + label: above + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + weight: 4 + region: content + field_c_p_summary: + type: basic_string + label: above + settings: { } + third_party_settings: { } + weight: 3 + region: content + field_c_p_theme: + type: list_default + label: above + settings: { } + third_party_settings: { } + weight: 5 + region: content + field_c_p_title: + type: string + label: above + settings: + link_to_entity: false + third_party_settings: { } + weight: 1 + region: content +hidden: { } diff --git a/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_icon.yml b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_icon.yml new file mode 100644 index 000000000..974d96d50 --- /dev/null +++ b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_icon.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.field_c_p_icon + - media.type.civictheme_icon + - paragraphs.paragraphs_type.civictheme_fast_fact_card +id: paragraph.civictheme_fast_fact_card.field_c_p_icon +field_name: field_c_p_icon +entity_type: paragraph +bundle: civictheme_fast_fact_card +label: Icon +description: '' +required: true +translatable: false +default_value: { } +default_value_callback: '' +settings: + handler: 'default:media' + handler_settings: + target_bundles: + civictheme_icon: civictheme_icon + sort: + field: _none + direction: ASC + auto_create: false + auto_create_bundle: '' +field_type: entity_reference diff --git a/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_link.yml b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_link.yml new file mode 100644 index 000000000..84e5ff1b6 --- /dev/null +++ b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_link.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.field_c_p_link + - paragraphs.paragraphs_type.civictheme_fast_fact_card + module: + - link +id: paragraph.civictheme_fast_fact_card.field_c_p_link +field_name: field_c_p_link +entity_type: paragraph +bundle: civictheme_fast_fact_card +label: Link +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + title: 0 + link_type: 17 +field_type: link diff --git a/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_summary.yml b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_summary.yml new file mode 100644 index 000000000..72917240c --- /dev/null +++ b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_summary.yml @@ -0,0 +1,18 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.field_c_p_summary + - paragraphs.paragraphs_type.civictheme_fast_fact_card +id: paragraph.civictheme_fast_fact_card.field_c_p_summary +field_name: field_c_p_summary +entity_type: paragraph +bundle: civictheme_fast_fact_card +label: Summary +description: 'Limited to the number of characters configured in the theme settings. Any characters past the character limit will not show for users.' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: { } +field_type: string_long diff --git a/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_theme.yml b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_theme.yml new file mode 100644 index 000000000..560640020 --- /dev/null +++ b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_theme.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.field_c_p_theme + - paragraphs.paragraphs_type.civictheme_fast_fact_card + module: + - options +id: paragraph.civictheme_fast_fact_card.field_c_p_theme +field_name: field_c_p_theme +entity_type: paragraph +bundle: civictheme_fast_fact_card +label: Theme +description: '' +required: true +translatable: false +default_value: + - + value: light +default_value_callback: '' +settings: { } +field_type: list_string diff --git a/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_title.yml b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_title.yml new file mode 100644 index 000000000..da4527278 --- /dev/null +++ b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_fast_fact_card.field_c_p_title.yml @@ -0,0 +1,18 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.field_c_p_title + - paragraphs.paragraphs_type.civictheme_fast_fact_card +id: paragraph.civictheme_fast_fact_card.field_c_p_title +field_name: field_c_p_title +entity_type: paragraph +bundle: civictheme_fast_fact_card +label: Title +description: '' +required: true +translatable: false +default_value: { } +default_value_callback: '' +settings: { } +field_type: string diff --git a/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_manual_list.field_c_p_list_items.yml b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_manual_list.field_c_p_list_items.yml index c3621f747..459b4bc38 100644 --- a/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_manual_list.field_c_p_list_items.yml +++ b/web/themes/contrib/civictheme/config/install/field.field.paragraph.civictheme_manual_list.field_c_p_list_items.yml @@ -5,6 +5,7 @@ dependencies: - field.storage.paragraph.field_c_p_list_items - paragraphs.paragraphs_type.civictheme_event_card - paragraphs.paragraphs_type.civictheme_event_card_ref + - paragraphs.paragraphs_type.civictheme_fast_fact_card - paragraphs.paragraphs_type.civictheme_manual_list - paragraphs.paragraphs_type.civictheme_navigation_card - paragraphs.paragraphs_type.civictheme_navigation_card_ref @@ -34,6 +35,7 @@ settings: target_bundles: civictheme_event_card: civictheme_event_card civictheme_event_card_ref: civictheme_event_card_ref + civictheme_fast_fact_card: civictheme_fast_fact_card civictheme_navigation_card: civictheme_navigation_card civictheme_navigation_card_ref: civictheme_navigation_card_ref civictheme_promo_card: civictheme_promo_card @@ -47,90 +49,96 @@ settings: negate: 0 target_bundles_drag_drop: civictheme_accordion: - weight: -61 + weight: -63 enabled: false civictheme_accordion_panel: - weight: -60 + weight: -62 enabled: false civictheme_attachment: - weight: -59 + weight: -61 enabled: false civictheme_automated_list: - weight: -58 + weight: -60 enabled: false civictheme_callout: - weight: -57 + weight: -59 enabled: false civictheme_campaign: - weight: -56 + weight: -58 enabled: false civictheme_content: - weight: -55 + weight: -57 enabled: false civictheme_event_card: - weight: -54 + weight: -56 enabled: true civictheme_event_card_ref: - weight: -53 + weight: -55 enabled: true civictheme_iframe: - weight: -52 + weight: -53 enabled: false + civictheme_fast_fact_card: + weight: -54 + enabled: true civictheme_manual_list: - weight: -51 + weight: -52 enabled: false civictheme_map: - weight: -50 + weight: -51 + enabled: false + civictheme_message: + weight: -33 enabled: false civictheme_navigation_card: - weight: -49 + weight: -50 enabled: true civictheme_navigation_card_ref: - weight: -48 + weight: -49 enabled: true civictheme_next_step: - weight: -47 + weight: -48 enabled: false civictheme_promo: - weight: -46 + weight: -47 enabled: false civictheme_promo_card: - weight: -45 + weight: -46 enabled: true civictheme_promo_card_ref: - weight: -44 + weight: -45 enabled: true civictheme_publication_card: - weight: -43 + weight: -44 enabled: true civictheme_service_card: - weight: -41 + weight: -43 enabled: true civictheme_slider: - weight: -40 + weight: -42 enabled: false civictheme_slider_slide: - weight: -39 + weight: -41 enabled: false civictheme_slider_slide_ref: - weight: -38 + weight: -40 enabled: false civictheme_snippet: - weight: -37 + weight: -39 enabled: true civictheme_snippet_ref: - weight: -36 + weight: -38 enabled: true civictheme_social_icon: - weight: -35 + weight: -37 enabled: false civictheme_subject_card: - weight: -34 + weight: -36 enabled: true civictheme_subject_card_ref: - weight: -33 + weight: -35 enabled: true civictheme_webform: - weight: -32 + weight: -34 enabled: false field_type: entity_reference_revisions diff --git a/web/themes/contrib/civictheme/config/install/paragraphs.paragraphs_type.civictheme_fast_fact_card.yml b/web/themes/contrib/civictheme/config/install/paragraphs.paragraphs_type.civictheme_fast_fact_card.yml new file mode 100644 index 000000000..48dbf88d2 --- /dev/null +++ b/web/themes/contrib/civictheme/config/install/paragraphs.paragraphs_type.civictheme_fast_fact_card.yml @@ -0,0 +1,9 @@ +langcode: en +status: true +dependencies: { } +id: civictheme_fast_fact_card +label: 'Fast fact card' +icon_uuid: null +icon_default: null +description: '' +behavior_plugins: { } diff --git a/web/themes/contrib/civictheme/includes/cards.inc b/web/themes/contrib/civictheme/includes/cards.inc index 7d0edac3c..77bc8dac2 100644 --- a/web/themes/contrib/civictheme/includes/cards.inc +++ b/web/themes/contrib/civictheme/includes/cards.inc @@ -201,3 +201,17 @@ function civictheme_preprocess_paragraph__civictheme_service_card(array &$variab _civictheme_preprocess_paragraph__paragraph_field__links($variables); _civictheme_preprocess_paragraph__paragraph_field__theme($variables); } + +/** + * Implements template_preprocess_paragraph(). + */ +function civictheme_preprocess_paragraph__civictheme_fast_fact_card(array &$variables): void { + _civictheme_preprocess_paragraph__paragraph_field__theme($variables); + _civictheme_preprocess_paragraph__paragraph_field__title($variables); + _civictheme_preprocess_paragraph__paragraph_field__summary($variables); + _civictheme_preprocess_paragraph__paragraph_field__link($variables); + $media = civictheme_get_field_value($variables['paragraph'], 'field_c_p_icon', TRUE); + if ($media) { + $variables['image'] = civictheme_media_image_get_variables($media); + } +} diff --git a/web/themes/contrib/civictheme/package-lock.json b/web/themes/contrib/civictheme/package-lock.json index 979a45cf3..0c5a1c0b9 100644 --- a/web/themes/contrib/civictheme/package-lock.json +++ b/web/themes/contrib/civictheme/package-lock.json @@ -8037,21 +8037,6 @@ "dev": true, "license": "ISC" }, - "node_modules/yaml": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz", - "integrity": "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==", - "dev": true, - "license": "ISC", - "optional": true, - "peer": true, - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14.6" - } - }, "node_modules/yargs-parser": { "version": "20.2.9", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", diff --git a/web/themes/contrib/civictheme/templates/paragraphs/paragraph--civictheme-fast-fact-card.html.twig b/web/themes/contrib/civictheme/templates/paragraphs/paragraph--civictheme-fast-fact-card.html.twig new file mode 100644 index 000000000..1e81f8ddc --- /dev/null +++ b/web/themes/contrib/civictheme/templates/paragraphs/paragraph--civictheme-fast-fact-card.html.twig @@ -0,0 +1,7 @@ +{# +/** + * @file + * CivicTheme implementation to display a Fast Fact card. + */ +#} +{% include 'civictheme:fast-fact-card' %}