Skip to content

Commit 10afbe1

Browse files
authored
Merge pull request #265 from NativeScript/fatme/theme-v2
feat: support for @nativescript/theme v2
2 parents ac081b6 + 46f7422 commit 10afbe1

File tree

11 files changed

+15
-53
lines changed

11 files changed

+15
-53
lines changed
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
/*
2-
In NativeScript, the app.css file is where you place CSS rules that
3-
you would like to apply to your entire application. Check out
4-
http://docs.nativescript.org/ui/styling for a full list of the CSS
5-
selectors and properties you can use to style UI components.
1+
@import "~@nativescript/theme/css/core.css";
2+
@import "~@nativescript/theme/css/blue.css";
63

7-
/*
8-
In many cases you may want to use the NativeScript core theme instead
9-
of writing your own CSS rules. For a full list of class names in the theme
10-
refer to http://docs.nativescript.org/ui/theme.
11-
*/
12-
@import '~nativescript-theme-core/css/core.light.css';
4+
/* Place any CSS rules you want to apply on both iOS and Android here.
5+
This is where the vast majority of your CSS code goes. */

src/add-ns/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ const addDependencies = () => (tree: Tree, context: SchematicContext) => {
363363
// @UPGRADE: Update all versions whenever {N} version updates
364364
const depsToAdd = {
365365
'nativescript-angular': '~8.20.0',
366-
'nativescript-theme-core': '~1.0.4',
366+
'@nativescript/theme': '~2.2.0',
367367
'reflect-metadata': '~0.1.12',
368368
'tns-core-modules': '~6.2.0',
369369
'tslib': '1.10.0',

src/add-ns/index_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('Add {N} schematic', () => {
7878
const { dependencies, devDependencies } = packageJson;
7979
expect(dependencies).toBeDefined();
8080
expect(dependencies['nativescript-angular']).toBeDefined();
81-
expect(dependencies['nativescript-theme-core']).toBeDefined();
81+
expect(dependencies['@nativescript/theme']).toBeDefined();
8282
expect(dependencies['tns-core-modules']).toBeDefined();
8383
expect(dependencies['reflect-metadata']).toBeDefined();
8484

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--The content below is only a placeholder and can be replaced.-->
22
<StackLayout<% if (theme) { %> class="p-20"<% } %>>
33
<Label text="Tap the button"<% if (theme) { %> class="h1 text-center"<% } %>></Label>
4-
<Button text="TAP" (tap)="onTap()"<% if (theme) { %> class="btn btn-primary btn-active"<% } %>></Button>
4+
<Button text="TAP" (tap)="onTap()"<% if (theme) { %> class="-primary"<% } %>></Button>
55
<Label [text]="getMessage()"<% if (theme) { %> class="h2 text-center"<% } %> textWrap="true"></Label>
66
</StackLayout>

src/ng-new/application/_files/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@angular/platform-browser-dynamic": "~8.2.0",
1717
"@angular/router": "~8.2.0",
1818
"nativescript-angular": "~8.20.0",<% if(theme) { %>
19-
"nativescript-theme-core": "~1.0.4",
19+
"@nativescript/theme": "~2.2.0",
2020
<% } %>"reflect-metadata": "~0.1.12",
2121
"rxjs": "~6.4.0",
2222
"tns-core-modules": "~6.2.0",

src/ng-new/shared/_files/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@angular/router": "~8.2.0",
3030
"core-js": "^2.6.9",
3131
"nativescript-angular": "~8.20.0",<% if(theme) { %>
32-
"nativescript-theme-core": "~1.0.4",
32+
"@nativescript/theme": "~2.2.0",
3333
<% } %>"reflect-metadata": "~0.1.12",
3434
"rxjs": "~6.4.0",
3535
"tns-core-modules": "~6.2.0",

src/styling/_css-files/app.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<% if (theme) { %>
2-
@import '~nativescript-theme-core/css/core.light.css';
2+
@import '~@nativescript/theme/css/core.css';
3+
@import '~@nativescript/theme/css/blue.css';
34
<% } %>

src/styling/_scss-files/_app-variables.scss

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/styling/_scss-files/app.android.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
// Import app variables
2-
@import 'app-variables';
3-
<% if (theme) { %>
4-
// Import the theme’s main ruleset - both index and platform specific.
5-
@import '~nativescript-theme-core/scss/index';
6-
@import '~nativescript-theme-core/scss/platforms/index.android';
7-
<% } %>
81
// Import common styles
92
@import 'app-common';
103

src/styling/_scss-files/app.ios.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
// Import app variables
2-
@import 'app-variables';
3-
<% if (theme) { %>
4-
// Import the theme’s main ruleset - both index and platform specific.
5-
@import '~nativescript-theme-core/scss/index';
6-
@import '~nativescript-theme-core/scss/platforms/index.ios';
7-
<% } %>
81
// Import common styles
92
@import 'app-common';
103

src/styling/index_spec.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('Styling Schematic', () => {
6565

6666
expect(getFileContent(tree, stylingFile))
6767
.not
68-
.toMatch(new RegExp('@import "~nativescript-theme-core/css/core.light.css";'));
68+
.toMatch(new RegExp('@import "~@nativescript/theme/css/core.css";'));
6969
});
7070
});
7171

@@ -85,7 +85,7 @@ describe('Styling Schematic', () => {
8585
expect(tree.exists(`${appPath}/${sourceDir}/app.android.scss`));
8686
expect(tree.exists(`${appPath}/${sourceDir}/app.ios.scss`));
8787
expect(tree.exists(`${appPath}/${sourceDir}/_app-common.scss`));
88-
expect(tree.exists(`${appPath}/${sourceDir}/_app-variables.scss`));
88+
expect(tree.exists(`${appPath}/${sourceDir}/_app-variables.scss`)).toBe(false);
8989
});
9090

9191
it('should add scss dependencies to package.json', () => {
@@ -109,21 +109,11 @@ describe('Styling Schematic', () => {
109109

110110
expect(getFileContent(tree, `${appPath}/${sourceDir}/app.android.scss`))
111111
.not
112-
.toMatch(new RegExp('@import \'~nativescript-theme-core/scss/index\';'));
113-
expect(getFileContent(tree, `${appPath}/${sourceDir}/app.android.scss`))
114-
.not
115-
.toMatch(new RegExp('@import \'~nativescript-theme-core/scss/platforms/index.android\';'));
112+
.toMatch(new RegExp('@import "~@nativescript/theme/css/core.css;'));
116113

117114
expect(getFileContent(tree, `${appPath}/${sourceDir}/app.ios.scss`))
118115
.not
119-
.toMatch(new RegExp('@import \'~nativescript-theme-core/scss/index\';'));
120-
expect(getFileContent(tree, `${appPath}/${sourceDir}/app.ios.scss`))
121-
.not
122-
.toMatch(new RegExp('@import \'~nativescript-theme-core/scss/platforms/index.ios\';'));
123-
124-
expect(getFileContent(tree, `${appPath}/${sourceDir}/_app-variables.scss`))
125-
.not
126-
.toMatch(new RegExp('@import \'~nativescript-theme-core/scss/light\';'));
116+
.toMatch(new RegExp('@import "~@nativescript/theme/css/core.css";'));
127117
});
128118
});
129119
});

0 commit comments

Comments
 (0)