Skip to content

Commit cf7f52b

Browse files
committed
[INIT] owl_playground : ch1 tasks 1-3
1 parent d4bc963 commit cf7f52b

File tree

6 files changed

+64
-6
lines changed

6 files changed

+64
-6
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Component, useState } from "@odoo/owl";
2+
3+
4+
export class Card extends Component {
5+
static template = "awesome_owl.card";
6+
7+
static props = {
8+
title: {type: String},
9+
content: {type: String}
10+
}
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
<t t-name="awesome_owl.card">
4+
<div class="card d-inline-block m-2" style="width: 18rem;">
5+
<div class="card-body">
6+
<h5 class="card-title">
7+
<t t-out="props.title"/>
8+
</h5>
9+
<p class="card-text">
10+
<t t-out="props.content"/>
11+
</p>
12+
</div>
13+
</div>
14+
</t>
15+
</templates>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component, useState } from "@odoo/owl";
2+
3+
4+
export class Counter extends Component {
5+
static template = "awesome_owl.counter";
6+
7+
setup() {
8+
this.state = useState({ counter: 0 });
9+
}
10+
11+
incrementCounter() {
12+
this.state.counter++;
13+
}
14+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
<t t-name="awesome_owl.counter">
4+
<p>Counter: <t t-esc="state.counter"/></p>
5+
<button t-on-click="incrementCounter">Increment</button>
6+
</t>
7+
</templates>
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import { Component } from "@odoo/owl";
1+
import { Component, useState } from "@odoo/owl";
2+
import { Counter } from "./counter/counter";
3+
import { Card } from "./card/card";
4+
25

36
export class Playground extends Component {
47
static template = "awesome_owl.playground";
8+
static components = { Counter, Card };
9+
setup(){
10+
11+
}
512
}
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<templates xml:space="preserve">
3-
43
<t t-name="awesome_owl.playground">
5-
<div class="p-3">
6-
hello world
4+
Hello My Friend
5+
<div>
6+
<Counter />
7+
<Counter />
78
</div>
8-
</t>
9-
9+
<div>
10+
<Card title="'Task 1'" content="'prepare things'"/>
11+
<Card title="'Task 2'" content="'do stuff'"/>
12+
</div>
13+
</t>
1014
</templates>

0 commit comments

Comments
 (0)