Skip to content

Commit 744de96

Browse files
author
Vladimir Enchev
committed
Class atribute registered and used instead cssClass
1 parent 601dffc commit 744de96

File tree

19 files changed

+63
-58
lines changed

19 files changed

+63
-58
lines changed

apps/action-bar-demo/main-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<Page>
33
<Page.actionBar>
4-
<ActionBar title="Title" cssClass="custom-action-bar">
4+
<ActionBar title="Title" class="custom-action-bar">
55
<ActionBar.actionItems>
66
<ActionItem text="hi" />
77
</ActionBar.actionItems>

apps/cuteness.io/details-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ScrollView>
44
<StackLayout>
55
<Image imageSource="{{ imageSource }}" stretch="aspectFill"/>
6-
<Label text="{{ title }}" cssClass="detailsTitle" textWrap="true" />
6+
<Label text="{{ title }}" class="detailsTitle" textWrap="true" />
77
</StackLayout>
88
</ScrollView>
99
<StackLayout orientation="horizontal" row="1">

apps/cuteness.io/main-page.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<ListView.itemTemplate>
88
<!-- Binding in template property of an component will use the bindingContext provided by the component. -->
99
<GridLayout columns="auto, *, auto" rows="auto, 25">
10-
<Image src="{{ thumbnailImage }}" cssClass="thumbnail" rowSpan="2"/>
11-
<Label text="{{ title || 'Downloading...' }}" textWrap="true" cssClass="title" col="1" colSpan="2" minHeight="50" />
12-
<Label text="{{ author ? 'by ' + author : '' }}" cssClass="author" col="1" row="1" />
13-
<Label text="{{ num_comments ? num_comments + ' comments' : '' }}" cssClass="comments" col="2" row="1" />
10+
<Image src="{{ thumbnailImage }}" class="thumbnail" rowSpan="2"/>
11+
<Label text="{{ title || 'Downloading...' }}" textWrap="true" class="title" col="1" colSpan="2" minHeight="50" />
12+
<Label text="{{ author ? 'by ' + author : '' }}" class="author" col="1" row="1" />
13+
<Label text="{{ num_comments ? num_comments + ' comments' : '' }}" class="comments" col="2" row="1" />
1414
</GridLayout>
1515
<!-- End of tempplate. -->
1616
</ListView.itemTemplate>

apps/cuteness.unoptimized/details-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ScrollView>
44
<StackLayout>
55
<Image imageSource="{{ imageSource }}" stretch="aspectFill"/>
6-
<Label text="{{ title }}" cssClass="detailsTitle" textWrap="true" />
6+
<Label text="{{ title }}" class="detailsTitle" textWrap="true" />
77
</StackLayout>
88
</ScrollView>
99
<StackLayout orientation="horizontal" row="1">

apps/cuteness.unoptimized/main-page.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<ListView.itemTemplate>
88
<!-- Binding in template property of an component will use the bindingContext provided by the component. -->
99
<GridLayout columns="auto, *, auto" rows="auto, 25">
10-
<Image src="{{ thumbnailImage }}" cssClass="thumbnail" rowSpan="2"/>
11-
<Label text="{{ title || 'Downloading...' }}" textWrap="true" cssClass="title" col="1" colSpan="2" minHeight="50" />
12-
<Label text="{{ author ? 'by ' + author : '' }}" cssClass="author" col="1" row="1" />
13-
<Label text="{{ num_comments ? num_comments + ' comments' : '' }}" cssClass="comments" col="2" row="1" />
10+
<Image src="{{ thumbnailImage }}" class="thumbnail" rowSpan="2"/>
11+
<Label text="{{ title || 'Downloading...' }}" textWrap="true" class="title" col="1" colSpan="2" minHeight="50" />
12+
<Label text="{{ author ? 'by ' + author : '' }}" class="author" col="1" row="1" />
13+
<Label text="{{ num_comments ? num_comments + ' comments' : '' }}" class="comments" col="2" row="1" />
1414
</GridLayout>
1515
<!-- End of tempplate. -->
1616
</ListView.itemTemplate>

