const CLICK_COUNTER = `class ClickCounter extends owl.Component {
constructor() {
super(...arguments);
this.state = { value: 0 };
}
increment() {
this.state.value++;
}
}
const qweb = new owl.QWeb(TEMPLATES);
const counter = new ClickCounter({ qweb });
counter.mount(document.body);
`;
const CLICK_COUNTER_XML = ``;
const CLICK_COUNTER_CSS = `button {
color: darkred;
font-size: 30px;
width: 220px;
}`;
const CLICK_COUNTER_ESNEXT = `// This example will not work if your browser does not support ESNext class fields
class ClickCounter extends owl.Component {
state = { value: 0 };
increment() {
this.state.value++;
}
}
const qweb = new owl.QWeb(TEMPLATES);
const counter = new ClickCounter({ qweb });
counter.mount(document.body);
`;
const WIDGET_COMPOSITION = `// This example will not work if your browser does not support ESNext class fields
class ClickCounter extends owl.Component {
state = { value: 0 };
increment() {
this.state.value++;
}
}
class InputWidget extends owl.Component {
state = {text: ""};
updateVal(event) {
let value = event.target.value;
if (this.props.reverse) {
value = value.split("").reverse().join("");
}
this.state.text = value
}
}
// Main root widget
class App extends owl.Component {
widgets = {ClickCounter, InputWidget};
}
// Application setup
const qweb = new owl.QWeb(TEMPLATES);
const app = new App({ qweb });
app.mount(document.body);
`;
const WIDGET_COMPOSITION_XML = `
`;
const WIDGET_COMPOSITION_CSS = `button, input {
font-size: 20px;
width: 220px;
margin: 5px;
}`;
const ANIMATION = `// This example will not work if your browser does not support ESNext class fields
class ClickCounter extends owl.Component {
state = { value: 0 };
increment() {
this.state.value++;
}
}
class App extends owl.Component {
state = {flag: false, widgetFlag: false, numbers: []};
widgets = {ClickCounter};
toggle() {
this.state.flag = !this.state.flag;
}
toggleWidget() {
this.state.widgetFlag = !this.state.widgetFlag;
}
addNumber() {
const n = this.state.numbers.length + 1;
this.state.numbers.push(n);
}
}
const qweb = new owl.QWeb(TEMPLATES);
const app = new App({qweb});
app.mount(document.body);
`;
const ANIMATION_XML = `
Transition on DOM element
Hello
Transition on sub widgets
Transition on lists
Transitions can also be applied on lists
Simple CSS animation
Remember, normal CSS still apply: for example, a simple flash animation with pure css