Skip to content

Commit ecc4982

Browse files
committed
shopping_list_design: Enh example
1 parent 5682d37 commit ecc4982

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

code_samples/shopping_list/add_to_shopping_list/templates/themes/standard/full/product.html.twig

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
{% endblock %}
1010

1111
{% block content %}
12-
{{ ibexa_content_name(content) }}
13-
{{ product.code }}
12+
<span>{{ ibexa_content_name(content) }}</span>
13+
<code>{{ product.code }}</code>
1414
{% if not product.isBaseProduct() and can_view_shopping_list and can_edit_shopping_list %}
1515
{% set component %}
1616
{% include '@ibexadesign/shopping_list/component/add_to_shopping_list/add_to_shopping_list.html.twig' with {
@@ -24,8 +24,8 @@
2424
<ul>
2525
{% for variant in variants %}
2626
<li>
27-
{{ variant.name }}
28-
{{ variant.code }}
27+
<span>{{ variant.name }}</span>
28+
<code>{{ variant.code }}</code>
2929
{% if can_view_shopping_list and can_edit_shopping_list %}
3030
{% set component %}
3131
{% include '@ibexadesign/shopping_list/component/add_to_shopping_list/add_to_shopping_list.html.twig' with {
@@ -46,11 +46,12 @@
4646

4747
{% macro add_to_shopping_list(product, component) %}
4848
{% set widget_id = 'add-to-shopping-list-' ~ product.code|slug %}
49-
<button
50-
onclick="(function(){let e=document.getElementById('{{ widget_id }}'); e.style.display=('none'===window.getComputedStyle(e).display)?'block':'none';})()">
51-
Add to shopping list
52-
</button>
53-
<div id="{{ widget_id }}" style="display: none;">
54-
{{ component }}
49+
<div style="display: inline-block;">
50+
<button onclick="(function(){let e=document.getElementById('{{ widget_id }}'); e.style.display=('none'===window.getComputedStyle(e).display)?'block':'none';})()">
51+
Add to shopping list
52+
</button>
53+
<div id="{{ widget_id }}" style="display: none; position: absolute; background: #fff;">
54+
{{ component }}
55+
</div>
5556
</div>
5657
{% endmacro %}
18.3 KB
Loading

docs/commerce/shopping_list/shopping_list_design.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ To have a more complete example, let's continue with a product full view templat
6868
``` twig hl_lines="7 8 16-18 31-33 44"
6969
[[= include_file('code_samples/shopping_list/add_to_shopping_list/templates/themes/standard/full/product.html.twig') =]]
7070
```
71-
Because the component uses some global variables, it can't be used directly in the macro.
71+
Because the component uses some global variables, it can't be used directly in a macro.
72+
73+
![](img/add_to_shopping_list_widget.png "Preview of this “Add to shopping list” widget example")
7274

7375
## `ShoppingList` JS class and `ibexaShoppingList` global
7476

0 commit comments

Comments
 (0)