forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolorselector-colorsquare-target.diff
28 lines (27 loc) · 1.11 KB
/
colorselector-colorsquare-target.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
diff --git a/assets/controllers/color-square_controller.js b/assets/controllers/color-square_controller.js
index 49051f0..6a1cac9 100644
--- a/assets/controllers/color-square_controller.js
+++ b/assets/controllers/color-square_controller.js
@@ -1,7 +1,11 @@
import { Controller } from 'stimulus';
export default class extends Controller {
+ targets = ['colorSquare']
+
selectColor(event) {
+ console.log(this.colorSquareTargets);
+
event.currentTarget.classList.add('selected');
}
}
diff --git a/templates/product/_cart_add_controls.html.twig b/templates/product/_cart_add_controls.html.twig
index 7578dcf..6a6b49d 100644
--- a/templates/product/_cart_add_controls.html.twig
+++ b/templates/product/_cart_add_controls.html.twig
@@ -10,6 +10,7 @@
class="color-square btn"
type="button"
data-action="color-square#selectColor"
+ data-color-square-target="colorSquare"
style="background-color: rgb({{ color.red }}, {{ color.green }}, {{ color.blue }});"
></button>
{% endfor %}