Skip to content

Commit

Permalink
[CIVIC-726] Added Snippet and Snippet Reference paragraphs to Drupal.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Aug 1, 2023
1 parent f0c55e8 commit 1c13f13
Show file tree
Hide file tree
Showing 32 changed files with 840 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,46 @@ function _cs_generated_content_create_node_civictheme_page__variations__componen
],
],

// All. Snippet.
[
'title' => 'Page. Component. Automated list, All, View as Snippet, Unlimited, Title, Content, Above link, Below link, Both space, Background',
'no_sidebar' => TRUE,
'components' => [
[
'type' => 'automated_list',
'title' => 'Automated list title Light',
'content' => $helper::staticSentenceFieldValue(),
'list_type' => $helper::civicthemeAutomatedListType(),
'list_link_above' => $helper::staticLinkFieldValue(),
'list_link_below' => $helper::staticLinkFieldValue(),
'list_limit_type' => $helper::civicthemeAutomatedListLimitTypeUnlimited(),
'list_limit' => 0,
'list_column_count' => 1,
'list_item_view_as' => $helper::civicthemeSnippetType(),
'list_item_theme' => $helper::civicthemeThemeLight(),
'theme' => $helper::civicthemeThemeLight(),
'vertical_spacing' => $helper::civicthemeVerticalSpacingTypeBoth(),
'background' => TRUE,
],
[
'type' => 'automated_list',
'title' => 'Automated list title Dark',
'content' => $helper::staticSentenceFieldValue(),
'list_type' => $helper::civicthemeAutomatedListType(),
'list_link_above' => $helper::staticLinkFieldValue(),
'list_link_below' => $helper::staticLinkFieldValue(),
'list_limit_type' => $helper::civicthemeAutomatedListLimitTypeUnlimited(),
'list_limit' => 0,
'list_column_count' => 1,
'list_item_view_as' => $helper::civicthemeSnippetType(),
'list_item_theme' => $helper::civicthemeThemeDark(),
'theme' => $helper::civicthemeThemeDark(),
'vertical_spacing' => $helper::civicthemeVerticalSpacingTypeBoth(),
'background' => TRUE,
],
],
],

// Page. Promo card.
[
'title' => 'Page. Component. Automated list, Light, Pages, View as Promo card, Light card, Unlimited, Title, Content, Above link, Below link, Both space, Background',
Expand All @@ -119,7 +159,6 @@ function _cs_generated_content_create_node_civictheme_page__variations__componen
],
],
],

// Page. Navigation card.
[
'title' => 'Page. Component. Automated list, Light, Pages, View as Navigation card, Light card, Unlimited, Title, Content, Above link, Below link, Both space, Background',
Expand All @@ -144,6 +183,30 @@ function _cs_generated_content_create_node_civictheme_page__variations__componen
],
],
],
// Page. Snippet.
[
'title' => 'Page. Component. Automated list, Light, Pages, View as Snippet, Light card, Unlimited, Title, Content, Above link, Below link, Both space, Background',
'no_sidebar' => TRUE,
'components' => [
[
'type' => 'automated_list',
'title' => 'Automated list title',
'content' => $helper::staticSentenceFieldValue(),
'list_type' => $helper::civicthemeAutomatedListType(),
'list_link_above' => $helper::staticLinkFieldValue(),
'list_link_below' => $helper::staticLinkFieldValue(),
'list_content_type' => $helper::civicthemePageContentType(),
'list_limit_type' => $helper::civicthemeAutomatedListLimitTypeUnlimited(),
'list_limit' => 0,
'list_column_count' => 1,
'list_item_view_as' => $helper::civicthemeSnippetType(),
'list_item_theme' => $helper::civicthemeThemeLight(),
'theme' => $helper::civicthemeThemeLight(),
'vertical_spacing' => $helper::civicthemeVerticalSpacingTypeBoth(),
'background' => TRUE,
],
],
],

// Event. Promo card.
[
Expand Down Expand Up @@ -193,6 +256,30 @@ function _cs_generated_content_create_node_civictheme_page__variations__componen
],
],
],
// Event. Snippet.
[
'title' => 'Page. Component. Automated list, Light, Pages, View as Snippet, Light card, Unlimited, Title, Content, Above link, Below link, Both space, Background',
'no_sidebar' => TRUE,
'components' => [
[
'type' => 'automated_list',
'title' => 'Automated list title',
'content' => $helper::staticSentenceFieldValue(),
'list_type' => $helper::civicthemeAutomatedListType(),
'list_link_above' => $helper::staticLinkFieldValue(),
'list_link_below' => $helper::staticLinkFieldValue(),
'list_content_type' => $helper::civicthemeEventContentType(),
'list_limit_type' => $helper::civicthemeAutomatedListLimitTypeUnlimited(),
'list_limit' => 0,
'list_column_count' => 1,
'list_item_view_as' => $helper::civicthemeSnippetType(),
'list_item_theme' => $helper::civicthemeThemeLight(),
'theme' => $helper::civicthemeThemeLight(),
'vertical_spacing' => $helper::civicthemeVerticalSpacingTypeBoth(),
'background' => TRUE,
],
],
],

