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

💄 #768 - Homepage styling. #339

Merged
merged 1 commit into from
Nov 21, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
{% for category in categories %}
{% url 'pdc: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 %}
{% card src=category.icon.file.url alt=category.icon.name title=category.name href=category_url image_object_fit=image_object_fit %}
{% else %}
{% card src=category.image.file.url alt=category.image.name title=category.name href=category_url %}
{% card src=category.image.file.url alt=category.image.name title=category.name href=category_url image_object_fit=image_object_fit %}
{% endif %}
{% endfor %}
{% endif %}

{% if subcategories %}
{% for subcategory in subcategories %}
{% category_card category=subcategory parent_category=parent_category %}
{% category_card category=subcategory parent_category=parent_category image_object_fit=image_object_fit %}
{% endfor %}
{% endif %}

{% if products %}
{% for product in products %}
{% get_product_url product as product_url %}
{% description_card title=product.name description=product.summary url=product_url image=product.icon %}
{% description_card title=product.name description=product.summary url=product_url image=product.icon image_object_fit=image_object_fit %}
{% 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 %}
{% description_card title=plan.title description=plan.goal|truncatechars:51 url=plan.get_absolute_url elypsis=True object=plan image_object_fit=image_object_fit %}
{% endfor %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="card{% if inline %} card--inline{% endif %}{% if tinted %} card--tinted{% endif %}{% if type %} card--type-{{ type }}{% endif %}">
{% if src %}
<a class="card__header" href="{{ href }}" title="{{ title }}" aria-describedby="{{ title }}">
<img class="card__img" src="{{ src }}" alt="{{ alt }}"/>
<img class="card__img{% if image_object_fit %} card__img--{{ image_object_fit }}{% endif %}" src="{{ src }}" alt="{{ alt }}"/>
</a>
{% endif %}

Comment on lines 4 to 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe sometime in the future we can find a more readable way to do conditional classes?

Expand Down
2 changes: 2 additions & 0 deletions src/open_inwoner/components/templatetags/card_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def card(href, title, **kwargs):
- 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}
Expand Down Expand Up @@ -100,6 +101,7 @@ def card_container(categories=[], subcategories=[], products=[], plans=[], **kwa
- 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
Expand Down
3 changes: 3 additions & 0 deletions src/open_inwoner/scss/components/Card/Card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
width: 100%;
}

&__img--contain {
object-fit: contain;
}
&__body {
padding: var(--card-spacing);
}
Expand Down
7 changes: 6 additions & 1 deletion src/open_inwoner/scss/components/Typography/P.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
}

*[class^='h'] + .p {
margin-top: var(--font-line-height-body);
margin-top: var(--spacing-small);
}
.p + .h1,
.p + .h2,
.p + .h3 {
margin-top: var(--gutter-width);
}

.p + .p {
Expand Down
8 changes: 3 additions & 5 deletions src/open_inwoner/templates/pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ <h2 class="h2">
<p class="p">{{configurable_text.home_page.home_theme_intro|linebreaksbr}}</p>

{% if request.user.is_authenticated %}
{% card_container categories=categories columns=3 %}
{% card_container categories=categories columns=3 image_object_fit="contain" %}
{% else %}
{% card_container categories=categories %}
{% card_container categories=categories image_object_fit="container" %}
{% endif %}

{% if questionnaire_roots.exists %}
Expand All @@ -37,9 +37,7 @@ <h2 class="h2">{% trans "Waar bent u naar op zoek?" %}</h2>
{% endif %}

{% if condition %}
{% render_grid %}
{% product_finder condition=condition form=condition_form form_action="pdc:product_finder" primary_text=_("Start") %}
{% endrender_grid %}
{% product_finder condition=condition form=condition_form form_action="pdc:product_finder" primary_text=_("Start") %}
{% endif %}

<h2 class="h2">{{configurable_text.home_page.home_map_title}}</h2>
Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/templates/pages/user-home.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<h1 class="h1">{{ configurable_text.home_page.home_welcome_title }} {{ request.user.get_full_name }}</h1>
<p class="p">{{ configurable_text.home_page.home_welcome_intro|linebreaksbr }}</p>

<h2 class="h2 h2--extra">
<h2 class="h2">
Samenwerken
{% button href="plans:plan_list" text=_("Naar samenwerken") icon="arrow_forward" icon_position="after" %}
</h2>

{% if plans %}
<div class="card-container card-container--columns-3">
{% for plan in plans %}
{% render_card %}
{% render_card image_object_fit="contain" %}
<h3 class="h3">{{ plan.title }}</h3>
<p class="p">{{ plan.goal|truncatewords:20 }}</p>
<a
Expand Down