Skip to content

Commit 7414760

Browse files
authored
feat: scoped package (#189)
* feat: scope package * refactor: migrate imports * docs: migrate imports * chore: migrate package-lock.json * fix: eslint errors
1 parent 1d85815 commit 7414760

18 files changed

+136
-114
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ install:
55
- echo no | npm install
66

77
before_script:
8-
- node_modules/.bin/eslint
8+
- npm run eslint
99

1010
script:
1111
- npm run builder

README.md

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NativeScript Theme: Core V2
2-
[![npm](https://img.shields.io/npm/v/nativescript-theme-core.svg)](https://www.npmjs.com/package/nativescript-theme-core)
3-
[![npm](https://img.shields.io/npm/dt/nativescript-theme-core.svg?label=npm%20downloads)](https://www.npmjs.com/package/nativescript-theme-core)
2+
[![npm](https://img.shields.io/npm/v/@nativescript/theme.svg)](https://www.npmjs.com/package/@nativescript/theme)
3+
[![npm](https://img.shields.io/npm/dt/@nativescript/theme.svg?label=npm%20downloads)](https://www.npmjs.com/package/@nativescript/theme)
44

55
Home of the core NativeScript theme 2.0 beta. The documentation of the beta theme will live here, until it gets final.
66

@@ -26,77 +26,77 @@ Home of the core NativeScript theme 2.0 beta. The documentation of the beta them
2626
## Breaking changes
2727

2828
* The theme requires 2 files to be loaded - the core theme and a skin on top of it. Read [Usage](#usage) for more info.
29-
* The theme is now **applied using Element selectors**, if you need the old classes approach - it has moved to
29+
* The theme is now **applied using Element selectors**, if you need the old classes approach - it has moved to
3030
.compat CSS/SCSS files, e.g. `core.compat.css` and `blue.compat.css`.
3131
* Theme 2.0 beta **requires some JavaScript to be loaded** for **{N} before 6.1** which helps with the styling.
32-
* Theme 2.0 replaces node-sass with **sass** which is more up to date feature-wise and doesn't have a native dependency.
32+
* Theme 2.0 replaces node-sass with **sass** which is more up to date feature-wise and doesn't have a native dependency.
3333
It does still work with node-sass though.
3434

3535
## Usage
3636

37-
The core theme supports light and dark core styling and skins on top of that. To load the core theme styling, just
37+
The core theme supports light and dark core styling and skins on top of that. To load the core theme styling, just
3838
load the core CSS (the default skin was added in 2.0.18):
3939

4040
```css
41-
@import "~nativescript-theme-core/css/core.css";
41+
@import "~@nativescript/theme/css/core.css";
4242
```
4343

4444
or alternatively SCSS:
4545

4646
```scss
47-
@import "~nativescript-theme-core/core";
47+
@import "~@nativescript/theme/core";
4848
```
4949

5050
If you want, you can choose from several different skins. To do that, you can include a second CSS/SCC file just after
5151
you load the core CSS/SCSS (if you use Theme 2.017 or earlier, you will have to include both files for the styling
52-
to work.
52+
to work.
5353

5454
```css
55-
@import "~nativescript-theme-core/css/core.css";
56-
@import "~nativescript-theme-core/css/blue.css";
55+
@import "~@nativescript/theme/css/core.css";
56+
@import "~@nativescript/theme/css/blue.css";
5757
```
5858

5959
or
6060

6161
```scss
62-
@import "~nativescript-theme-core/core";
63-
@import "~nativescript-theme-core/blue";
62+
@import "~@nativescript/theme/core";
63+
@import "~@nativescript/theme/blue";
6464
```
6565

6666
In order to import just the Theme variables in one of your modules, use this:
6767

6868
```scss
69-
@import "~nativescript-theme-core/scss/variables";
69+
@import "~@nativescript/theme/scss/variables";
7070
```
7171

7272
It will import just the variables and mixins, without any additional styling.
7373

74-
Here is the old list of Theme skins - the first two are now the Core default Light and Dark skins, the rest are
74+
Here is the old list of Theme skins - the first two are now the Core default Light and Dark skins, the rest are
7575
all the Light skins available, listed by name.
7676

77-
![Multiple Platforms](http://docs.nativescript.org/img/theme/color-schemes-all.png)
77+
![Multiple Platforms](http://docs.nativescript.org/img/theme/color-schemes-all.png)
7878

7979
The theme will style your application using Element selectors - you don't need to add CSS classes on every element you
8080
need to style.
8181

82-
Additionally, if you need to create you own skin, you can start just from the core theme - it includes the sizing and
82+
Additionally, if you need to create you own skin, you can start just from the core theme - it includes the sizing and
8383
initial styling of the components.
8484

8585
## Usage before NativeScript 6.1
8686

8787
In order to use the 2.0 beta theme before {N} 6.1, you will also need to include a small JS file in your project:
8888

8989
```javascript
90-
import "nativescript-theme-core";
90+
import "@nativescript/theme";
9191
```
9292

93-
This JS takes care of updating several classes on the app root elements, something that got
93+
This JS takes care of updating several classes on the app root elements, something that got
9494
[included in tns-core-modules](https://github.com/NativeScript/NativeScript/issues/7313) in {N} 6.1.
9595

9696
## Setting Dark or Light mode
9797

98-
Setting the theme mode from light to dark is now easier - instead of loading a new file, just find the root view and
99-
set `.ns-dark` class to it - this will change all colorization to dark tones. For instance, if your page root is
98+
Setting the theme mode from light to dark is now easier - instead of loading a new file, just find the root view and
99+
set `.ns-dark` class to it - this will change all colorization to dark tones. For instance, if your page root is
100100
RadSideDrawer, just add a class to it, like this:
101101

102102
```html
@@ -111,16 +111,16 @@ If your root is a frame, you can do this
111111
<Frame class="ns-dark" defaultPage="root"></Frame>
112112
```
113113

114-
For **Angular**, if your root is a `page-router-outlet`, you can set the .ns-dark class on it - it will pass it down to the
115-
Frame it renders.
114+
For **Angular**, if your root is a `page-router-outlet`, you can set the .ns-dark class on it - it will pass it down to the
115+
Frame it renders.
116116

117117
## Setting Dark or Light mode from JavaScript
118118

119-
Setting the theme mode from JavaScript is also much easier now - just import the theme and call Theme.setMode() with
119+
Setting the theme mode from JavaScript is also much easier now - just import the theme and call Theme.setMode() with
120120
your preferred mode - either Theme.Light or Theme.dark, like this:
121121

122122
```javascript
123-
import Theme from "nativescript-theme-core";
123+
import Theme from "@nativescript/theme";
124124

125125
Theme.setMode(Theme.Dark); // Or Theme.Light
126126
```
@@ -129,7 +129,7 @@ Additionally there is another helper method - toggleMode, which can be used with
129129
or with a boolean parameter to ensure light or dark mode is set:
130130

131131
```javascript
132-
import Theme from "nativescript-theme-core";
132+
import Theme from "@nativescript/theme";
133133

134134
Theme.toggleMode(); // to toggle between the modes
135135

@@ -145,28 +145,28 @@ Due to limitation in Playground the JS Theme API cannot be imported like an ES6
145145
have to resort to requiring it:
146146

147147
```javascript
148-
const Theme = require("nativescript-theme-core");
148+
const Theme = require("@nativescript/theme");
149149

150150
Theme.setMode(Theme.Dark); // Or Theme.Light
151151
```
152152

153153
## More root classes
154154

155155
In addition to `.ns-light` and `.ns-dark` classes, the theme's little JavaScript file introduces `.ns-root` on the root element,
156-
`.ns-android/.ns-ios` depending on the current platform (which the theme extensively uses) and additionally
157-
`.ns-portrait/.ns-landscape` and `.ns-phone/.ns-tablet`, which should be self-explanatory.
158-
Of course `.ns-portrait/.ns-landscape` get updated on orientation change, so you can use it to show a two pane layout
159-
in landscape, for instance.
156+
`.ns-android/.ns-ios` depending on the current platform (which the theme extensively uses) and additionally
157+
`.ns-portrait/.ns-landscape` and `.ns-phone/.ns-tablet`, which should be self-explanatory.
158+
Of course `.ns-portrait/.ns-landscape` get updated on orientation change, so you can use it to show a two pane layout
159+
in landscape, for instance.
160160

161-
The newest addition is `.ns-statusbar-transparent` since 2.0.4 - add this class to your root element, if you have enabled
162-
transparent status bar in the OS and your ActionBar gets underneath it.
161+
The newest addition is `.ns-statusbar-transparent` since 2.0.4 - add this class to your root element, if you have enabled
162+
transparent status bar in the OS and your ActionBar gets underneath it.
163163

164-
> Keep in mind that **Android APIs before 21** don't support transparent status bars and this will result
164+
> Keep in mind that **Android APIs before 21** don't support transparent status bars and this will result
165165
in an undesired top ActionBar padding!
166166

167167
## Using Theme variables
168168

169-
There are several functions and mixins in the core theme, that can be used in your projects, as long as you're using
169+
There are several functions and mixins in the core theme, that can be used in your projects, as long as you're using
170170
SASS/SCSS.
171171

172172
If you need to access specific theme variables like simple colors or sizes, do it through the `const` function:
@@ -176,7 +176,7 @@ Button {
176176
background-color: const(forest);
177177
height: const(btn-height);
178178
}
179-
```
179+
```
180180

181181
You can get light/dark colors:
182182

@@ -206,13 +206,13 @@ Button {
206206
}
207207
```
208208

209-
The above example uses the contrasted function to check the contrast level of the background and adjust the lightness of
209+
The above example uses the contrasted function to check the contrast level of the background and adjust the lightness of
210210
the accent color according to it.
211211

212212
## CSS variables
213213

214-
Since 2.0.17 beta, the Theme now exports all its internal variables to CSS ones in the .ns-root and .ns-modal classes.
215-
This is also done for Kendo based skins. You can use them to inherit your styles from the Theme.
214+
Since 2.0.17 beta, the Theme now exports all its internal variables to CSS ones in the .ns-root and .ns-modal classes.
215+
This is also done for Kendo based skins. You can use them to inherit your styles from the Theme.
216216
A list of the supported CSS variables follows:
217217

218218
| Simple Colors | Constants | Light Colors | Dark Colors |
@@ -252,14 +252,14 @@ Use them like this:
252252
}
253253
```
254254

255-
For now these CSS variables are not used internally, so changing them won't change the look of your skin. This is planned
256-
for after HSL color support comes in NativeScript 6.2.
255+
For now these CSS variables are not used internally, so changing them won't change the look of your skin. This is planned
256+
for after HSL color support comes in NativeScript 6.2.
257257

258258
## Kendo UI ThemeBuilder support
259259

260260
The theme now supports inheriting the [Kendo UI ThemeBuilder](https://themebuilder.telerik.com/) theme variables. Just head
261-
there, customize your Keno UI SASS theme and hit the Download button. You will get a ZIP with two files in it - the theme CSS
262-
that you can use to style your web app, and `variables.scss` - the one you need for your NativeScript theme. It will look
261+
there, customize your Keno UI SASS theme and hit the Download button. You will get a ZIP with two files in it - the theme CSS
262+
that you can use to style your web app, and `variables.scss` - the one you need for your NativeScript theme. It will look
263263
something like this:
264264

265265
```scss
@@ -294,27 +294,27 @@ Take this file, add the following under it:
294294
// Uncomment this row, if you target compat styling:
295295
// $compat: true;
296296

297-
@import '~nativescript-theme-core/index';
297+
@import '~@nativescript/theme/index';
298298
```
299299

300300
And load the file after your core theme. It should just work&trade;. If it doesn't - head for the issues section.
301301

302302
## Theme classes and compatibility
303303

304-
The old generic theme classes have been retired to avoid clashes with user code. They now live in the .compat world -
304+
The old generic theme classes have been retired to avoid clashes with user code. They now live in the .compat world -
305305
if you want to use them, you should load them separately, like this:
306306

307307
```scss
308-
@import "~nativescript-theme-core/core.compat";
309-
@import "~nativescript-theme-core/blue.compat";
308+
@import "~@nativescript/theme/core.compat";
309+
@import "~@nativescript/theme/blue.compat";
310310
```
311311

312312
There might be bugs with these in the beta, you might want to hold off upgrading if you want to use the old classes.
313313

314314
As of 2.0, the theme now utilizes a simplified BEM approach for the new element classes, that might be needed here or there.
315-
For instance, the buttons need `.-primary` and `.-outline` modifiers, instead of the old `.btn-primary` and
316-
`.btn-outline` classes. All element classes (which are not needed by default, except if you want to style a component
317-
to look like another one) are namespaced, so for instance a button is `.nt-button`, an action bar is `.nt-action-bar` and a ListView is
315+
For instance, the buttons need `.-primary` and `.-outline` modifiers, instead of the old `.btn-primary` and
316+
`.btn-outline` classes. All element classes (which are not needed by default, except if you want to style a component
317+
to look like another one) are namespaced, so for instance a button is `.nt-button`, an action bar is `.nt-action-bar` and a ListView is
318318
`.nt-list-view`.
319319

320320
## Should I use sass or node-sass
@@ -333,13 +333,13 @@ Theme 2.0 is developed using SASS. The NPM package used was sass (formerly dart-
333333
## Why Beta
334334

335335
* Firstly, we want to gather feedback from the community and create a theme that is useful and if possible - beautiful.
336-
* Secondly, the theme needs the classes inside the core modules to work properly without loading additional JavaScript
336+
* Secondly, the theme needs the classes inside the core modules to work properly without loading additional JavaScript
337337
(this is now released with {N} 6.1).
338-
* And thirdly - {N} core modules should have a way to propagate OS theme changes inside the app, so that it can act accordingly
338+
* And thirdly - {N} core modules should have a way to propagate OS theme changes inside the app, so that it can act accordingly
339339
(planned for {N} 6.2).
340340

341-
The theme is relatively stable, try the latest version [![npm](https://img.shields.io/npm/v/nativescript-theme-core?label=%20&style=flat-square)](https://www.npmjs.com/package/nativescript-theme-core)
342-
and report if you notice problems.
341+
The theme is relatively stable, try the latest version [![npm](https://img.shields.io/npm/v/@nativescript/theme?label=%20&style=flat-square)](https://www.npmjs.com/package/@nativescript/theme)
342+
and report if you notice problems.
343343

344344
## Screenshots
345345

@@ -371,7 +371,7 @@ If you’d like to toggle the color scheme from light to dark, open the sidedraw
371371

372372
**IMPORTANT**: Always make sure you have run the demo app in iOS or Android to verify any changes as well as ensure the latest `css` has been built before doing the following:
373373

374-
* Bump version in `nativescript-theme-core.json`
374+
* Bump version in `package.json`
375375
* Adjust `nativescript-theme-core.md` if any changes to the published `README` are needed.
376376

377377
```

app-compat/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ You can use this file to perform app-level initialization, but the primary
44
purpose of the file is to pass control to the app’s first module.
55
*/
66
import * as app from "tns-core-modules/application";
7-
import "nativescript-theme-core";
7+
import "@nativescript/theme";
88

99
export function fonticon(value) {
1010
if (value) {

app-compat/app.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Import the theme’s variables. If you’re using a color scheme
22
// other than “light”, switch the path to the alternative scheme,
3-
// for example '~nativescript-theme-core/scss/dark'.
4-
@import '~nativescript-theme-core/core.compat';
3+
// for example '~@nativescript/theme/scss/dark'.
4+
@import '~@nativescript/theme/core.compat';
55

66
@import '~/assets/css/font-awesome.scss';
77

app-compat/pages/themes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BaseModel } from "./base";
22
import themes from "nativescript-themes";
33
import * as application from "tns-core-modules/application";
4-
import { ClassList } from "nativescript-theme-core";
4+
import { ClassList } from "@nativescript/theme";
55

66
const currentTheme = {
77
theme: "core.light",
@@ -74,7 +74,7 @@ export class ThemesModel extends BaseModel {
7474
import(
7575
/* webpackMode: "lazy",
7676
webpackExclude: /\/scss\/|index.d.ts|index.js/ */
77-
`nativescript-theme-core/${currentTheme.skin}`)
77+
`@nativescript/theme/${currentTheme.skin}`)
7878
.then((skinStyles) => this._applyStyles(skinStyles, `${currentTheme.skin}`));
7979
}
8080

app/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ You can use this file to perform app-level initialization, but the primary
44
purpose of the file is to pass control to the app’s first module.
55
*/
66
import * as app from "tns-core-modules/application";
7-
import "nativescript-theme-core";
7+
import "@nativescript/theme";
88

99
export function fonticon(value) {
1010
if (value) {

app/app.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Import the theme’s variables. If you’re using a color scheme
22
// other than “light”, switch the path to the alternative scheme,
3-
// for example '~nativescript-theme-core/scss/dark'.
4-
@import '~nativescript-theme-core/core';
3+
// for example '~@nativescript/theme/scss/dark'.
4+
@import '~@nativescript/theme/core';
55

66
@import '~/assets/css/font-awesome.scss';
77

app/bootstrap-based.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* Licensed under Apache 2.0 (https://github.com/NativeScript/theme/blob/master/LICENSE)
66
*/
77

8-
@import '~nativescript-theme-core/scss/variables';
8+
@import '~@nativescript/theme/scss/variables';
99

1010
// Variables form bootstrap v4 dependency
1111
@import '~bootstrap/scss/functions', '~bootstrap/scss/variables';
1212

1313
// Import bootstrap map to apply variable mapping
14-
@import '~nativescript-theme-core/scss/bootstrap/map';
14+
@import '~@nativescript/theme/scss/bootstrap/map';
1515

1616
// Import theme
17-
@import '~nativescript-theme-core/index';
17+
@import '~@nativescript/theme/index';

app/customized.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Theme variables customizations
99

1010
// Core variables
11-
@import '~nativescript-theme-core/scss/variables';
11+
@import '~@nativescript/theme/scss/variables';
1212

1313
// Colors
1414
$focus: #09A52e;
@@ -27,4 +27,4 @@ $background-alt-10: #0AC16E;
2727
$btn-color-disabled: #CCC4C9;
2828

2929
// Core styles
30-
@import '~nativescript-theme-core/index';
30+
@import '~@nativescript/theme/index';

app/kendo-bootstrap.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ $series-d: #f0ad4e;
2121
$series-e: #e67d4a;
2222
$series-f: #d9534f;
2323

24-
@import '~nativescript-theme-core/index';
24+
@import '~@nativescript/theme/index';

0 commit comments

Comments
 (0)