diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js new file mode 100644 index 00000000000..0a356c3b46c --- /dev/null +++ b/awesome_owl/static/src/card/card.js @@ -0,0 +1,14 @@ +import { Component } from "@odoo/owl"; + +export class Card extends Component { + static template = "awesome_owl.card"; + + static props = { + title: { + type: String, + }, + content: { + type: String, + } + } +} diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml new file mode 100644 index 00000000000..4eb2359d045 --- /dev/null +++ b/awesome_owl/static/src/card/card.xml @@ -0,0 +1,17 @@ + + + + +
+
+
+ +
+

+ +

+
+
+
+ +
diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js new file mode 100644 index 00000000000..3d0c528e96c --- /dev/null +++ b/awesome_owl/static/src/counter/counter.js @@ -0,0 +1,23 @@ +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(); + } + } +} diff --git a/awesome_owl/static/src/counter/counter.xml b/awesome_owl/static/src/counter/counter.xml new file mode 100644 index 00000000000..5e0ec2135c0 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.xml @@ -0,0 +1,9 @@ + + + + +

Counter:

+ +
+ +
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 4ac769b0aa5..0a7ea38f78f 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,5 +1,18 @@ -import { Component } from "@odoo/owl"; +import { Component, useState } 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.state = useState({value: 0}); + } + + incrementSum() { + this.state.value++; + } } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4fb905d59f9..d371115e428 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -2,9 +2,13 @@ -
- hello world -
+

My Counter

+ + + + +

Sum:

+
diff --git a/awesome_owl/static/src/todo/item/todo_item.js b/awesome_owl/static/src/todo/item/todo_item.js new file mode 100644 index 00000000000..8ef0284175b --- /dev/null +++ b/awesome_owl/static/src/todo/item/todo_item.js @@ -0,0 +1,19 @@ +import { Component } from "@odoo/owl"; +import {Card} from "../../card/card"; + +export class TodoItem extends Component { + static template = "awesome_owl.todo_item"; + + static Components = [ Card ] + + static props = { + todo: { + type: Object, + shape: { + id: Number, + description: String, + isCompleted: Boolean, + } + } + } +} diff --git a/awesome_owl/static/src/todo/item/todo_item.xml b/awesome_owl/static/src/todo/item/todo_item.xml new file mode 100644 index 00000000000..7cbc7cea19c --- /dev/null +++ b/awesome_owl/static/src/todo/item/todo_item.xml @@ -0,0 +1,11 @@ + + + + +
+ + +
+
+ +
diff --git a/awesome_owl/static/src/todo/list/todo_list.js b/awesome_owl/static/src/todo/list/todo_list.js new file mode 100644 index 00000000000..1355fc2a8e8 --- /dev/null +++ b/awesome_owl/static/src/todo/list/todo_list.js @@ -0,0 +1,22 @@ +import {Component, useState} from "@odoo/owl"; +import {TodoItem} from "../item/todo_item"; + +export class TodoList extends Component { + static template = "awesome_owl.todo_list"; + + static components = {TodoItem}; + + static props = { + items: { + type: Array, + optional: true, + } + } + + setup() { + this.props.items = useState([ + { id: 1, description: "buy Beer", isCompleted: true }, + { id: 2, description: "buy Chicken", isCompleted: false }, + ]) + } +} diff --git a/awesome_owl/static/src/todo/list/todo_list.xml b/awesome_owl/static/src/todo/list/todo_list.xml new file mode 100644 index 00000000000..ec7822f0a99 --- /dev/null +++ b/awesome_owl/static/src/todo/list/todo_list.xml @@ -0,0 +1,11 @@ + + + + + + +
+
+
+ +