|
4 | 4 |
|
5 | 5 | ==========================================================================
|
6 | 6 |
|
7 |
| - Description: |
| 7 | + Create an Item Introduction organism. |
8 | 8 |
|
9 |
| - Create an Item Introduction molecule. |
10 |
| - See [GHE]/flapjack/Modules-V1/wiki/Item-Introduction |
| 9 | + https://cfpb.github.io/design-system/patterns/item-introductions |
11 | 10 |
|
12 |
| - value: An object with the following options for value. |
| 11 | + value.show_category: (Optional) Whether to show category. |
13 | 12 |
|
14 |
| - value.show_category: Whether to show the category or not. |
15 |
| - value.heading: Heading text. |
16 |
| - value.paragraph.source: Body introduction text. |
17 |
| - value.authors: Array of author names and associated URLs. |
| 13 | + value.category: (Optional) Category to show above heading. |
18 | 14 |
|
19 |
| - value.date: A datetime for the post. |
20 |
| - value.has_social: Whether to show the share icons or not. |
21 |
| - value.social_options: An object with options for the share icons |
| 15 | + value.category_url: (Optional) URL to link category to. |
| 16 | + |
| 17 | + value.heading: Heading text. |
| 18 | + |
| 19 | + value.paragraph: (Optional) Subheader paragraph. |
| 20 | + |
| 21 | + value.authors: (Optional) A list of author names to be included |
| 22 | + on a byline. |
| 23 | + |
| 24 | + value.date: (Optional) A date to be included on a byline. |
| 25 | + |
| 26 | + value.has_social: Whether to show the share icons or not. |
| 27 | + |
| 28 | + value.social_options: (Optional) Share icon options. |
22 | 29 |
|
23 | 30 | ========================================================================== #}
|
24 | 31 |
|
25 | 32 |
|
26 | 33 | {% import 'molecules/social-media.html' as social_media with context %}
|
27 | 34 | {% import 'macros/category-slug.html' as category_slug %}
|
28 | 35 |
|
29 |
| -{% macro render(value) %} |
30 |
| - |
31 |
| -{% set filter_page = page.get_filter_data() %} |
32 |
| -{% set filter_page_url = pageurl(filter_page) if filter_page else none %} |
33 |
| -{% set published_date = value.date %} |
34 |
| -{% set has_authors = page.authors.exists() %} |
35 |
| -{% set social_options = value.social_options or {} %} |
36 |
| - |
| 36 | +{%- macro render( value ) %} |
37 | 37 | <div class="o-item-introduction">
|
38 |
| - {% if filter_page_url and page.categories.count() > 0 and value.show_category %} |
39 |
| - {{ category_slug.render(category=page.categories.first().name, href=filter_page_url) }} |
40 |
| - {% endif %} |
| 38 | + {% if value.show_category and value.category -%} |
| 39 | + {{ category_slug.render( value.category, href=value.category_url ) }} |
| 40 | + {%- endif %} |
| 41 | + |
41 | 42 | <h1>{{ value.heading | safe }}</h1>
|
42 | 43 |
|
43 |
| - {% if value.paragraph %} |
| 44 | + {% if value.paragraph -%} |
44 | 45 | <div class="lead-paragraph">{{ value.paragraph | safe }}</div>
|
45 |
| - {% endif %} |
| 46 | + {%- endif %} |
46 | 47 |
|
47 |
| - {% if published_date or has_authors %} |
48 |
| - <div class="meta"> |
49 |
| - {% endif %} |
50 |
| - {% if filter_page_url and has_authors %} |
51 |
| - <span class="byline"> |
52 |
| - {%- for author in page.get_authors() -%} |
53 |
| - {% if loop.first %}By {% elif loop.last %}and {% endif %} |
54 |
| - {{ author.name }} |
55 |
| - {%- if loop.length > 2 and loop.index < loop.length %}, {% endif %} |
56 |
| - {% endfor %} |
57 |
| - – |
58 |
| - </span> |
59 |
| - {% endif %} |
60 |
| - {% if published_date %} |
61 |
| - <span class="a-date"> |
62 |
| - {% import 'macros/time.html' as time %} |
63 |
| - {{ time.render(published_date, {'date':true}) }} |
64 |
| - </span> |
| 48 | + {% include 'atoms/byline.html' with context %} |
| 49 | + |
| 50 | + {% if value.has_social -%} |
| 51 | + {{ social_media.render( value.social_options or {} ) }} |
| 52 | + {%- endif %} |
| 53 | +</div> |
| 54 | +{% endmacro -%} |
| 55 | + |
| 56 | +{%- if value %} |
| 57 | + |
| 58 | +{% if page %} |
| 59 | + {% if not "category" in value %} |
| 60 | + {% set category = page.categories.values_list("name", flat=True).first() %} |
| 61 | + {% if category %} |
| 62 | + {% do value.update( { "category": category } ) %} |
| 63 | + |
| 64 | + {% set filter_page = page.get_filter_data() %} |
| 65 | + {% if filter_page %} |
| 66 | + {% do value.update( |
| 67 | + { "category_url": pageurl( filter_page ) } |
| 68 | + ) %} |
| 69 | + {% endif %} |
65 | 70 | {% endif %}
|
66 |
| - {% if published_date or has_authors %} |
67 |
| - </div> |
68 | 71 | {% endif %}
|
| 72 | +{% endif %} |
69 | 73 |
|
70 |
| - {% if value.has_social %} |
71 |
| - {{ social_media.render(social_options) }} |
72 |
| - {% endif %} |
73 |
| -</div> |
| 74 | +{{- render( value ) -}} |
74 | 75 |
|
75 |
| -{% endmacro %} |
| 76 | +{% endif -%} |
0 commit comments