Skip to content

Commit

Permalink
Merge pull request #152 from USEPA/IN-439b
Browse files Browse the repository at this point in the history
IN-439b USWDS Collection Styling for new Dynamic Lists
  • Loading branch information
johnrockweilercgi authored Jul 1, 2021
2 parents 3e3d4e7 + 33d47af commit ba6f978
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ bundle: views_reference_list
mode: default
content:
field_list_header:
weight: 1
weight: 0
settings:
size: 60
placeholder: ''
third_party_settings: { }
type: string_textfield
region: content
field_views_reference:
weight: 0
weight: 1
settings: { }
third_party_settings: { }
type: viewsreference_select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ id: paragraph.views_reference_list.field_views_reference
field_name: field_views_reference
entity_type: paragraph
bundle: views_reference_list
label: 'Views Reference'
label: 'Content Type'
description: ''
required: false
translatable: false
Expand Down
4 changes: 2 additions & 2 deletions config/sync/views.view.articles_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ display:
exposed: true
expose:
operator_id: field_keywords_target_id_op
label: 'Keywords (field_keywords)'
label: Keywords
description: ''
use_operator: false
operator: field_keywords_target_id_op
Expand Down Expand Up @@ -232,7 +232,7 @@ display:
display_extenders: { }
title: ''
use_ajax: true
use_more: true
use_more: false
use_more_always: true
use_more_text: 'Go to Google with this ''more'' link'
link_url: 'https://www.google.com/'
Expand Down
2 changes: 1 addition & 1 deletion config/sync/views.view.blog_post_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ display:
exposed: true
expose:
operator_id: field_keywords_target_id_op
label: 'Keywords (field_keywords)'
label: Keywords
description: ''
use_operator: false
operator: field_keywords_target_id_op
Expand Down
2 changes: 1 addition & 1 deletion config/sync/views.view.events_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ display:
exposed: true
expose:
operator_id: field_event_tags_target_id_op
label: 'Tags (field_event_tags)'
label: Tags
description: ''
use_operator: false
operator: field_event_tags_target_id_op
Expand Down
6 changes: 6 additions & 0 deletions docroot/modules/custom/epa_core/css/admin_forms.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* This file intends to override the 'Seven' theme styling used for admin pages. To be used in a pinch only. */
/* In 99% of circumstances, form items etc should be removed via configuration changes */

div[class*='exposed-filters-vr-exposed-filters-visible'] {
display: none;
}
11 changes: 11 additions & 0 deletions docroot/modules/custom/epa_core/epa_core.libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
hierarchy-handler:
version: 1.x
js:
js/HierarchySelectHandler.js: {}
dependencies:
- core/jquery
admin-forms:
version: 1.x
css:
theme:
css/admin_forms.css: {}
14 changes: 13 additions & 1 deletion docroot/modules/custom/epa_core/epa_core.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@
* Contains misc features for EPA intranet.
*/


/**
* Implements hook_views_plugins_style_alter() to show empty calendar when not events exist.
*/
function epa_core_views_plugins_style_alter(array &$plugins) {
$plugins['fullcalendar_view_display']['even empty'] = true;
}
}

/**
* Attach handler js if a hierarchy input type is detected
* Implements hook_form_alter().
*/
function epa_core_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if (str_contains($form_id, 'webform') && $form_id != "webform_source_form") {
$form['#attached']['library'][] = 'epa_core/hierarchy-handler';
}
$form['#attached']['library'][] = 'epa_core/admin-forms';
}
5 changes: 4 additions & 1 deletion docroot/themes/custom/epa_intranet/assets/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
min-width: 0;
}

div[class*='exposed-filters-vr-exposed-filters-visible'] {
display: none;
}

div.more-link {
margin-bottom: 1rem;
}
Expand All @@ -15,7 +19,6 @@ div.more-link {
font-family: Public Sans Web,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: .88rem;
line-height: 1.2;
margin-bottom: 1rem;
margin-top: 2rem;
padding-left: 1.25rem;
padding-right: 1.25rem;
Expand Down
13 changes: 13 additions & 0 deletions docroot/themes/custom/epa_intranet/epa_intranet.theme
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ function epa_intranet_preprocess_field(&$variables, $hook) {
}
}

