@nativescript/theme
Advanced tools
Comparing version 2.1.1 to 2.1.2-2019-10-16-141152-03
@@ -0,1 +1,25 @@ | ||
<a name="2.1.2"></a> | ||
## [2.1.2](https://github.com/NativeScript/theme/compare/v2.1.1...v2.1.2) (2019-10-16) | ||
### Features | ||
* Make the Button color modifiers work as such (applies to primary and outline buttons) | ||
### Fixes | ||
* Fix the iOS landscape custom ActionBar items displacement | ||
* Fix the not properly distributed custom ActionBar title and iOS buttons | ||
* Update blue skin accent color (to blue:) | ||
* Make the outline button borders use accent color | ||
* Return the thumb/-thumb classes for Listview (Playground compatibility) | ||
* Fix app-compat to use scoped packages | ||
* Make the default Image height only 20pt | ||
* Increase the side drawer header padding | ||
* Add -circle class to complement -rounded/rounded | ||
* Fix the esm to cjs transpilation (was breaking Angular projects in Playground) | ||
### Potential breaking changes | ||
* Remove border-radius-rounded variable - use border-radius-sm instead (they had 1pt difference). | ||
<a name="2.1.1"></a> | ||
@@ -2,0 +26,0 @@ ## [2.1.1](https://github.com/NativeScript/theme/compare/v2.1.0...v2.1.1) (2019-10-14) |
194
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.ClassList = undefined; | ||
exports.default = exports.Theme = exports.ClassList = void 0; | ||
var _application = require("tns-core-modules/application"); | ||
var app = _interopRequireWildcard(require("tns-core-modules/application")); | ||
var app = _interopRequireWildcard(_application); | ||
var _platform = require("tns-core-modules/platform"); | ||
var _viewCommon = require("tns-core-modules/ui/core/view/view-common"); | ||
var viewCommon = _interopRequireWildcard(require("tns-core-modules/ui/core/view/view-common")); | ||
var viewCommon = _interopRequireWildcard(_viewCommon); | ||
var frame = _interopRequireWildcard(require("tns-core-modules/ui/frame")); | ||
var _frame = require("tns-core-modules/ui/frame"); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
var frame = _interopRequireWildcard(_frame); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
const display = _platform.screen.mainScreen; | ||
const whiteSpaceRegExp = /\s+/; | ||
const platformClass = `ns-${_platform.isAndroid ? "android" : "ios"}`; | ||
const sdkVersionClass = _platform.device.sdkVersion.replace(".", "-"); | ||
@@ -32,143 +29,130 @@ | ||
class ClassList { | ||
constructor(className) { | ||
this.list = new Set(); | ||
constructor(className) { | ||
this.list = new Set(); | ||
(className || "").split(whiteSpaceRegExp).forEach(v => v && this.list.add(v)); | ||
} | ||
(className || "").split(whiteSpaceRegExp).forEach(v => v && this.list.add(v)); | ||
} | ||
add(...classes) { | ||
classes.forEach(v => this.list.add(v)); | ||
return this; | ||
} | ||
add(...classes) { | ||
classes.forEach(v => this.list.add(v)); | ||
remove(...classes) { | ||
classes.forEach(v => this.list.delete(v)); | ||
return this; | ||
} | ||
return this; | ||
} | ||
get() { | ||
return Array.from(this.list).join(" "); | ||
} | ||
remove(...classes) { | ||
classes.forEach(v => this.list.delete(v)); | ||
return this; | ||
} | ||
get() { | ||
return Array.from(this.list).join(" "); | ||
} | ||
} | ||
exports.ClassList = ClassList; | ||
class Theme { | ||
static setMode(mode, root = app.getRootView()) { | ||
Theme.currentMode = mode; | ||
Theme.rootView = root; | ||
static setMode(mode, root = app.getRootView()) { | ||
Theme.currentMode = mode; | ||
Theme.rootView = root; | ||
if (!root || !mode) { | ||
return; | ||
} | ||
const classList = new ClassList(Theme.rootView.className); | ||
classList.remove(Theme.Light, Theme.Dark).add(Theme.currentMode); | ||
Theme.rootView.className = classList.get(); | ||
if (!root || !mode) { | ||
return; | ||
} | ||
static toggleMode(isDark) { | ||
if (isDark === undefined) { | ||
Theme.setMode(Theme.getMode() === Theme.Light ? Theme.Dark : Theme.Light); | ||
const classList = new ClassList(Theme.rootView.className); | ||
classList.remove(Theme.Light, Theme.Dark).add(Theme.currentMode); | ||
Theme.rootView.className = classList.get(); | ||
} | ||
return; | ||
} | ||
Theme.setMode(isDark ? Theme.Dark : Theme.Light); | ||
static toggleMode(isDark) { | ||
if (isDark === undefined) { | ||
Theme.setMode(Theme.getMode() === Theme.Light ? Theme.Dark : Theme.Light); | ||
return; | ||
} | ||
static getMode() { | ||
const root = app.getRootView(); | ||
Theme.setMode(isDark ? Theme.Dark : Theme.Light); | ||
} | ||
return Theme.currentMode || ((root.className || "").indexOf(Theme.Dark) !== -1 ? Theme.Dark : Theme.Light); | ||
} | ||
} | ||
static getMode() { | ||
const root = app.getRootView(); | ||
return Theme.currentMode || ((root.className || "").indexOf(Theme.Dark) !== -1 ? Theme.Dark : Theme.Light); | ||
} | ||
if (module) { | ||
const desc = Object.getOwnPropertyDescriptor(module, "exports"); | ||
// Check if in a commonjs module | ||
if (desc.writable) { | ||
module.exports = Theme; | ||
} | ||
} | ||
exports.Theme = Theme; | ||
Theme.Light = "ns-light"; | ||
Theme.Dark = "ns-dark"; | ||
var _default = Theme; // Where the magic happens | ||
exports.default = Theme; | ||
exports.default = _default; | ||
const oldSetupAsRootView = viewCommon.ViewCommon.prototype._setupAsRootView; | ||
// Where the magic happens | ||
const oldSetupAsRootView = viewCommon.ViewCommon.prototype._setupAsRootView; | ||
viewCommon.ViewCommon.prototype._setupAsRootView = function () { | ||
oldSetupAsRootView.call(this, ...arguments); | ||
Theme.setMode(Theme.currentMode, this); | ||
oldSetupAsRootView.call(this, ...arguments); | ||
Theme.setMode(Theme.currentMode, this); | ||
}; | ||
/* Deprecated root class setters, now available in core modules */ | ||
function updateRootClasses(orientation, root = app.getRootView(), classes = []) { | ||
const classList = new ClassList(root.className); | ||
classList.remove("ns-portrait", "ns-landscape", "ns-unknown", ...classes).add(`ns-${orientation}`, ...classes); | ||
root.className = classList.get(); | ||
function updateRootClasses(orientation, root = app.getRootView(), classes = []) { | ||
const classList = new ClassList(root.className); | ||
classList.remove("ns-portrait", "ns-landscape", "ns-unknown", ...classes).add(`ns-${orientation}`, ...classes); | ||
root.className = classList.get(); | ||
} | ||
function handleOrientation({ newValue: orientation }) { | ||
updateRootClasses(orientation); | ||
function handleOrientation({ | ||
newValue: orientation | ||
}) { | ||
updateRootClasses(orientation); | ||
if (viewCommon._rootModalViews.length) { | ||
const classList = new ClassList(app.getRootView().className); | ||
if (viewCommon._rootModalViews.length) { | ||
const classList = new ClassList(app.getRootView().className); | ||
viewCommon._rootModalViews.forEach(view => updateRootClasses(orientation, view, classList.add("ns-modal").list)); | ||
} | ||
viewCommon._rootModalViews.forEach(view => updateRootClasses(orientation, view, classList.add("ns-modal").list)); | ||
} | ||
} | ||
function getOrientation() { | ||
return display.heightDIPs > display.widthDIPs ? "portrait" : "landscape"; | ||
return display.heightDIPs > display.widthDIPs ? "portrait" : "landscape"; | ||
} | ||
const rootModalTrap = { | ||
defineProperty(target, key, desc) { | ||
if (desc && "value" in desc) { | ||
target[key] = desc.value; | ||
defineProperty(target, key, desc) { | ||
if (desc && "value" in desc) { | ||
target[key] = desc.value; | ||
if (desc.value instanceof frame.Frame) { | ||
const classList = new ClassList(app.getRootView().className); | ||
if (desc.value instanceof frame.Frame) { | ||
const classList = new ClassList(app.getRootView().className); | ||
updateRootClasses(getOrientation(), desc.value, classList.add("ns-modal").list); | ||
} | ||
} | ||
updateRootClasses(getOrientation(), desc.value, classList.add("ns-modal").list); | ||
} | ||
} | ||
return target; | ||
} | ||
return target; | ||
} | ||
}; | ||
app.on(app.displayedEvent, () => { | ||
const root = app.getRootView(); | ||
const root = app.getRootView(); // Bail out if no root view or root classes already set (pre 6.1). | ||
// Bail out if no root view or root classes already set (pre 6.1). | ||
if (!root || root.cssClasses.has("ns-root")) { | ||
// Add ns-{platform}-{sdkVersion} classes | ||
if (root) { | ||
root.className = new ClassList(root.className).add(`${platformClass}__${sdkVersionClass}`).get(); | ||
} | ||
return; | ||
if (!root || root.cssClasses.has("ns-root")) { | ||
// Add ns-{platform}-{sdkVersion} classes | ||
if (root) { | ||
root.className = new ClassList(root.className).add(`${platformClass}__${sdkVersionClass}`).get(); | ||
} | ||
// Get notified when a modal is created. | ||
viewCommon._rootModalViews = new Proxy(viewCommon._rootModalViews, rootModalTrap); | ||
return; | ||
} // Get notified when a modal is created. | ||
root.className = new ClassList(root.className).add("ns-root", platformClass, `ns-${_platform.device.deviceType.toLowerCase()}`).get(); | ||
if (!started) { | ||
handleOrientation({ newValue: getOrientation() }); | ||
app.on(app.orientationChangedEvent, handleOrientation); | ||
started = true; | ||
} | ||
viewCommon._rootModalViews = new Proxy(viewCommon._rootModalViews, rootModalTrap); | ||
root.className = new ClassList(root.className).add("ns-root", platformClass, `ns-${_platform.device.deviceType.toLowerCase()}`).get(); | ||
if (!started) { | ||
handleOrientation({ | ||
newValue: getOrientation() | ||
}); | ||
app.on(app.orientationChangedEvent, handleOrientation); | ||
started = true; | ||
} | ||
}); |
{ | ||
"name": "@nativescript/theme", | ||
"version": "2.1.1", | ||
"description": "Telerik NativeScript Core Theme", | ||
"main": "index", | ||
"typings": "index.d.ts", | ||
"author": "Telerik <support@telerik.com>", | ||
"homepage": "https://www.nativescript.org", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/NativeScript/theme" | ||
}, | ||
"nativescript": { | ||
"platforms": { | ||
"android": "6.1.2", | ||
"ios": "6.1.1" | ||
"name": "@nativescript/theme", | ||
"version": "2.1.2-2019-10-16-141152-03", | ||
"description": "Telerik NativeScript Core Theme", | ||
"main": "index", | ||
"typings": "index.d.ts", | ||
"author": "Telerik <support@telerik.com>", | ||
"homepage": "https://www.nativescript.org", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/NativeScript/theme" | ||
}, | ||
"nativescript": { | ||
"platforms": { | ||
"android": "6.1.2", | ||
"ios": "6.1.1" | ||
} | ||
} | ||
} | ||
} |
@@ -238,6 +238,6 @@ # NativeScript Theme: Core V2 | ||
| --color-error | --const-border-radius-lg | --light-background-accent | --dark-background-accent | | ||
| | --const-border-radius-rounded | --light-background-dark-accent | --dark-background-dark-accent | | ||
| | --const-disabled-opacity | --light-background-dark-accent | --dark-background-dark-accent | | ||
| | --const-icon-font-size | --light-item-active-color | --dark-item-active-color | | ||
| | --const-icon-font-size-lg | --light-item-active-background | --dark-item-active-background | | ||
| | --const-disabled-opacity | --light-btn-color | --dark-btn-color | | ||
| | | --light-btn-color | --dark-btn-color | | ||
| | | --light-ab-background-dark | --dark-ab-background-dark | | ||
@@ -244,0 +244,0 @@ | | | --light-item-active-icon-color | --dark-item-active-icon-color | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
564525
310
1