// Limit.
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,36 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
$page = [
'components' => [
[
'title' => 'Light, Full width, 1 column, 1 card',
'title' => 'Promo card, Light, Full width, 1 column, 1 card',
'theme' => $helper::civicthemeThemeLight(),
'list_column_count' => 1,
'type' => 'manual_list',
'cards' => [
'list_items' => [
[
'type' => 'civictheme_promo_card',
'title' => $helper::staticSentence(3),
],
],
],
[
'title' => 'Light, Full width, 1 column, 1 card, fill width',
'title' => 'Promo card, Light, Full width, 1 column, 1 card, fill width',
'theme' => $helper::civicthemeThemeLight(),
'list_column_count' => 1,
'list_fill_width' => TRUE,
'type' => 'manual_list',
'cards' => [
'list_items' => [
[
'type' => 'civictheme_promo_card',
'title' => $helper::staticSentence(3),
],
],
],
[
'title' => 'Light, Full width, 2 column, 3 cards',
'title' => 'Promo card, Light, Full width, 2 column, 3 cards',
'theme' => $helper::civicthemeThemeLight(),
'list_column_count' => 2,
'type' => 'manual_list',
'cards' => [
'list_items' => [
[
'type' => 'civictheme_promo_card',
'title' => $helper::staticSentence(3),
Expand All @@ -62,12 +62,12 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
],
],
[
'title' => 'Light, Full width, 2 column, 3 cards, fill width',
'title' => 'Promo card, Light, Full width, 2 column, 3 cards, fill width',
'theme' => $helper::civicthemeThemeLight(),
'list_column_count' => 2,
'list_fill_width' => TRUE,
'type' => 'manual_list',
'cards' => [
'list_items' => [
[
'type' => 'civictheme_promo_card',
'title' => $helper::staticSentence(3),
Expand All @@ -83,12 +83,12 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
],
],
[
'title' => 'Light, Title, Content',
'title' => 'Promo card, Light, Title, Content',
'theme' => $helper::civicthemeThemeLight(),
'content' => $helper::staticSentence(8),
'type' => 'manual_list',
'list_column_count' => 2,
'cards' => [
'list_items' => [
[
'type' => 'civictheme_promo_card',
'title' => $helper::staticSentence(3),
Expand All @@ -104,12 +104,12 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
],
],
[
'title' => 'Dark, Title, Content',
'title' => 'Promo card, Dark, Title, Content',
'theme' => $helper::civicthemeThemeDark(),
'content' => $helper::staticSentenceFieldValue(8),
'type' => 'manual_list',
'list_column_count' => 2,
'cards' => [
'list_items' => [
[
'type' => 'civictheme_promo_card',
'title' => $helper::staticSentence(3),
Expand All @@ -125,15 +125,15 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
],
],
[
'title' => 'Light, BG, Title, Content, Before Link, After Link',
'title' => 'Promo card, Light, BG, Title, Content, Before Link, After Link',
'theme' => $helper::civicthemeThemeLight(),
'content' => $helper::staticSentenceFieldValue(8),
'list_link_above' => $helper::staticLinkFieldValue(2),
'list_link_below' => $helper::staticLinkFieldValue(2),
'background' => TRUE,
'type' => 'manual_list',
'list_column_count' => 2,
'cards' => [
'list_items' => [
[
'type' => 'civictheme_promo_card',
'title' => $helper::staticSentence(3),
Expand All @@ -149,15 +149,15 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
],
],
[
'title' => 'Dark, BG, Title, Content, Before Link, After Link',
'title' => 'Promo card, Dark, BG, Title, Content, Before Link, After Link',
'theme' => $helper::civicthemeThemeDark(),
'content' => $helper::staticSentenceFieldValue(8),
'list_link_above' => $helper::staticLinkFieldValue(2),
'list_link_below' => $helper::staticLinkFieldValue(2),
'background' => TRUE,
'type' => 'manual_list',
'list_column_count' => 2,
'cards' => [
'list_items' => [
[
'type' => 'civictheme_promo_card',
'title' => $helper::staticSentence(3),
Expand All @@ -177,7 +177,7 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
],

[
'title' => 'Light, BG, Title, Content, Before Link, After Link, Vertical Spacing',
'title' => 'Promo card, Light, BG, Title, Content, Before Link, After Link, Vertical Spacing',
'theme' => $helper::civicthemeThemeLight(),
'vertical_spacing' => $helper::civicthemeVerticalSpacingTypeBoth(),
'content' => $helper::staticSentenceFieldValue(8),
Expand All @@ -186,7 +186,7 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
'background' => TRUE,
'type' => 'manual_list',
'list_column_count' => 2,
'cards' => [
'list_items' => [
[
'type' => 'civictheme_promo_card',
'title' => $helper::staticSentence(3),
Expand All @@ -202,7 +202,7 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
],
],
[
'title' => 'Dark, BG, Title, Content, Before Link, After Link, Vertical Spacing',
'title' => 'Promo card, Dark, BG, Title, Content, Before Link, After Link, Vertical Spacing',
'theme' => $helper::civicthemeThemeDark(),
'vertical_spacing' => $helper::civicthemeVerticalSpacingTypeBoth(),
'content' => $helper::staticSentenceFieldValue(8),
Expand All @@ -211,7 +211,7 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
'background' => TRUE,
'type' => 'manual_list',
'list_column_count' => 2,
'cards' => [
'list_items' => [
[
'type' => 'civictheme_promo_card',
'title' => $helper::staticSentence(3),
Expand All @@ -229,6 +229,66 @@ function _cs_generated_content_create_node_civictheme_page__variations__manual_l
],
],
],

[
'title' => 'Snippet, Light, BG, Title, Content, Before Link, After Link, Vertical Spacing',
'theme' => $helper::civicthemeThemeLight(),
'vertical_spacing' => $helper::civicthemeVerticalSpacingTypeBoth(),
'content' => $helper::staticSentenceFieldValue(8),
'list_link_above' => $helper::staticLinkFieldValue(2),
'list_link_below' => $helper::staticLinkFieldValue(2),
'background' => TRUE,
'type' => 'manual_list',
'list_column_count' => 1,
'list_items' => [
[
'type' => 'civictheme_snippet',
'title' => $helper::staticSentence(3),
'summary' => $helper::staticPlainParagraph(),
],
[
'type' => 'civictheme_snippet',
'title' => $helper::staticSentence(3),
'summary' => $helper::staticPlainParagraph(),
],
[
'type' => 'civictheme_snippet',
'title' => $helper::staticSentence(3),
'summary' => $helper::staticPlainParagraph(),
],
],
],
[
'title' => 'Snippet, Dark, BG, Title, Content, Before Link, After Link, Vertical Spacing',
'theme' => $helper::civicthemeThemeDark(),
'vertical_spacing' => $helper::civicthemeVerticalSpacingTypeBoth(),
'content' => $helper::staticSentenceFieldValue(8),
'list_link_above' => $helper::staticLinkFieldValue(2),
'list_link_below' => $helper::staticLinkFieldValue(2),
'background' => TRUE,
'type' => 'manual_list',
'list_column_count' => 1,
'list_items' => [
[
'type' => 'civictheme_snippet',
'title' => $helper::staticSentence(3),
'summary' => $helper::staticPlainParagraph(),
'theme' => $helper::civicthemeThemeDark(),
],
[
'type' => 'civictheme_snippet',
'title' => $helper::staticSentence(3),
'summary' => $helper::staticPlainParagraph(),
'theme' => $helper::civicthemeThemeDark(),
],
[
'type' => 'civictheme_snippet',
'title' => $helper::staticSentence(3),
'summary' => $helper::staticPlainParagraph(),
'theme' => $helper::civicthemeThemeDark(),
],
],
],
],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public static function civicthemeNavigationCardType() {
return 'civictheme_navigation_card';
}

/**
* Snippet type name.
*/
public static function civicthemeSnippetType() {
return 'civictheme_snippet';
}

/**
* Available theme names.
*/
Expand Down Expand Up @@ -764,9 +771,9 @@ public static function civicthemeParagraphManualListAttach($node, $field_name, $
return NULL;
}

if (!empty($options['cards']) && count($options['cards']) > 0) {
$cards = $options['cards'];
unset($options['cards']);
if (!empty($options['list_items']) && count($options['list_items']) > 0) {
$list_items = $options['list_items'];
unset($options['list_items']);
}

$paragraph = self::civicthemeParagraphAttach('civictheme_manual_list', $node, $field_name, $options);
Expand All @@ -776,12 +783,12 @@ public static function civicthemeParagraphManualListAttach($node, $field_name, $
}

// Slider slide.
if (!empty($cards)) {
foreach ($cards as $card_options) {
if (!empty($card_options['type'])) {
$type = $card_options['type'];
unset($card_options['type']);
$card = self::civicthemeParagraphAttach($type, $paragraph, 'field_c_p_list_items', $card_options, TRUE);
if (!empty($list_items)) {
foreach ($list_items as $list_item_options) {
if (!empty($list_item_options['type'])) {
$type = $list_item_options['type'];
unset($list_item_options['type']);
$card = self::civicthemeParagraphAttach($type, $paragraph, 'field_c_p_list_items', $list_item_options, TRUE);
if (!empty($card)) {
$paragraph->field_c_p_list_items->appendItem($card);
}
Expand Down
Loading

0 comments on commit 1c13f13

Please sign in to comment.