Skip to content

Commit

Permalink
feat(Organization): renaming and organization of theme files per disc…
Browse files Browse the repository at this point in the history
…ussion

closes #11
  • Loading branch information
NathanWalker committed Aug 8, 2016
1 parent 3e05ef5 commit 08552a9
Show file tree
Hide file tree
Showing 22 changed files with 185 additions and 80 deletions.
14 changes: 14 additions & 0 deletions app/_demo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.main-page {
Button {
font-size: 30;
margin:10;
}
}
.themes {
Label {
margin: 5;
}
Button {
margin:5;
}
}
20 changes: 14 additions & 6 deletions app/app.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
@import 'scss/core';
/*!
* NativeScript Theme v0.1.0 (https://nativescript.org)
* Copyright 2016-2016 The Theme Authors
* Copyright 2016-2016 Telerik
* Licensed under MIT (https://github.com/NativeScript/theme/blob/master/LICENSE)
*/

/**
* Base style (un-themed)
*/
@import 'scss/variables';
@import 'scss/index';

.main-page {
// demo app
@import 'demo';

Button {
@include button-size(15, 15, 40, $btn-radius);
}
}
12 changes: 12 additions & 0 deletions app/dark.android.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*!
* NativeScript Theme v0.1.0 (https://nativescript.org)
* Copyright 2016-2016 The Theme Authors
* Copyright 2016-2016 Telerik
* Licensed under MIT (https://github.com/NativeScript/theme/blob/master/LICENSE)
*/

@import 'scss/themes/core/dark';
@import 'scss/themes/core/platforms/index.android';

// demo app
@import 'demo';
12 changes: 12 additions & 0 deletions app/dark.ios.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*!
* NativeScript Theme v0.1.0 (https://nativescript.org)
* Copyright 2016-2016 The Theme Authors
* Copyright 2016-2016 Telerik
* Licensed under MIT (https://github.com/NativeScript/theme/blob/master/LICENSE)
*/

@import 'scss/themes/core/dark';
@import 'scss/themes/core/platforms/index.ios';

// demo app
@import 'demo';
12 changes: 12 additions & 0 deletions app/light.android.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*!
* NativeScript Theme v0.1.0 (https://nativescript.org)
* Copyright 2016-2016 The Theme Authors
* Copyright 2016-2016 Telerik
* Licensed under MIT (https://github.com/NativeScript/theme/blob/master/LICENSE)
*/

@import 'scss/themes/core/light';
@import 'scss/themes/core/platforms/index.android';

// demo app
@import 'demo';
12 changes: 12 additions & 0 deletions app/light.ios.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*!
* NativeScript Theme v0.1.0 (https://nativescript.org)
* Copyright 2016-2016 The Theme Authors
* Copyright 2016-2016 Telerik
* Licensed under MIT (https://github.com/NativeScript/theme/blob/master/LICENSE)
*/

@import 'scss/themes/core/light';
@import 'scss/themes/core/platforms/index.ios';

// demo app
@import 'demo';
4 changes: 2 additions & 2 deletions app/pages/basics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</ActionBar>
</Page.actionBar>
<StackLayout>
<Button text="Button" tap="" cssClass="btn-primary" />
<Button text="Button" tap="" cssClass="btn-outline-primary" />
<Button text="Button" tap="" cssClass="btn btn-primary" />
<Button text="Button" tap="" cssClass="btn btn-outline-primary" />

</StackLayout>
</Page>
41 changes: 27 additions & 14 deletions app/pages/themes-vm.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
import {Observable} from 'data/observable';
import {topmost} from 'ui/frame';
import {knownFolders} from 'file-system';
import {isIOS, isAndroid} from 'platform';
var themes = require('nativescript-themes');

export class ThemesModel extends Observable {
public btnText: string;
public labelText: string;
private _toggled: boolean = false;

constructor() {
super();
this.set('btnText', 'Nina');
this.set('labelText', 'Default');
}

public switchTheme() {
this._toggled = !this._toggled;
public applyDefault() {
this.set('labelText', 'Default');
themes.applyTheme(this.getPath('app'));
}

let appPath = knownFolders.currentApp().path + '/';

if (this._toggled) {
this.set('btnText', 'Default');
themes.applyTheme(`${appPath}theme-nina.css`);

} else {
this.set('btnText', 'Nina');
themes.applyTheme(`${appPath}app.css`);
}
public applyLight() {
this.set('labelText', 'Light');
themes.applyTheme(this.getPath('light'));
}

public applyDark() {
this.set('labelText', 'Dark');
themes.applyTheme(this.getPath('dark'));
}

private getPath(name: string) {
let appPath = knownFolders.currentApp().path + '/';
let platform = '';
// if (name !== 'app') {
// if (isIOS) {
// platform = '.ios';
// } else {
// platform = '.android';
// }
// }
return `${appPath}${name}${platform}.css`;
}
}
8 changes: 5 additions & 3 deletions app/pages/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
</ActionBar.actionItems>
</ActionBar>
</Page.actionBar>
<StackLayout>
<Button text="{{ 'Change Theme to ' + btnText}}" tap="{{ switchTheme }}" />
<Label text="TO DO :)" textWrap="true" />
<StackLayout class="main-page themes">
<Label text="{{ 'Active: ' + labelText }}" textWrap="true" />
<Button text="Apply Default" tap="{{ applyDefault }}" />
<Button text="Apply Light" tap="{{ applyLight }}" />
<Button text="Apply Dark" tap="{{ applyDark }}" />
</StackLayout>
</Page>
File renamed without changes.
20 changes: 0 additions & 20 deletions app/scss/_core.scss

This file was deleted.

12 changes: 12 additions & 0 deletions app/scss/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Utilities
@import 'mixins';

// Core CSS
@import 'action-bar';
@import 'buttons';
@import 'labels';
@import 'list-view';
@import 'segmented-bar';
@import 'switch';
@import 'slider';
@import 'stack-layout';
File renamed without changes.
4 changes: 0 additions & 4 deletions app/scss/themes/_button.scss

This file was deleted.

20 changes: 0 additions & 20 deletions app/scss/themes/_nina.scss

This file was deleted.

7 changes: 7 additions & 0 deletions app/scss/themes/core/_buttons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Just a sample
// if we need custom styles for the theme, we can create them in files like this

.btn {
color: $btn-color;
@include button-size(5, 10, 18, $btn-radius);
}
9 changes: 9 additions & 0 deletions app/scss/themes/core/_dark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Core variables and mixins
@import '../../variables';
@import 'variables_dark';

// Core CSS
@import '../../index';

// Custom Theme Overrides
@import 'buttons';
9 changes: 9 additions & 0 deletions app/scss/themes/core/_light.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Core variables and mixins
@import '../../variables';
@import 'variables_light';

// Core CSS
@import '../../index';

// Custom Theme Overrides
@import 'buttons';
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* TODO .... These are not correct ... just samples.
*/

// Colors
$primary: #528100;
$complimentary: #7C3FE8;
Expand Down
28 changes: 28 additions & 0 deletions app/scss/themes/core/_variables_light.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* TODO .... These are not correct ... just samples.
*/

// Colors
$primary: pink;
$complimentary: purple;
$gray: lightblue;
$white: white;

// Skin
$background: $primary;
$text-color: $gray;

// Buttons
$btn-color: $complimentary;
$btn-font-size: 18;
$btn-radius: 5;
$btn-padding-x: 20;
$btn-padding-y: 20;

// Options
//
// Quickly modify global styling by enabling or disabling optional features.
$enable-rounded: true !default;
$enable-shadows: false !default;
$enable-gradients: false !default;
$enable-transitions: false !default;
8 changes: 0 additions & 8 deletions app/theme-nina.scss

This file was deleted.

9 changes: 6 additions & 3 deletions hooks/before-prepare/nativescript-dev-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ function convert(logger, projectDir, options) {

// Customized by Nathan Walker
// Allows normal SASS imports to work as expected
var sassFilesPath = path.join(projectDir, 'app/*.scss');
var sassFilesPath = path.join(projectDir, 'app/**/*.scss');
var sassImportPath = path.join(projectDir, 'app/');
console.log("SASS Import Path", sassImportPath);

var sassFiles = glob.sync(sassFilesPath).filter(function(fileName){
return fileName.indexOf("App_Resources") === -1;
var sassFiles = glob.sync(sassFilesPath).filter(function (filePath) {
var path = filePath;
var parts = path.split('/');
var filename = parts[parts.length - 1];
return path.indexOf("App_Resources") === -1 && filename.indexOf("_") !== 0;
});

if(sassFiles.length === 0){
Expand Down

0 comments on commit 08552a9

Please sign in to comment.