apps/gallery-app/main-page.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Page>
33
<ScrollView>
44
<StackLayout>
5-
<Label cssClass="title" text="Layouts" />
5+
<Label class="title" text="Layouts" />
66
<StackLayout>
77
<Button tag="layouts/stack-layout" text="StackLayout" tap="itemTap" />
88
<Button tag="layouts/grid-layout" text="GridLayout" tap="itemTap" />
@@ -11,7 +11,7 @@
1111
<Button tag="layouts/absolute-layout" text="AbsoluteLayout" tap="itemTap" />
1212
</StackLayout>
1313

14-
<Label cssClass="title" text="Content" />
14+
<Label class="title" text="Content" />
1515
<StackLayout>
1616
<Button tag="content/tab-view" text="TabView" tap="itemTap" />
1717
<Button tag="content/web-view" text="WebView" tap="itemTap" />
@@ -20,7 +20,7 @@
2020
<Button tag="content/border" text="Border" tap="itemTap" />
2121
</StackLayout>
2222

23-
<Label cssClass="title" text="Views" />
23+
<Label class="title" text="Views" />
2424
<StackLayout>
2525
<Button tag="views/button" text="Button" tap="itemTap" />
2626
<Button tag="views/label" text="Label" tap="itemTap" />

apps/paylocity/login.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<StackLayout>
33
<StackLayout verticalAlignment="center" horizontalAlignment="center" margin="50">
44
<Image loaded="imageLoaded" />
5-
<TextField cssClass="nameField" text="Captain" margin="10" />
6-
<TextField cssClass="familyNameField" text="America" margin="10" />
7-
<TextField cssClass="passwordField" secure="true" hint="Password (leave empty)" margin="10" />
8-
<Button cssClass="loginButton" text="Login" margin="10" tap="loginButtonTap" />
5+
<TextField class="nameField" text="Captain" margin="10" />
6+
<TextField class="familyNameField" text="America" margin="10" />
7+
<TextField class="passwordField" secure="true" hint="Password (leave empty)" margin="10" />
8+
<Button class="loginButton" text="Login" margin="10" tap="loginButtonTap" />
99
</StackLayout>
1010
</StackLayout>
1111
</Page>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
22
<StackLayout>
3-
<Label text="Tap the button" cssClass="title"/>
3+
<Label text="Tap the button" class="title"/>
44
<Button text="TAP" tap="{{ tapAction }}" />
5-
<Label text="{{ message }}" cssClass="message" textWrap="true"/>
5+
<Label text="{{ message }}" class="message" textWrap="true"/>
66
</StackLayout>
77
</Page>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<StackLayout xmlns="http://www.nativescript.org/tns.xsd">
2-
<Label text="{{ title }}" cssClass="detail-title"/>
3-
<Label text="{{ info }}" cssClass="info" textWrap="true"/>
2+
<Label text="{{ title }}" class="detail-title"/>
3+
<Label text="{{ info }}" class="info" textWrap="true"/>
44
</StackLayout>

apps/template-master-detail/main-page.minWH600.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
xmlns:app="."
33
loaded="pageLoaded">
44
<GridLayout rows="auto, *" columns="300, *">
5-
<Label text="Master Details Page" cssClass="title" colSpan="2" />
5+
<Label text="Master Details Page" class="title" colSpan="2" />
66

77
<ListView items="{{ items }}" itemTap="listViewItemTap" row="1">
88
<ListView.itemTemplate>
9-
<Label text="{{ title }}" cssClass="listItem" />
9+
<Label text="{{ title }}" class="listItem" />
1010
</ListView.itemTemplate>
1111
</ListView>
1212

apps/template-master-detail/main-page.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<Page xmlns="http://www.nativescript.org/tns.xsd"
22
loaded="pageLoaded">
33
<GridLayout rows="auto, *">
4-
<Label text="Items Page" cssClass="title" />
4+
<Label text="Items Page" class="title" />
55

66
<ListView items="{{ items }}" itemTap="listViewItemTap" row="1">
77
<ListView.itemTemplate>
8-
<Label text="{{ title }}" cssClass="listItem" />
8+
<Label text="{{ title }}" class="listItem" />
99
</ListView.itemTemplate>
1010
</ListView>
1111
</GridLayout>

