Skip to content

Commit 19a8882

Browse files
committed
[IMP] awesome_owl: add counter component as sub component to playground
1 parent 4c650f3 commit 19a8882

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

awesome_owl/static/src/counter.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** @odoo-module **/
2+
3+
import { Component, useState } from "@odoo/owl";
4+
5+
export class Counter extends Component {
6+
static template = "awesome_owl.counter";
7+
8+
setup() {
9+
this.state = useState({ value: 0 });
10+
}
11+
12+
increment() {
13+
this.state.value++;
14+
}
15+
}

awesome_owl/static/src/counter.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
4+
<t t-name="awesome_owl.counter">
5+
<div>Hello World
6+
<p>Counter: <t t-esc="state.value"/>
7+
</p>
8+
<button class="btn btn-primary" t-on-click="increment">Increment</button>
9+
</div>
10+
</t>
11+
12+
</templates>
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/** @odoo-module **/
22

3-
import { Component } from "@odoo/owl";
3+
import { Component, useState } from "@odoo/owl";
4+
import { Counter } from "./counter";
45

56
export class Playground extends Component {
67
static template = "awesome_owl.playground";
7-
}
8+
static components = { Counter };
9+
}

awesome_owl/static/src/playground.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
<templates xml:space="preserve">
33

44
<t t-name="awesome_owl.playground">
5-
<div class="p-3">
6-
hello world
7-
</div>
5+
<Counter></Counter>
6+
<Counter></Counter>
87
</t>
98

10-
</templates>
9+
</templates>

0 commit comments

Comments
 (0)