forked from khoanguyen123/aurelia-ui-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui-page.ts
114 lines (95 loc) · 2.84 KB
/
ui-page.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
* UI Core Page
* @author Adarsh Pastakia
* @company HMC
* @copyright 2015-2016, Adarsh Pastakia
* @description Router view
**/
import {customElement, bindable, inlineView} from "aurelia-framework";
import {Router} from "aurelia-router";
import {UIUtils} from "../utils/ui-utils";
@customElement('ui-page')
export class UIPage {
private __body;
/**
* @property page-title
* @type string
*/
@bindable()
pageTitle: string;
constructor(public element: Element) {
}
toast(config) {
if (typeof config === 'string') config = { message: config };
config.extraClass = 'ui-page-toast';
UIUtils.showToast(this.__body, config);
}
}
@customElement('ui-section')
@inlineView('<template class="ui-section"><content></content></template>')
export class UISection {
constructor(public element: Element) {
}
bind() {
if (this.element.hasAttribute('column')) {
this.element.classList.add('ui-section-column');
}
else {
this.element.classList.add('ui-section-row');
}
}
}
@customElement('ui-content')
@inlineView('<template class="ui-content"><content></content></template>')
export class UIContent {
constructor(public element: Element) {
}
bind() {
if (this.element.hasAttribute('auto')) {
this.element.classList.add('ui-auto-fit');
}
else if (this.element.hasAttribute('scroll')) {
this.element.classList.add('ui-scroll');
}
if (this.element.hasAttribute('padded')) this.element.classList.add('ui-pad-all');
}
}
@customElement('ui-sidebar')
@inlineView(`<template class="ui-sidebar" role="sidebar" css.bind="{'flex-basis':width}"><content></content></template>`)
export class UISidebar {
private collapsible: boolean = false;
/**
* @property width
* @type string
*/
@bindable()
width: string = '220px';
constructor(public element: Element) {
}
bind() {
// TODO: Add collapse functionality
this.collapsible = this.element.hasAttribute('collapsible');
if (this.element.hasAttribute('scroll')) this.element.classList.add('ui-scroll');
if (this.element.hasAttribute('padded')) this.element.classList.add('ui-pad-all');
}
}
@customElement('ui-divider')
@inlineView('<template class="ui-divider" role="separator"></template>')
export class UIDivider {
}
@customElement('ui-toolbar')
@inlineView(`<template class="ui-toolbar ui-button-bar" role="toolbar"><content></content></template>`)
export class UIToolbar {
}
@customElement('ui-statsbar')
@inlineView(`<template class="ui-statsbar"><content></content></template>`)
export class UIStatsbar {
}
@customElement('ui-stat')
@inlineView('<template class="ui-stat"><span class="${icon}" if.bind="icon"></span><div><h1>${value}</h1><h6><content></content></h6></div></template>')
export class UIStat {
@bindable()
value;
@bindable()
icon;
}