apps/template-settings/main-page.xml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
2-
<StackLayout cssClass="content">
2+
<StackLayout class="content">
33
<!-- Profile sttings -->
4-
<Label cssClass="header" text="Profile"/>
5-
<GridLayout cssClass="field-group" columns="auto, 50, *" rows="auto, auto, auto">
4+
<Label class="header" text="Profile"/>
5+
<GridLayout class="field-group" columns="auto, 50, *" rows="auto, auto, auto">
66

77
<!-- Name -->
8-
<Label cssClass="field" text="Name"/>
9-
<Button cssClass="field-dialog-button" text="{{ name }}" tap="{{ promptName }}" col="1" colSpan="2"/>
8+
<Label class="field" text="Name"/>
9+
<Button class="field-dialog-button" text="{{ name }}" tap="{{ promptName }}" col="1" colSpan="2"/>
1010

1111
<!-- Height -->
12-
<Label cssClass="field" text="Height" row="1"/>
13-
<TextField cssClass="field-value" text="{{ height }}" keyboardType="number" row="1" col="1"/>
14-
<Label cssClass="field-unit" text="cm" col="2" row="1"/>
12+
<Label class="field" text="Height" row="1"/>
13+
<TextField class="field-value" text="{{ height }}" keyboardType="number" row="1" col="1"/>
14+
<Label class="field-unit" text="cm" col="2" row="1"/>
1515

1616
<!-- Weight -->
17-
<Label cssClass="field" text="Weight" row="2"/>
18-
<TextField cssClass="field-value" text="{{ weight }}" keyboardType="number" row="2" col="1"/>
19-
<Label cssClass="field-unit" text="kg" row="2" col="2"/>
17+
<Label class="field" text="Weight" row="2"/>
18+
<TextField class="field-value" text="{{ weight }}" keyboardType="number" row="2" col="1"/>
19+
<Label class="field-unit" text="kg" row="2" col="2"/>
2020
</GridLayout>
2121

2222
<!-- Notifications settings -->
23-
<Label cssClass="header" text="Notifications"/>
24-
<GridLayout cssClass="field-group" columns="*, auto" rows="auto, auto, auto">
23+
<Label class="header" text="Notifications"/>
24+
<GridLayout class="field-group" columns="*, auto" rows="auto, auto, auto">
2525
<!-- Notifications -->
26-
<Label cssClass="field" text="Vibrate"/>
27-
<Switch cssClass="field-value" checked="{{ vibrateEnabled }}" col="1"/>
26+
<Label class="field" text="Vibrate"/>
27+
<Switch class="field-value" checked="{{ vibrateEnabled }}" col="1"/>
2828

2929
<!-- Notifications -->
30-
<Label cssClass="field" text="Sound" row="1"/>
31-
<Switch cssClass="field-value" checked="{{ soundEnabled }}" row="1" col="1"/>
30+
<Label class="field" text="Sound" row="1"/>
31+
<Switch class="field-value" checked="{{ soundEnabled }}" row="1" col="1"/>
3232
<Slider maxValue="100" value="{{ soundVolume }}" isEnabled="{{ soundEnabled }}" row="2" colSpan="2"/>
3333
</GridLayout>
3434
</StackLayout>

apps/template-tab-navigation/main-page.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
<TabView.items>
44
<TabViewItem title="First">
55
<TabViewItem.view>
6-
<StackLayout cssClass="tab-content">
7-
<Label text="First View" cssClass="title"/>
6+
<StackLayout class="tab-content">
7+
<Label text="First View" class="title"/>
88
<Label text="This is the content of the first tab." textWrap="true"/>
99
</StackLayout>
1010
</TabViewItem.view>
1111
</TabViewItem>
1212
<TabViewItem title="Second">
1313
<TabViewItem.view>
14-
<StackLayout cssClass="tab-content">
15-
<Label text="Second View" cssClass="title"/>
14+
<StackLayout class="tab-content">
15+
<Label text="Second View" class="title"/>
1616
<Label text="This is the content of the second tab." textWrap="true"/>
1717
</StackLayout>
1818
</TabViewItem.view>

apps/tests/ui/list-view/list-view-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import labelModule = require("ui/label");
5757
// <Page>
5858
// {%raw%}<ListView items="{{ myItems }}">
5959
// <ListView.itemTemplate>
60-
// <Label text="{{ title || 'Downloading...' }}" textWrap="true" cssClass="title" />
60+
// <Label text="{{ title || 'Downloading...' }}" textWrap="true" class="title" />
6161
// </ListView.itemTemplate>
6262
// </ListView>{%endraw%}
6363
// </Page>

