-
Notifications
You must be signed in to change notification settings - Fork 6
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
🗑️ [#2062] Remove card templatetags #1010
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 11 additions & 7 deletions
18
src/open_inwoner/components/templates/components/Card/CardContainer.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 |
---|---|---|
@@ -1,34 +1,38 @@ | ||
{% load card_tags helpers %} | ||
{% load helpers %} | ||
<div class="card-container{% if columns %} card-container--columns-{{columns}}{% endif %}{% if small %} card-container--small{% endif %}"> | ||
{% if categories %} | ||
{% for category in categories %} | ||
{% url 'products:category_detail' slug=category.slug as category_url %} | ||
{% if category.icon %} | ||
{% card src=category.icon.file.url alt=category.icon.name title=category.name href=category_url compact=True image_object_fit=image_object_fit %} | ||
{% include "components/Card/Card.html" with src=category.icon.file.url alt=category.icon.name title=category.name href=category_url compact=True image_object_fit=image_object_fit only %} | ||
{% else %} | ||
{% card src=category.image.file.url alt=category.image.name title=category.name href=category_url compact=True image_object_fit=image_object_fit %} | ||
{% include "components/Card/Card.html" with src=category.image.file.url alt=category.image.name title=category.name href=category_url compact=True image_object_fit=image_object_fit only %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{% if subcategories %} | ||
{% for subcategory in subcategories %} | ||
{% category_card category=subcategory parent_category=parent_category compact=True image_object_fit=image_object_fit %} | ||
{% include "components/Card/CategoryCard.html" with category=subcategory parent_category=parent_category compact=True image_object_fit=image_object_fit only %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{% if products %} | ||
{% for product in products %} | ||
{% get_product_url product as product_url %} | ||
{% product_card title=product.name description=product.summary url=product_url image=product.icon compact=True image_object_fit=image_object_fit %} | ||
{% include "components/Card/ProductCard.html" with title=product.name description=product.summary url=product_url image=product.icon compact=True image_object_fit=image_object_fit only %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{% if plans %} | ||
{% for plan in plans %} | ||
{% description_card title=plan.title description=plan.goal|truncatechars:51 url=plan.get_absolute_url elypsis=True object=plan compact=True image_object_fit=image_object_fit %} | ||
{% include "components/Card/DescriptionCard.html" with title=plan.title description=plan.goal|truncatechars:51 url=plan.get_absolute_url elypsis=True object=plan compact=True image_object_fit=image_object_fit only %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{{ contents }} | ||
{% if locations %} | ||
{% for location in locations %} | ||
{% include "components/Card/LocationCard.html" with location_name=location.name address_line_1=location.address_line_1 address_line_2=location.address_line_2 compact=True phonenumber=location.phonenumber email=location.email only %} | ||
{% endfor %} | ||
{% endif %} | ||
</div> |
16 changes: 16 additions & 0 deletions
16
src/open_inwoner/components/templates/components/Card/LocationCard.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,16 @@ | ||
{% load link_tags string_tags %} | ||
<div class="card card__body"> | ||
{% if location_name %} | ||
{% link href=location.get_absolute_url primary=True text=location_name extra_classes="h3" %} | ||
{% endif %} | ||
<div class="card__body--flex p--no-margin"> | ||
<p class="p">{{ address_line_1 }}</p> | ||
<p class="p">{{ address_line_2 }}</p> | ||
{% if phonenumber %} | ||
{% link href='tel:'|addstr:phonenumber secondary=True text=phonenumber %} | ||
{% endif %} | ||
{% if email %} | ||
{% link href='mailto:'|addstr:email secondary=True text=email %} | ||
{% endif %} | ||
</div> | ||
</div> |
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 |
---|---|---|
|
@@ -2,38 +2,9 @@ | |
|
||
from open_inwoner.components.utils import ContentsNode, parse_component_with_args | ||
|
||
from ...pdc.models import Category | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.inclusion_tag("components/Card/Card.html") | ||
def card(href, title, **kwargs): | ||
""" | ||
Render in a card. Only using variables. | ||
|
||
Usage: | ||
{% card href="https://maykinmedia.nl" %} | ||
|
||
Variables: | ||
+ href: url | where the card links to. | ||
+ title: string | this will be the card title. | ||
- alt: string | the alt of the header image. | ||
- compact: bool | Whether to use compact styling. | ||
- direction: string | can be set to "horizontal" to show contents horizontally. | ||
- inline: bool | Whether the card should be rendered inline. | ||
- src: string | the src of the header image. | ||
- compact: bool | Whether the card has uniform padding on all sides. | ||
- stretch: bool | Whether to stretch the card vertically. | ||
- tinted: bool | whether to use gray as background color. | ||
- type: string (info) | Set to info for an info card. | ||
- image: FilerImageField | an image that should be used. | ||
- image_object_fit: string | Can be set to either "cover" (default) or "contain". | ||
- grid: boolean | if the card should be a grid. | ||
""" | ||
return {**kwargs, "href": href, "title": title} | ||
|
||
|
||
@register.tag | ||
def render_card(parser, token): | ||
alextreme marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
|
@@ -55,113 +26,3 @@ def render_card(parser, token): | |
nodelist = parser.parse(("endrender_card",)) | ||
parser.delete_first_token() | ||
return ContentsNode(nodelist, "components/Card/RenderCard.html", **context_kwargs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very pleasant clean-up :-) |
||
|
||
|
||
@register.inclusion_tag("components/Card/CategoryCard.html") | ||
def category_card(category: Category, **kwargs): | ||
""" | ||
Renders a card prepopulated based on `category`. | ||
|
||
Usage: | ||
{% category_card category %} | ||
|
||
Available options: | ||
- category: Category | the category to render card for. | ||
""" | ||
return {**kwargs, "category": category} | ||
|
||
|
||
@register.inclusion_tag("components/Card/DescriptionCard.html") | ||
def description_card(title, description, url, **kwargs): | ||
""" | ||
Renders a card prepopulated based on `product`. | ||
|
||
Usage: | ||
{% description_card title=product.title description=product.intro url=product.get_absolute_url %} | ||
{% description_card title="title" description="description" url="https://maykinmedia.nl" %} | ||
|
||
Available options: | ||
+ title: string | The title of the card that needs to be displayed. | ||
+ description: string | The description that needs to be displayed. | ||
+ url: string | The url that the card should point to. | ||
- object: any | The object that needs to render aditional data. | ||
- image: FilerImageField | an image that should be used. | ||
""" | ||
kwargs.update(title=title, description=description, url=url) | ||
return kwargs | ||
|
||
|
||
@register.inclusion_tag("components/Card/ProductCard.html") | ||
def product_card(description, url, **kwargs): | ||
""" | ||
Renders a card with or without an image prepopulated based on `product`. | ||
|
||
Usage: | ||
{% product_card title=product.title description=product.intro url=product.get_absolute_url %} | ||
|
||
Available options: | ||
+ description: string | The description that needs to be displayed. | ||
+ url: string | The url that the card should point to. | ||
- title: string | The title of the card that may be displayed if there is no image. | ||
- object: any | The object that needs to render aditional data. | ||
- image: FilerImageField | an image that should be used. | ||
""" | ||
kwargs.update(description=description, url=url) | ||
return kwargs | ||
|
||
|
||
@register.inclusion_tag("components/Card/CardContainer.html") | ||
def card_container(categories=[], subcategories=[], products=[], plans=[], **kwargs): | ||
""" | ||
A card container where the category card or product card will be rendered in. | ||
|
||
Usage: | ||
{% card_container categories=categories %} | ||
|
||
Variables: | ||
- categories: Category[] | categories to render. | ||
- subcategories: Category[] | subcategories to render. | ||
- products: Product[] | products to render. | ||
- parent: Category | The parent of the given card_container | ||
- image_object_fit: string | Can be set to either "cover" (default) or "contain". | ||
""" | ||
if ( | ||
categories is None | ||
and subcategories is None | ||
and products is None | ||
and plans is None | ||
): | ||
assert False, "provide categories, subcategories, products or plans" | ||
|
||
return { | ||
**kwargs, | ||
"categories": categories, | ||
"subcategories": subcategories, | ||
"products": products, | ||
"plans": plans, | ||
} | ||
|
||
|
||
@register.tag() | ||
def render_card_container(parser, token): | ||
""" | ||
Nested content supported. | ||
|
||
Usage: | ||
{% render_card_container %} | ||
{% card href='https://www.example.com' title='example.com' %} | ||
{% endrender_card_container %} | ||
|
||
Variables: | ||
Supports all options from card, but optional. | ||
|
||
Extra context: | ||
- contents: string (HTML) | this is the context between the render_card and endrender_card tags | ||
""" | ||
bits = token.split_contents() | ||
context_kwargs = parse_component_with_args(parser, bits, "render_list") | ||
nodelist = parser.parse(("endrender_card_container",)) # End tag | ||
parser.delete_first_token() | ||
return ContentsNode( | ||
nodelist, "components/Card/CardContainer.html", **context_kwargs | ||
) # Template |
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
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
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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
{% extends 'master.html' %} | ||
{% load card_tags %} | ||
|
||
{% block content %} | ||
<div class="categories__content"> | ||
<h1 class="h1">{{configurable_text.theme_page.theme_title}}</h1> | ||
<p class="p">{{configurable_text.theme_page.theme_intro|linebreaksbr}}</p> | ||
|
||
{% card_container categories=object_list %} | ||
{% include "components/Card/CardContainer.html" with categories=object_list only %} | ||
</div> | ||
{% endblock content %} |
This file was deleted.
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this card is in the 'old' style and contains a link inside, (as opposed to all the other cards that are entirely clickable with a surrounding anchor instead) but then again: we'll indeed need to keep the phone/mail as clickable items.