Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh: Update gallery component (Fix #15481) #15533

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions bedrock/base/templates/macros-m24.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,61 @@
#}

{#
Grid Tile
HTML Import: {% from "macros-m24.html" import grid_tile with context %}
Gallery Tile
HTML Import: {% from "macros-m24.html" import gallery_tile with context %}
CSS Import: @import '[path to]/m24/grid';
Macro Parameters:
class: String providing modifier class(es) to the tile component.
cta_text: String indicating CTA text (usually a translation id wrapped in an ftl function).
desc: String indicating paragraph text (usually a translation id wrapped in ftl function).
heading_level: Number indicating heading level for title text. Should be based on semantic meaning, not presentational styling.
image: Image to be used in the tile. Can pass an <img> element, resp_img or picture Python helpers.
image_desktop: Image to be used in the tile at desktop sizes. Can pass an <img> element, resp_img or picture Python helpers.
image_mobile: Image to be used in the tile at desktop sizes. Can pass an <img> element, resp_img or picture Python helpers.
link_attributes: A generic parameter to add any extra attributes to the CTA link, such as target, rel, or data attributes for GA tracking. Note that the quotes will pass through unescaped.
link_url (Required): String or url helper function provides href value for the tile link.
tag: A category tag for this gallery tile (e.g. product, program, event) (usually a translation id wrapped in ftl function).
tag_icon: (Do not translate) Last word of the icon class. Must be configured in the CSS. Currently supports: product, program, event.
title (Required): String indicating heading text (usually a translation id wrapped in ftl function).
#}
{% macro grid_tile(
{% macro gallery_tile(
class=None,
cta_text=None,
desc=None,
heading_level=3,
image=None,
link_attributes=None,
link_url=None,
tag='',
tag_icon=None,
title=''
) -%}
<div class="m24-c-gallery-tile{% if class %} {{ class }}{% endif %}">
<a href="{{ link_url }}" class="m24-c-gallery-tile-link"{% if link_attributes %} {{ link_attributes|safe }}{% endif %}>
{% if image %}
<div class="m24-c-gallery-tile-image">{{ image|safe }}</div>
{% endif %}
<div class="m24-c-gallery-tile-content">
<h{{ heading_level }} class="m24-c-gallery-tile-title"><span>{{ title }}</span></h{{ heading_level }}>
{% if desc %}
<div class="m24-c-gallery-tile {% if class %} {{ class }}{% endif %}">
<h{{ heading_level }} class="m24-c-gallery-tile-title">
<a href="{{ link_url }}" class="m24-c-gallery-tile-link"{% if link_attributes %} {{ link_attributes|safe }}{% endif %}>
<span>{{ title }}</span>
</a>
</h{{ heading_level }}>
{% if image %}
<div class="m24-c-gallery-tile-image">
{{ image|safe }}
</div>
{% endif %}
{% if tag %}
<div class="m24-c-gallery-tile-tag">
{% if tag_icon %}<span class="m24-c-gallery-tile-icon m24-c-gallery-tile-icon-{{ tag_icon|lower }}"></span>{% endif %}
{{ tag }}
</div>
{% endif %}
<div class="m24-c-gallery-tile-content">
{% if desc %}
<p class="m24-c-gallery-tile-desc">{{ desc }}</p>
{% endif %}
{% if cta_text %}
{% endif %}
{% if cta_text %}
<p class="m24-c-gallery-tile-cta">
<span>{{ cta_text }}</span>
</p>
{% endif %}
{% endif %}
</div>
</a>
</div>
{%- endmacro %}

Expand All @@ -59,9 +74,9 @@
image: Thumbnail image. Can pass an <img> element, resp_img or picture Python helpers.
link_attributes: A generic parameter to add any extra attributes to the CTA link, such as target, rel, or data attributes for GA tracking. Note that the quotes will pass through unescaped.
link_url (Required): String or url helper function provides href value for item.
preview: Blurb / summary of the media.
topic: One or two word topic of the item. Perhaps one of the things the item is "tagged" with if it's a blog post.
type: (Should be translated) Type of media the item links to. Probably one of podcast, article, video.
preview: Blurb / summary of the media. (usually a translation id wrapped in ftl function).
topic: One or two word topic of the item. Perhaps one of the things the item is "tagged" with if it's a blog post. (usually a translation id wrapped in ftl function).
type: Type of media the item links to. Probably one of podcast, article, video. (usually a translation id wrapped in ftl function).
type_icon: (Do not translate) Last word of the icon class. Must be configured in the CSS. Currently supports: podcast, article, video.
#}
{% macro springboard_item(
Expand Down
65 changes: 0 additions & 65 deletions bedrock/mozorg/templates/mozorg/about/includes/m24/amplify.html

This file was deleted.

108 changes: 108 additions & 0 deletions bedrock/mozorg/templates/mozorg/about/includes/m24/news.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@

{#
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
#}

{% from "macros-m24.html" import gallery_tile with context %}

<section class="m24-c-content">
<header class="m24-c-intro">
<h2 class="m24-c-intro-title">Read the latest Mozilla news &amp; articles</h2>
</header>
<div class="m24-c-gallery-container">

{{ gallery_tile(
class='m24-l-grid-three-quarters',
image=picture(
url="img/m24/todo-27-1.svg",
optional_attributes={
"loading": "lazy",
"alt": "",
"width": "1440",
"height": "533",
}
),
title='14 AI projects to watch: Mozilla’s first Builders Accelerator cohort kicks off',
link_url='#',
cta_text='Read more'
) }}
</div>
<div class="m24-c-gallery-container">
{{ gallery_tile(
class='m24-l-grid-third',
image=picture(
url="img/mozorg/about/m24/rise25-mobile.jpg",
sources=[
{
'media': '(max-width: 1311px)',
'srcset': {
"img/mozorg/about/m24/rise25-mobile.jpg": "318w",
"img/mozorg/about/m24/rise25-mobile-high-res.jpg": "634w",
},
'sizes': {
"(min-width: 768px)": "calc(50vw - 32px)",
"default": "calc(100vw - 32px)",
}
},
{
'srcset': {
'img/mozorg/about/m24/news-rise25-4-5.png': '564w',
'img/mozorg/about/m24/news-rise25-4-5-high-res.png': '1128w'
},
'sizes': {
"(min-width: 1440px)": "448px",
"default": "calc(33vw - 32px)",
}
},
],
optional_attributes={
"loading": "lazy",
"alt": "",
}
),
title='At our Rise25 Awards, the future of AI is trustworthy, inclusive and accountable',
link_url='#',
cta_text='Read more'
) }}

{{ gallery_tile(
class='m24-l-grid-quarter',
image=picture(
url="img/mozorg/about/m24/chicago-mobile.jpg",
sources=[
{
'media': '(max-width: 1311px)',
'srcset': {
"img/mozorg/about/m24/chicago-mobile.jpg": "318w",
"img/mozorg/about/m24/chicago-mobile-high-res.jpg": "634w",
},
'sizes': {
"(min-width: 768px)": "calc(50vw - 32px)",
"default": "calc(100vw - 32px)",
},
},
{
'srcset': {
'img/mozorg/about/m24/news-chicago.png': '332w',
'img/mozorg/about/m24/news-chicago-high-res.png': '664w'
},
'sizes': {
"(min-width: 1440px)": "448px",
"default": "calc(25vw - 32px)",
},
},
],
optional_attributes={
"loading": "lazy",
"alt": "",
}
),
title='Empowering Chicago’s entrepreneurs for generational change',
link_url='#',
cta_text='Read more'
) }}

</div>
</section>
2 changes: 1 addition & 1 deletion bedrock/mozorg/templates/mozorg/about/index-m24.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<main>
{% include 'mozorg/about/includes/m24/intro.html'%}
{% include 'mozorg/about/includes/m24/manifesto.html'%}
{% include 'mozorg/about/includes/m24/amplify.html'%}
{% include 'mozorg/about/includes/m24/news.html'%}
{% include 'mozorg/about/includes/m24/impact.html'%}
{% include 'mozorg/about/includes/m24/careers.html'%}
{% include 'mozorg/about/includes/m24/community.html'%}
Expand Down
4 changes: 2 additions & 2 deletions bedrock/mozorg/templates/mozorg/home/home-m24.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
{% include 'mozorg/home/includes/m24/hero.html'%}
{% include 'mozorg/home/includes/m24/products.html'%}
{% include 'mozorg/home/includes/m24/donate.html'%}
{% include 'mozorg/home/includes/m24/ai-grid.html'%}
{% include 'mozorg/home/includes/m24/ai-gallery.html'%}
{% include 'mozorg/home/includes/m24/media-springboard.html'%}
{% include 'mozorg/home/includes/m24/showcase.html'%}
{% include 'mozorg/home/includes/m24/resources-grid.html'%}
{% include 'mozorg/home/includes/m24/resources-gallery.html'%}

</main>

Expand Down
Loading