apps/tests/ui/repeater/repeater-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import labelModule = require("ui/label");
3232
// <Page>
3333
// {%raw%}<Repeater items="{{ myItems }}">
3434
// <Repeater.itemTemplate>
35-
// <Label text="{{ title || 'Downloading...' }}" textWrap="true" cssClass="title" />
35+
// <Label text="{{ title || 'Downloading...' }}" textWrap="true" class="title" />
3636
// </Repeater.itemTemplate>
3737
// </Repeater>{%endraw%}
3838
// </Page>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<StackLayout xmlns:customControls="xml-declaration/mymodule" cssClass="MySecondCustomStackLayout">
1+
<StackLayout xmlns:customControls="xml-declaration/mymodule" class="MySecondCustomStackLayout">
22
<Label id="Label1" text="mymodulewithxml" />
33
<Button text="Click!" tap="buttonTap2" />
44
</StackLayout>

apps/tests/xml-declaration/xml-declaration-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export function test_parse_ShouldResolveExportsFromCodeFileForTemplates() {
201201
export function test_parse_ShouldApplyCssFromCssFile() {
202202
var newPage: Page;
203203
var pageFactory = function (): Page {
204-
newPage = <Page>builder.parse("<Page cssFile='~/xml-declaration/custom-css-file.css'><Label cssClass='MyClass' /></Page>");
204+
newPage = <Page>builder.parse("<Page cssFile='~/xml-declaration/custom-css-file.css'><Label class='MyClass' /></Page>");
205205
return newPage;
206206
};
207207

@@ -218,7 +218,7 @@ export function test_parse_ShouldApplyCssFromCssFile() {
218218
export function test_parse_ShouldResolveExportsFromCodeFileAndApplyCssFile() {
219219
var newPage: Page;
220220
var pageFactory = function (): Page {
221-
newPage = <Page>builder.parse("<Page codeFile='~/xml-declaration/custom-code-file' cssFile='~/xml-declaration/custom-css-file.css' loaded='loaded'><Label cssClass='MyClass' /></Page>");
221+
newPage = <Page>builder.parse("<Page codeFile='~/xml-declaration/custom-code-file' cssFile='~/xml-declaration/custom-css-file.css' loaded='loaded'><Label class='MyClass' /></Page>");
222222
return newPage;
223223
};
224224

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Page>
22
<GridLayout rows="*,*,*" columns="*,*">
3-
<Image row="0" col="0" src="~/image-view/gravatar.png" cssClass="one"/>
4-
<Image row="0" col="1" src="~/image-view/gravatar.png" cssClass="two"/>
5-
<Image row="1" col="0" src="~/image-view/gravatar.png" cssClass="three"/>
6-
<Image row="1" col="1" src="~/image-view/gravatar.png" cssClass="four"/>
7-
<Image row="2" col="0" src="~/image-view/gravatar.png" cssClass="five"/>
8-
<Image row="2" col="1" src="~/image-view/gravatar.png" cssClass="six"/>
3+
<Image row="0" col="0" src="~/image-view/gravatar.png" class="one"/>
4+
<Image row="0" col="1" src="~/image-view/gravatar.png" class="two"/>
5+
<Image row="1" col="0" src="~/image-view/gravatar.png" class="three"/>
6+
<Image row="1" col="1" src="~/image-view/gravatar.png" class="four"/>
7+
<Image row="2" col="0" src="~/image-view/gravatar.png" class="five"/>
8+
<Image row="2" col="1" src="~/image-view/gravatar.png" class="six"/>
99
</GridLayout>
1010
</Page>

ui/core/view-common.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ import utils = require("utils/utils");
1414
import color = require("color");
1515
import animationModule = require("ui/animation");
1616
import observable = require("data/observable");
17+
import {registerSpecialProperty} from "ui/builder/special-properties";
18+
19+
registerSpecialProperty("class", (instance: definition.View, propertyValue: string) => {
20+
instance.cssClass = propertyValue;
21+
});
1722

1823
export function isEventOrGesture(name: string, view: View): boolean {
1924
if (types.isString(name)) {

0 commit comments

Comments
 (0)