Skip to content

Commit 7309073

Browse files
to add our first basic component
1 parent 19a5d95 commit 7309073

File tree

15 files changed

+72
-20
lines changed

15 files changed

+72
-20
lines changed

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@
6262
]
6363
],
6464
"plugins": [
65-
["@babel/plugin-proposal-decorators", { "legacy": true }],
65+
[
66+
"@babel/plugin-proposal-decorators",
67+
{
68+
"legacy": true
69+
}
70+
],
6671
"@babel/plugin-proposal-class-properties"
6772
],
6873
"env": {

src/components/page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const route = (path: string) => {
77
registry.category('pages').add(path, target);
88
}
99
}
10-
export const themplate = (name: string) => {
10+
export const template = (name: string) => {
1111
return (target: any) => {
1212
target.template = name;
1313
}
File renamed without changes.

src/core/buttons/button.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
3+
@see https://getbootstrap.com/docs/5.0/components/buttons/
4+
*/
5+
import { Component } from "@odoo/owl";
6+
import { template } from "../components";
7+
8+
9+
@template('component.button')
10+
export class Button extends Component {
11+
static props = ['color', 'href'];
12+
13+
}

src/core/buttons/button.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates xml:space="preserve">
3+
<t t-name="component.button" owl="1">
4+
<a t-att-class="{
5+
'btn': true,
6+
'btn-success': props.color === 'success',
7+
'btn-primary': props.color === 'primary',
8+
'btn-secondary': props.color === 'secondary',
9+
}"
10+
t-att-href="props.href">
11+
<t t-slot="default"/>
12+
</a>
13+
</t>
14+
</templates>

src/core/buttons/buttons.ts

Whitespace-only changes.

src/core/buttons/buttons.xml

Whitespace-only changes.

src/core/buttons/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Button } from "./button";
2+
3+
import "./button.xml";
4+
import "./button.scss"
5+
6+
export {
7+
Button
8+
};

src/core/components.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
4+
/**
5+
* A decorator to add template into a component
6+
*/
7+
export const template = (name: string) => {
8+
return (component: any) => {
9+
component.template = name;
10+
}
11+
}

src/pages/csc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CSC Network
44
55
*/
66
import { useState } from "@odoo/owl";
7-
import { OPage, enableStaking, logo, route, symbol, themplate, title } from "../components/page";
7+
import { OPage, enableStaking, logo, route, symbol, template, title } from "../components/page";
88
import { switchChain, useContract, useWallet } from "../core/wallet";
99

1010
import cetABI from "../data/csc-validators.json";
@@ -22,7 +22,7 @@ const mainnetChainId = "0x34";
2222
@route('/staking/CSC')
2323
@title('Coinex Smart Coin')
2424
@logo('./img/csc.svg')
25-
@themplate('pages.csc')
25+
@template('pages.csc')
2626
@symbol('CET')
2727
@enableStaking()
2828
export class CscStakingPage extends OPage {

0 commit comments

Comments
 (0)