diff --git a/cfgov/hmda/jinja2/hmda/hmda-explorer.html b/cfgov/hmda/jinja2/hmda/hmda-explorer.html index b72effce500..56a717c12a7 100644 --- a/cfgov/hmda/jinja2/hmda/hmda-explorer.html +++ b/cfgov/hmda/jinja2/hmda/hmda-explorer.html @@ -3,7 +3,6 @@ {% import 'hmda-explorer-controls.html' as controls with context %} {% import 'hmda-explorer-results.html' as results with context %} {% import 'hmda-explorer-institutions.html' as institutions with context %} -{% import 'organisms/item-introduction.html' as item_introduction with context %} {% import 'templates/render_block.html' as render_block with context %} {% import 'templates/streamfield-sidefoot.html' as streamfield_sidefoot with context %} @@ -13,11 +12,7 @@ {% block content_main %} {% for block in page.header -%} - {% if block.block_type == 'item_introduction' %} - {{ item_introduction.render(block.value) }} - {% else %} - {{ render_block.render(block, loop.index) }} - {% endif %} + {{ render_block.render(block, loop.index) }} {%- endfor %}
diff --git a/cfgov/jinja2/v1/_includes/article.html b/cfgov/jinja2/v1/_includes/article.html index c4d09c75e2b..c21e2210eb6 100644 --- a/cfgov/jinja2/v1/_includes/article.html +++ b/cfgov/jinja2/v1/_includes/article.html @@ -38,21 +38,20 @@
- {% set data = { - 'category': page.categories.all(), + {% with value = { 'heading': page.title, 'date': page.date_published, - 'has_social': True, + 'has_social': true, 'social_options': { 'is_printable': true } } %} + {% for block in page.header -%} + {% if block.block_type == 'article_subheader' %} + {% do value.update( { 'paragraph': block.value } ) %} + {% endif %} + {% endfor %} - {% for block in page.header -%} - {% if block.block_type == 'article_subheader' %} - {% do data.update({'paragraph': block.value}) %} - {% endif %} - {% endfor %} - - {{ item_introduction.render(data) }} + {% include 'organisms/item-introduction.html' with context %} + {% endwith %}
diff --git a/cfgov/jinja2/v1/_includes/atoms/byline.html b/cfgov/jinja2/v1/_includes/atoms/byline.html new file mode 100644 index 00000000000..ca83032029d --- /dev/null +++ b/cfgov/jinja2/v1/_includes/atoms/byline.html @@ -0,0 +1,49 @@ +{# ========================================================================== + + Create a byline when given: + + value.authors: List of author names. + + value.date: Publication date. + +========================================================================== #} + +{%- macro render( value ) %} +{%- if value.authors or value.date -%} + +{%- endif %} +{%- endmacro %} + + +{%- if value %} + +{% if page and not "authors" in value %} + {% do value.update( + { "authors": page.authors.values_list( "name", flat=True ) } + ) %} +{% endif %} + +{{- render( value ) -}} + +{% endif -%} diff --git a/cfgov/jinja2/v1/_includes/macros/category-slug.html b/cfgov/jinja2/v1/_includes/macros/category-slug.html index b4fa5c24d73..a302f1d67bd 100644 --- a/cfgov/jinja2/v1/_includes/macros/category-slug.html +++ b/cfgov/jinja2/v1/_includes/macros/category-slug.html @@ -9,45 +9,35 @@ Render a category slug when given: - category: A string. + category: A category slug, e.g. "press-release". - href (optional): If present creates a link with - a path to which the category filter applies. - For example, if the slug is used on a blog article - then path should be '/about-us/blog/'. - Remember to leverage vars.path instead of - using the literal string '/about-us/blog/'. - Path is used to create the filtered URL: - {{ href }}?category={{ category }} + href (optional): If present creates a link with + a path to which the category filter applies. + For example, if the slug is used on a blog article + then path should be '/about-us/blog/'. + Path is used to create the filtered URL: + {{ href }}?categories={{ category }} classes (optional): Space separated list of class names. - use_blog_category (optional): Whether to use the blog category filter or not. - Defaults to false. - ========================================================================== #} -{% macro render(category, href, classes='', use_blog_category=false) %} +{% macro render( category, href, classes='' ) %} {% import 'macros/category-icon.html' as category_icon %} {% if href %} - {# TODO: Remove use_blog_category parameter when this element becomes atomic. #} - {% if use_blog_category %} - {% set href = href + '?blog_category=' + category | urlencode | replace('%20', '+') %} - {% else %} - {% set href = href + '?categories=' + category | urlencode | replace('%20', '+') %} - {% endif %} + {% set href = href + '?categories=' + category | urlencode %} {% endif %} - {% call _category_link(href, classes) %} - {% set cat = category_label(category) or category %} - {{ category_icon.render(cat) }} + {% call _category_link( href, classes ) -%} + {% set category_name = category_label( category ) or category %} + {{- category_icon.render( category_name ) }} Category: - {{ cat | safe }} - {% endcall %} + {{ category_name }} + {%- endcall %} {% endmacro %} -{% macro _category_link(href, classes) %} +{% macro _category_link( href, classes ) %} {% if href %} diff --git a/cfgov/jinja2/v1/_includes/molecules/text-introduction.html b/cfgov/jinja2/v1/_includes/molecules/text-introduction.html index e1539f27dd7..e2ced9719d3 100644 --- a/cfgov/jinja2/v1/_includes/molecules/text-introduction.html +++ b/cfgov/jinja2/v1/_includes/molecules/text-introduction.html @@ -4,79 +4,56 @@ ========================================================================= - Description: - Create a Text Introduction molecule. - See [GHE]/flapjack/Modules-V1/wiki/Text-Introduction - value: Object defined from a StreamField block. + https://cfpb.github.io/design-system/patterns/text-introductions value.eyebrow: (Optional) Text to display above heading. value.heading: (Optional) String for heading text. - value.intro: (Optional) String for body introduction text. + value.authors: (Optional) A list of author names to be included + on a byline. + + value.date: (Optional) A date to be included on a byline. - value.intro.source: TODO: add type and description. + value.intro: (Optional) String for body introduction text. value.body: (Optional) String for body text. - value.links: A tuple to create a list of links, containing: + value.links: A list of links, containing: - value.links[i].text: (Optional) A string for the text of the link. + value.links[i].text: A string for the text of the link. value.links[i].url: A string for the URL of the link. value.links[i].aria_label: (Optional) An aria-label for the link. - value.date: (Optional) A date to be included on a byline. - value.has_rule: Whether or not to render a rule line (border-bottom) at the bottom of the molecule. ========================================================================== #} -{% set published_date = value.date %} -{% set has_authors = page.authors.exists() %} -{% if value.eyebrow %} +{% if value.eyebrow -%}
{{ value.eyebrow }}
-{% endif %} -{% if value.heading %} +{%- endif %} + +{% if value.heading -%}

{{ value.heading }}

-{% endif %} +{%- endif %} -{% if published_date or has_authors %} -
-{% endif %} -{% if has_authors %} - -{% endif %} -{% if published_date %} - - {% import 'macros/time.html' as time %} - {{ time.render(published_date, {'date':true}) }} - -{% endif %} -{% if published_date or has_authors %} -
-{% endif %} +{% include 'atoms/byline.html' with context %} -{% if value.intro.source %} +{% if value.intro -%}
{{ value.intro | safe }}
-{% endif %} +{%- endif %} {% if value.body %} {{ value.body | safe }} {% endif %} + {% for link in value.links %} {% if link.text %} {% if loop.first %}
+{{- render( value ) -}} -{% endmacro %} +{% endif -%} diff --git a/cfgov/jinja2/v1/document-detail/index.html b/cfgov/jinja2/v1/document-detail/index.html index 7e93fc32b10..82d5c7e1ed0 100644 --- a/cfgov/jinja2/v1/document-detail/index.html +++ b/cfgov/jinja2/v1/document-detail/index.html @@ -9,15 +9,9 @@ {% block content_main %} {% for block in page.header -%} - {% if block.block_type == 'item_introduction' %} - {% import 'organisms/item-introduction.html' as item_introduction with context %} - {{ item_introduction.render(block.value) }} - {% else %} -
- {{ render_stream_child(block) }} -
- {% endif %} +
+ {{ render_stream_child(block) }} +
{%- endfor %} {% for block in page.content -%} diff --git a/cfgov/jinja2/v1/enforcement-action/index.html b/cfgov/jinja2/v1/enforcement-action/index.html index 6a7c03924f1..2c5c5e438df 100644 --- a/cfgov/jinja2/v1/enforcement-action/index.html +++ b/cfgov/jinja2/v1/enforcement-action/index.html @@ -10,15 +10,9 @@ {% block content_main %} {% for block in page.header -%} - {% if block.block_type == 'item_introduction' %} - {% import 'organisms/item-introduction.html' as item_introduction with context %} - {{ item_introduction.render(block.value) }} - {% else %} -
- {{ render_stream_child(block) }} -
- {% endif %} +
+ {{ render_stream_child(block) }} +
{%- endfor %} {% for block in page.content -%} diff --git a/cfgov/jinja2/v1/learn-page/index.html b/cfgov/jinja2/v1/learn-page/index.html index 7720e7217dd..7a4d3a571b2 100644 --- a/cfgov/jinja2/v1/learn-page/index.html +++ b/cfgov/jinja2/v1/learn-page/index.html @@ -1,6 +1,5 @@ {% extends 'layout-2-1.html' %} -{% import 'organisms/item-introduction.html' as item_introduction with context %} {% import 'templates/render_block.html' as render_block with context %} {% import 'templates/streamfield-sidefoot.html' as streamfield_sidefoot with context %} @@ -10,11 +9,7 @@ {% block content_main %} {% for block in page.header -%} - {% if block.block_type == 'item_introduction' %} - {{ item_introduction.render(block.value) }} - {% else %} - {{ render_block.render(block, loop.index) }} - {% endif %} + {{ render_block.render(block, loop.index) }} {%- endfor %} {% for block in page.content -%} diff --git a/cfgov/unprocessed/css/organisms/item-introduction.less b/cfgov/unprocessed/css/organisms/item-introduction.less index 908615308e5..509952c7a22 100644 --- a/cfgov/unprocessed/css/organisms/item-introduction.less +++ b/cfgov/unprocessed/css/organisms/item-introduction.less @@ -35,18 +35,18 @@ */ .o-item-introduction { - margin-bottom: unit( @grid_gutter-width * 2 / @base-font-size-px, em ); + margin-bottom: unit(@grid_gutter-width * 2 / @base-font-size-px, em); .short-desc { - padding-bottom: unit( @grid_gutter-width / 2 / @base-font-size-px, em ); + padding-bottom: unit(@grid_gutter-width / 2 / @base-font-size-px, em); } .lead-paragraph { margin-top: 0; } - .meta { - margin-bottom: unit( @grid_gutter-width / @base-font-size-px, em ); + .a-byline { + margin-bottom: unit(@grid_gutter-width / @base-font-size-px, em); .byline { .heading-4(); @@ -54,7 +54,6 @@ } } - /* topdoc name: EOF eof: true diff --git a/cfgov/v1/atomic_elements/organisms.py b/cfgov/v1/atomic_elements/organisms.py index 0a6aee41ba7..2cc99fff6d4 100644 --- a/cfgov/v1/atomic_elements/organisms.py +++ b/cfgov/v1/atomic_elements/organisms.py @@ -721,7 +721,6 @@ class ItemIntroduction(blocks.StructBlock): class Meta: icon = "form" template = "_includes/organisms/item-introduction.html" - classname = "block__flush-top" class FilterableList(BaseExpandable): diff --git a/cfgov/v1/jinja2/v1/template_debug.html b/cfgov/v1/jinja2/v1/template_debug.html index b9772b96cda..fafe0d3c851 100644 --- a/cfgov/v1/jinja2/v1/template_debug.html +++ b/cfgov/v1/jinja2/v1/template_debug.html @@ -7,7 +7,7 @@