-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds new Mozfest specific grid card block...
Also: - Add a template based on the original grid card block - Ensure fake data is built
- Loading branch information
1 parent
c5f4a49
commit ebd6885
Showing
7 changed files
with
1,784 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# flake8: noqa | ||
from .card_block import MozfestCardGridBlock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from wagtail import blocks | ||
from wagtail.images.blocks import ImageChooserBlock | ||
|
||
""" | ||
The following card and grid definitions are specifically for Mozfest. | ||
They are based on wagtailpages.pagemodels.customblocks.card_grid.py | ||
but have been modified to fit the Mozfest design. | ||
""" | ||
|
||
|
||
class MozfestCardGrid(blocks.StructBlock): | ||
image = ImageChooserBlock() | ||
|
||
alt_text = blocks.CharBlock(required=False, help_text="Alt text for card's image.") | ||
|
||
title = blocks.CharBlock(help_text="Heading for the card.") | ||
|
||
body = blocks.TextBlock(help_text="Body text of the card.", required=False) | ||
|
||
link_url = blocks.CharBlock( | ||
required=False, | ||
help_text="Optional URL that this card should link out to. " "(Note: If left blank, link will not render.) ", | ||
) | ||
|
||
link_label = blocks.CharBlock( | ||
required=False, | ||
help_text="Optional Label for the URL link above. " "(Note: If left blank, link will not render.) ", | ||
) | ||
|
||
|
||
class MozfestCardGridBlock(blocks.StructBlock): | ||
heading = blocks.CharBlock(help_text="Heading for the block.") | ||
cards = blocks.ListBlock(MozfestCardGrid(), help_text="Please use a minimum of 2 cards.") | ||
|
||
class Meta: | ||
icon = "placeholder" | ||
template = "fragments/blocks/mozfest_card_grid_block.html" | ||
label = "Mozfest Card Grid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,661 changes: 1,661 additions & 0 deletions
1,661
network-api/networkapi/mozfest/migrations/0031_alter_mozfestprimarypage_body.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
network-api/networkapi/mozfest/templates/fragments/blocks/mozfest_card_grid_block.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{% extends "wagtailpages/blocks/base_streamfield_block.html" %} | ||
{% load wagtailcore_tags wagtailimages_tags %} | ||
|
||
{% block block_content %} | ||
<h3>{{ self.heading }}</h3> | ||
<div class="tw-row"> | ||
{% for block in self.cards %} | ||
{% with card=block count=self.cards|length %} | ||
<div class="tw-px-8 small:tw-w-full {% if count > 2 %} large:tw-w-1/3 medium:tw-w-1/2 {% else %} medium:tw-w-1/2 {% endif %} tw-mb-12"> | ||
<div class="card-regular tw-h-full tw-flex tw-flex-col"> | ||
|
||
<div class="tw-w-full tw-aspect-video tw-bg-gray-05"> | ||
<picture> | ||
{% comment %} | ||
Because of the card layout, the image size is not increasing consistently with the device size. | ||
The image sizes are based on the layout on a banner page with wide layout. | ||
The designed image aspect ratio is 16:9. | ||
|
||
Screen sizes: | ||
small: "576px" | ||
medium: "768px" | ||
large: "992px" | ||
xlarge: "1200px" | ||
"2xl": "1400px" | ||
|
||
The picture element will use the first source with a matching media query. | ||
Using min-media queries, we need to list the breakpoints in decending order, otherwise larger screens will always use the first listed (because that min-width query would be fulfilled). | ||
{% endcomment %} | ||
{% image card.image fill-512x288 as img_small %} | ||
{% image card.image fill-1024x576 as img_small_2x %} | ||
{% image card.image fill-336x189 as img_medium %} | ||
{% image card.image fill-672x378 as img_medium_2x %} | ||
{% image card.image fill-448x252 as img_large %} | ||
{% image card.image fill-896x504 as img_large_2x %} | ||
{% image card.image fill-592x333 as img_xlarge %} | ||
{% image card.image fill-1184x666 as img_xlarge_2x %} | ||
<source media="(min-width: 1200px)" srcset="{{ img_xlarge.url }}, {{ img_xlarge_2x.url }} 2x" /> | ||
<source media="(min-width: 992px)" srcset="{{ img_large.url }}, {{ img_large_2x.url }} 2x" /> | ||
<source media="(min-width: 768px)" srcset="{{ img_medium.url }}, {{ img_medium_2x.url }} 2x" /> | ||
<source media="(max-width: 767px)" srcset="{{ img_small.url }}, {{ img_small_2x.url }} 2x" /> | ||
<img class="tw-w-full tw-h-full tw-object-cover" src="{{ img_small.url }}" alt="{{ img_small.alt_text }}" /> | ||
</picture> | ||
</div> | ||
|
||
<div class="tw-flex tw-flex-1"> | ||
<div class="tw-border-b-4 tw-border-gray-05 tw--mt-12 tw-bg-white tw-relative tw-mx-4 medium:tw-mx-8 tw-p-8 tw-w-full tw-flex tw-flex-col"> | ||
<h3 class="tw-h3-heading tw-mb-4">{{ card.title }}</h3> | ||
<p>{{ card.body }}</p> | ||
{% if card.link_label and card.link_url %} | ||
<a class="tw-cta-link tw-mb-4" href="{{ card.link_url }}">{{ card.link_label }}</a> | ||
{% endif %} | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
{% endwith %} | ||
{% endfor %} | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters