-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathTitle.js
132 lines (114 loc) · 2.73 KB
/
Title.js
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import TitleLevel from "./types/TitleLevel.js";
import WrappingType from "./types/WrappingType.js";
// Template
import TitleTemplate from "./generated/templates/TitleTemplate.lit.js";
// Styles
import titleCss from "./generated/themes/Title.css.js";
/**
* @public
*/
const metadata = {
tag: "ui5-title",
properties: /** @lends sap.ui.webcomponents.main.Title.prototype */ {
/**
* Defines how the text of a component will be displayed when there is not enough space.
* Available options are:
* <ul>
* <li><code>None</code> - The text will be truncated with an ellipsis.</li>
* <li><code>Normal</code> - The text will wrap. The words will not be broken based on hyphenation.</li>
* </ul>
*
* @type {WrappingType}
* @defaultvalue "None"
* @public
*/
wrappingType: {
type: WrappingType,
defaultValue: WrappingType.None,
},
/**
* Defines the component level.
* Available options are: <code>"H6"</code> to <code>"H1"</code>.
*
* @type {TitleLevel}
* @defaultvalue "H2"
* @public
*/
level: {
type: TitleLevel,
defaultValue: TitleLevel.H2,
},
},
slots: /** @lends sap.ui.webcomponents.main.Title.prototype */ {
/**
* Defines the text of the component.
* <br><br>
* <b>Note:</b> Although this slot accepts HTML Elements, it is strongly recommended that you only use text in order to preserve the intended design.
*
* @type {Node[]}
* @slot
* @public
*/
"default": {
type: Node,
},
},
};
/**
* @class
*
* <h3 class="comment-api-title">Overview</h3>
*
* The <code>ui5-title</code> component is used to display titles inside a page.
* It is a simple, large-sized text with explicit header/title semantics.
*
* <h3>ES6 Module Import</h3>
*
* <code>import "@ui5/webcomponents/dist/Title";</code>
*
* @constructor
* @author SAP SE
* @alias sap.ui.webcomponents.main.Title
* @extends sap.ui.webcomponents.base.UI5Element
* @tagname ui5-title
* @public
*/
class Title extends UI5Element {
static get metadata() {
return metadata;
}
static get render() {
return litRender;
}
static get template() {
return TitleTemplate;
}
static get styles() {
return titleCss;
}
get normalizedLevel() {
return this.level.toLowerCase();
}
get h1() {
return this.normalizedLevel === "h1";
}
get h2() {
return this.normalizedLevel === "h2";
}
get h3() {
return this.normalizedLevel === "h3";
}
get h4() {
return this.normalizedLevel === "h4";
}
get h5() {
return this.normalizedLevel === "h5";
}
get h6() {
return this.normalizedLevel === "h6";
}
}
Title.define();
export default Title;