Skip to content

Commit

Permalink
Merge pull request #52 from thelia/feat/search-result
Browse files Browse the repository at this point in the history
search template
  • Loading branch information
leanormandon authored Sep 2, 2024
2 parents acecb8b + 92b1b29 commit e005cba
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 72 deletions.
70 changes: 1 addition & 69 deletions category.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,75 +8,7 @@
{% set totalProducts = resources('/api/front/products', {'productCategories.category.id': attr('category', 'id'), itemsPerPage:9, page: page}) %}

{% include '@components/Layout/Subheader/Category/SubheaderCategory.twig' with {title: attr('category', 'title'), description: attr('category', 'description'), nbProducts: products|length} %}

<section class="px-6 lg:px-[120px] py-6 lg:flex lg:gap-[115px] lg:justify-between">
<div class="w-[310px] lg:block hidden mt-[44px] sticky top-20">
<div class="h4 mb-[22px]">{{ 'Filter'|trans }}</div>

<div>
{% include '@components/Molecules/Accordion/Accordion.twig' with {
title: "Size" | trans,
content: ""
} %}
{% include '@components/Molecules/Accordion/Accordion.twig' with {
title: "Color" | trans,
content: "test"
} %}
{% include '@components/Molecules/Accordion/Accordion.twig' with {
title: "Material" | trans,
content: "test"
} %}
</div>
</div>

<div>
<div class="lg:justify-between lg:items-center mb-[29px] hidden lg:flex">
<span>{{ products|length }}
{{ 'item(s)'|trans }}</span>

<div class="w-[250px]">
{% include '@components/Molecules/Fields/FieldSelect/FieldSelect.twig' with {
label: "Sort by" | trans,
tooltip: "Sort the products" | trans,
placeholder: "Sort by" | trans,
options: [{
value: "priceASC",
label: "Price ascending" | trans
}, {
value: "priceDESC",
label: "Price descending" | trans
}, {
value: "newness",
label: "New arrivals" | trans
}, {
value: "promo",
label: "Promotions" | trans
}],
} %}
</div>

</div>

<div class="grid grid-cols-2 lg:grid-cols-3 gap-4 lg:gap-8 mb-[40px]">
{% for product in products %}
{% include '@components/Organisms/ProductCard/ProductCard.twig' with product|merge({displayWishButton: true}) %}
{% endfor %}
</div>

<div class='mx-auto lg:mx-0 lg:ml-auto w-max'>
{% include '@components/Molecules/Pagination/Pagination.twig' with {
prevText: 'Previous' | trans,
nextText: 'Next' | trans,
currentPage: page,
totalPages: 3
} %}
</div>

<p class="paragraph-4 lg:paragraph-2 lg:pt-[56px] lg:pb-[96px] max-w-[664px] pt-[102px] pb-[52px] mx-auto">
{{ attr('category', 'description') }}
</p>
</div>
</section>
{% include '@components/Layout/CategoryProduct/CategoryProduct.html.twig' with {products: products, totalProducts:totalProducts} %}