// Determine final date value for recurring dates and make vals accessible via twig
function epa_intranet_preprocess_node__event(&$variables) {
if ($variables['view_mode'] == 'reference_list') {
$final_index = count($variables['elements']['field_event_date']['#items'])-1;
$last_element = $variables['elements']['field_event_date']['#items'][$final_index];
foreach($variables['elements']['field_event_date']['#items'] as $key => $item) {
$event_start_date = $item->getValue()['value'];
$variables['rawDateTime'] = date("Y-M-d H:i:s", $event_start_date);
$variables['displayMonth'] = date("M", $event_start_date);
$variables['displayDay'] = date("d", $event_start_date);
}
}
}

function epa_intranet_preprocess_media(&$variables) {
if ($variables['view_mode'] == 'slideshow') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
#}
{% set view_mode = element['#view_mode'] %}

{% if view_mode == 'reference_list' or view_mode == 'list' %}
{% if items|length > 1 %}
<em>
Expand Down Expand Up @@ -59,7 +58,7 @@
label_display == 'inline' ? 'inline',
] %}

{% if (formatter == 'smartdate_recurring' and showRecurring) or (formatter == 'addtocal_view' and showEventDate) or (formatter == 'smartdate_default' and showEventDate) %}
{% if (formatter == 'smartdate_recurring' and showRecurring) or (formatter == 'addtocal_view' and showEventDate) %}
<div{{ attributes.addClass(classes) }}>
{% if not label_hidden %}
{% if formatter == 'smartdate_recurring' %}
Expand All @@ -70,11 +69,11 @@
{% endif %}
<div class="card-body py-1 display-grid">
{% for item in items %}
{% if (item.recurring and formatter == 'smartdate_recurring') or (not item.recurring and formatter == 'addtocal_view') or (not item.recurring and formatter == 'smartdate_default') %}
{% if (item.recurring and formatter == 'smartdate_recurring') or (not item.recurring and formatter == 'addtocal_view') %}
<p{{ item.attributes }}>{{ item.content }}</p>
{% endif %}
{% endfor %}
</div>
</div>
{% endif %}
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
<div class="usa-collection__body">
{{ title_prefix }}
{{ title_attributes }}
<h3 class="usa-collection__heading">
<span class="usa-collection__heading font-weight-bold">
<a href="{{ url }}" rel="bookmark">{{ label }}</a>
</h3>
</span>
{{ title_suffix }}
</div>
</li>
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
<div class="usa-collection__body">
{{ title_prefix }}
{{ title_attributes }}
<h3 class="usa-collection__heading">
<span class="usa-collection__heading font-weight-bold">
<a href="{{ url }}" rel="bookmark">{{ label }}</a>
</h3>
</span>
{{ title_suffix }}
</div>
</li>
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,27 @@
* @ingroup themeable
*/
#}

<p>
<article{{ attributes }}>

<li {{ attributes.addClass('usa-collection__item') }}>
<div class="usa-collection__calendar-date">
<time datetime="{{ rawDateTime }}">
<span class="usa-collection__calendar-date-month">{{ displayMonth }}</span>
<span class="usa-collection__calendar-date-day">{{ displayDay }}</span>
</time>
</div>
<div class="usa-collection__body">
{{ title_prefix }}
{% if label and not page %}
{{ title_attributes }}
<a href="{{ url }}" rel="bookmark">{{ label }}</a>

<span class="usa-collection__heading font-weight-bold">
<a href="{{ url }}" rel="bookmark">{{ label }}</a>
</span>
{% endif %}
{{ title_suffix }}
<div class="usa-collection__description">
{{ content.field_event_date }}
</div>
</div>

<br/>
{{ content.field_event_date }}

</article>
</li>
</p>
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@

{% block paragraph %}
<div {{ attributes.addClass(classes) }}>
<div class="{{ isPage ? 'site-preview-heading' : 'm-0 font-weight-bold'}}">
<div class="site-preview-heading {{ not isPage ? 'm-0 p-0'}}">
{{ content.field_list_header }}
</div>
<article class="{{ isPage ? 'card-body' }} py-1">
<article class="{{ isPage ? 'card-body' }} py-1">
<ul class="usa-collection">
{{ content.field_views_reference }}
</ul>
Expand Down

0 comments on commit ba6f978

Please sign in to comment.