Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions awesome_owl/static/src/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from "@odoo/owl";

export class Card extends Component {
static template = "awesome_owl.Card";

static props = {
title: { type: String },
content: { type: [String, Object] }
};
}
15 changes: 15 additions & 0 deletions awesome_owl/static/src/card/card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_owl.Card">
<div class="card d-inline-block m-2" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">
<t t-esc="props.title"/>
</h5>
<p class="card-text">
<t t-out="props.content"/>
</p>
</div>
</div>
</t>
</templates>
21 changes: 21 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component, useState } from "@odoo/owl";

export class Counter extends Component {
static template = "awesome_owl.Counter";

static props = {
onChange: { type: Function, optional: true }
};

setup() {
this.state = useState({ value: 0 });
}

increment() {
this.state.value++;

if (this.props.onChange) {
this.props.onChange();
}
}
}
9 changes: 9 additions & 0 deletions awesome_owl/static/src/counter/counter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_owl.Counter">
<div class="counter d-flex align-items-center gap-1 mb-3" style="border: 2px solid #333333; padding: 10px;">
<p class="mb-0">Counter: <t t-esc="state.value"/></p>
<button class="btn btn-primary" t-on-click="increment">Increment</button>
</div>
</t>
</templates>
16 changes: 15 additions & 1 deletion awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { Component } from "@odoo/owl";
import { Component, useState, markup } from "@odoo/owl";
import { Counter } from "./counter/counter";
import { Card } from "./card/card";
import { TodoList } from "./todo_list/todo_list";

export class Playground extends Component {
static template = "awesome_owl.playground";
static components = { Counter, Card, TodoList };

setup() {
this.normalString = "<div class='text-primary'>some content</div>";
this.markupString = markup("<div class='text-primary'>some content</div>");
this.state = useState({ sum: 2 });
}

incrementSum() {
this.state.sum++;
}
}
20 changes: 16 additions & 4 deletions awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
<div class="playground">

<TodoList/>

<hr/>

<div class="d-flex gap-3">
<Counter onChange="() => this.incrementSum()"/>
<Counter onChange="() => this.incrementSum()"/>
</div>
<div class="mb-4">
<h3>The sum is: <t t-esc="state.sum"/></h3>
</div>

<Card title="'card 1'" content="normalString"/>
<Card title="'card 2'" content="markupString"/>
</div>
</t>

</templates>
16 changes: 16 additions & 0 deletions awesome_owl/static/src/todo_list/todo_item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from "@odoo/owl";

export class TodoItem extends Component {
static template = "awesome_owl.TodoItem";

static props = {
todo: {
type: Object,
shape: {
id: Number,
description: String,
isCompleted: Boolean,
},
},
};
}
9 changes: 9 additions & 0 deletions awesome_owl/static/src/todo_list/todo_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_owl.TodoItem">
<div class="todo-item border border-1 border-secondary rounded p-2 mb-2 d-flex align-items-center gap-2">
<strong>#<t t-esc="props.todo.id"/></strong>
<span><t t-esc="props.todo.description"/></span>
</div>
</t>
</templates>
14 changes: 14 additions & 0 deletions awesome_owl/static/src/todo_list/todo_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component, useState } from "@odoo/owl";
import { TodoItem } from "./todo_item";

export class TodoList extends Component {
static template = "awesome_owl.TodoList";
static components = { TodoItem };

setup() {
this.todos = useState([
{ id: 3, description: "Eat", isCompleted: false },
{ id: 4, description: "Sleep", isCompleted: true },
]);
}
}
11 changes: 11 additions & 0 deletions awesome_owl/static/src/todo_list/todo_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<templates xml:space="preserve">
<t t-name="awesome_owl.TodoList">
<div class="todo-list mb-4">
<h3>My Todo List</h3>

<t t-foreach="todos" t-as="todo" t-key="todo.id">
<TodoItem todo="todo"/>
</t>
</div>
</t>
</templates>