{% include '@components/Layout/Reinsurance/Reinsurance.twig' with { data: [
{
Expand Down
71 changes: 71 additions & 0 deletions components/Layout/CategoryProduct/CategoryProduct.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{% set products = products|default([]) %}
{% set totalProducts = totalProducts|default("") %}

<section class="px-6 lg:px-[120px] py-6 lg:flex lg:gap-[115px] lg:justify-between">
<div class="w-[310px] lg:block hidden mt-[44px] sticky top-20">
<div class="h4 mb-[22px]">{{ 'Filter'|trans }}</div>

<div>
{% include '@components/Molecules/Accordion/Accordion.twig' with {
title: "Size" | trans,
content: ""
} %}
{% include '@components/Molecules/Accordion/Accordion.twig' with {
title: "Color" | trans,
content: "test"
} %}
{% include '@components/Molecules/Accordion/Accordion.twig' with {
title: "Material" | trans,
content: "test"
} %}
</div>
</div>

<div>
<div class="lg:justify-between lg:items-center mb-[29px] hidden lg:flex">
<span>{{ products|length }}
{{ 'item(s)'|trans }}</span>

<div class="w-[250px]">
{% include '@components/Molecules/Fields/FieldSelect/FieldSelect.twig' with {
label: "Sort by" | trans,
tooltip: "Sort the products" | trans,
placeholder: "Sort by" | trans,
options: [{
value: "priceASC",
label: "Price ascending" | trans
}, {
value: "priceDESC",
label: "Price descending" | trans
}, {
value: "newness",
label: "New arrivals" | trans
}, {
value: "promo",
label: "Promotions" | trans
}],
} %}
</div>

</div>

<div class="grid grid-cols-2 lg:grid-cols-3 gap-4 lg:gap-8 mb-[40px]">
{% for product in products %}
{% include '@components/Organisms/ProductCard/ProductCard.twig' with product|merge({displayWishButton: true}) %}
{% endfor %}
</div>

<div class='mx-auto lg:mx-0 lg:ml-auto w-max'>
{% include '@components/Molecules/Pagination/Pagination.twig' with {
prevText: 'Previous' | trans,
nextText: 'Next' | trans,
currentPage: page,
totalPages: 3
} %}
</div>

<p class="paragraph-4 lg:paragraph-2 lg:pt-[56px] lg:pb-[96px] max-w-[664px] pt-[102px] pb-[52px] mx-auto">
{{ attr('category', 'description') }}
</p>
</div>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% set nbProducts = nbProducts|default(0) %}

<div class='Subheader Subheader--category'>
<div class='container flex flex-col mx-auto'>
<div class='max-w-[600px] w-full flex flex-col mx-auto'>
<h1 class='Subheader-title'>{{ title }}</h1>
<div class='Subheader-description'>
{{ description }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
{% set nbProducts = nbProducts|default(0) %}

<div class='Subheader Subheader--search'>
<div class='container flex flex-col mx-auto'>
<div class='max-w-[600px] w-full flex flex-col mx-auto'>
<h1 class='Subheader-title Subheader-title--search'>{{ title }}</h1>
<div>
{% include '@components/Molecules/SearchBar/SearchBar.twig' with { label: "Find a delivery address"|trans, classes: 'SearchBar--white ',placeholder: "e.g. City, Postcode"|trans,iconButtonLeft:true, iconButton: "search" } %}

</div>
<div class='Subheader-info'>
<div>{{ nbProducts}} {{ 'product(s)'|trans }}</div>
Expand Down
38 changes: 38 additions & 0 deletions search.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% extends 'base.html.twig' %}
{% set page = app.request.get('page')|default(1) %}
{% set searchString = app.request.get('query')|default("") %}

{% block title %}{{ 'Search'|trans }}
{% endblock %}

{% block body %}
{% set products = resources('/api/front/products', {itemsPerPage:9, page: page}) %}
{% set totalProducts = resources('/api/front/products', {itemsPerPage:9, page: page}) %}

{% include '@components/Layout/Subheader/SearchResult/SubheaderSearch.twig' with {title: "Search results" | trans, } %}
{% include '@components/Layout/CategoryProduct/CategoryProduct.html.twig' with {products: products, totalProducts:totalProducts} %}

{% include '@components/Layout/Reinsurance/Reinsurance.twig' with { data: [
{
strongText: 'Free delivery' | trans,
text: 'For any order over €100' | trans,
linkLabel: 'See conditions' | trans,
link: '#',
icon: 'reinsurance-delivery'
},
{
strongText: 'Secure payment' | trans,
text: 'Credit card, Paypal' | trans,
linkLabel: 'See conditions' | trans,
link: '#',
icon: 'reinsurance-payment'
},
{
strongText: 'Satisfied or refunded' | trans,
text: 'Exchange or refund offered within 30 days' | trans,
linkLabel: 'See conditions' | trans,
link: '#',
icon: 'reinsurance-satisfied'
}
] } %}
{% endblock %}
1 change: 1 addition & 0 deletions translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Your password: Your password
Forgot password?: Forgot password?
Don’t have an account yet?: Don’t have an account yet?
Sign up: Sign up
Search results: Search results
Description: Description
Features: Features
Shipping & Returns: Shipping & Returns
Expand Down
1 change: 1 addition & 0 deletions translations/messages.fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Your password: Votre mot de passe
Forgot password?: Mot de passe oublié ?
Don’t have an account yet?: Vous n'avez pas encore de compte ?
Sign up: S'inscrire
Search results: Résultat de recherche
Description: Description
Features: Caractéristiques
Shipping & Returns: Expédition & Retours
Expand Down

0 comments on commit e005cba

Please sign in to comment.