Skip to content

Commit 459b6a5

Browse files
committed
[IMP] awesome_owl: add props validation in card component
1 parent 19a8882 commit 459b6a5

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

awesome_owl/static/src/card.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Component, useState } from "@odoo/owl"
2+
3+
export class Card extends Component {
4+
static template = "awesome_owl.card";
5+
static props = {
6+
title: String,
7+
content: String,
8+
}
9+
}

awesome_owl/static/src/card.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
4+
<t t-name="awesome_owl.card">
5+
<div class="card d-inline-block m-2" style="width: 18rem;">
6+
<div class="card-body">
7+
<h5 class="card-title">
8+
<t t-esc="props.title"/>
9+
</h5>
10+
<p class="card-text">
11+
<t t-out="props.content"/>
12+
</p>
13+
</div>
14+
</div>
15+
</t>
16+
17+
</templates>

awesome_owl/static/src/playground.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
/** @odoo-module **/
22

3-
import { Component, useState } from "@odoo/owl";
3+
import { Component, markup } from "@odoo/owl";
44
import { Counter } from "./counter";
5+
import { Card } from "./card";
56

67
export class Playground extends Component {
78
static template = "awesome_owl.playground";
8-
static components = { Counter };
9+
static components = { Counter, Card };
10+
11+
card1Content = markup("<div>Some Text in div Tag</div>");
12+
card2Content = "<div>Some Text in div Tag</div>";
913
}

awesome_owl/static/src/playground.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<t t-name="awesome_owl.playground">
55
<Counter></Counter>
66
<Counter></Counter>
7+
<Card title="'my title'" content="card1Content"/>
8+
<Card title="'my title'" content="card2Content"/>
79
</t>
810

911
</templates>

0 commit comments

Comments
 (0)