diff --git a/src/core/constants.ts b/src/core/constants.ts index 7e6f45e98..8330e31d9 100644 --- a/src/core/constants.ts +++ b/src/core/constants.ts @@ -38,10 +38,18 @@ export class CoreConstants { /* eslint-disable max-len */ static readonly SECONDS_YEAR = 31536000; + static readonly SECONDS_MONTH = 2592000; static readonly SECONDS_WEEK = 604800; static readonly SECONDS_DAY = 86400; static readonly SECONDS_HOUR = 3600; static readonly SECONDS_MINUTE = 60; + static readonly MILLISECONDS_YEAR = 31536000000; + static readonly MILLISECONDS_MONTH = 2592000000; + static readonly MILLISECONDS_WEEK = 604800000; + static readonly MILLISECONDS_DAY = 86400000; + static readonly MILLISECONDS_HOUR = 3600000; + static readonly MILLISECONDS_MINUTE = 60000; + static readonly MILLISECONDS_SECOND = 1000; static readonly WIFI_DOWNLOAD_THRESHOLD = 104857600; // 100MB. static readonly DOWNLOAD_THRESHOLD = 10485760; // 10MB. static readonly MINIMUM_FREE_SPACE = 10485760; // 10MB. @@ -131,7 +139,7 @@ export class CoreConstants { } -type EnvironmentConfig = { +export interface EnvironmentConfig { app_id: string; appname: string; versioncode: number; @@ -167,7 +175,7 @@ type EnvironmentConfig = { forceOpenLinksIn: 'app' | 'browser'; }; -type EnvironmentBuild = { +export interface EnvironmentBuild { version: string; isProduction: boolean; isTesting: boolean; diff --git a/src/core/singletons/math.ts b/src/core/singletons/math.ts new file mode 100644 index 000000000..1c32c947f --- /dev/null +++ b/src/core/singletons/math.ts @@ -0,0 +1,32 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * Singleton with helper functions for math operations. + */ +export class CoreMath { + + /** + * Clamp a value between a minimum and a maximum. + * + * @param value Original value. + * @param min Minimum value. + * @param max Maximum value. + * @return Clamped value. + */ + static clamp(value: number, min: number, max: number): number { + return Math.min(Math.max(value, min), max); + } + +} diff --git a/src/core/singletons/object.ts b/src/core/singletons/object.ts index 8f6bf1fa3..0b3dbbc38 100644 --- a/src/core/singletons/object.ts +++ b/src/core/singletons/object.ts @@ -21,6 +21,17 @@ export type CoreObjectWithoutEmpty = { */ export class CoreObject { + /** + * Check if two objects have the same shape and the same leaf values. + * + * @param a First object. + * @param b Second object. + * @return Whether objects are equal. + */ + static deepEquals(a: unknown, b: unknown): boolean { + return JSON.stringify(a) === JSON.stringify(b); + } + /** * Check whether the given object is empty. * diff --git a/src/theme/globals.variables.scss b/src/theme/globals.variables.scss index c0c8e0eb4..327dd8f23 100644 --- a/src/theme/globals.variables.scss +++ b/src/theme/globals.variables.scss @@ -161,3 +161,12 @@ $screen-breakpoints: ( ) !default; $breakpoint-tablet: map-get($screen-breakpoints, tablet), !default; + +/* + * Z-indexes. + * + * https://github.com/ionic-team/ionic-framework/blob/master/core/src/themes/ionic.globals.scss + */ + +$z-index-overlay: 1001; +$z-index-overlay-wrapper: 10; diff --git a/src/theme/theme.base.scss b/src/theme/theme.base.scss index 1e33ab0ef..a3b41bb81 100644 --- a/src/theme/theme.base.scss +++ b/src/theme/theme.base.scss @@ -37,6 +37,14 @@ flex-direction: row; } +.margin-bottom-sm { margin-bottom: 8px; } +.margin-bottom-md { margin-bottom: 12px; } + +.font-bold { font-weight: bold; } +.font-italic { font-style: italic; } +.font-lg { font-size: 1.7rem; } +.font-sm { font-size: 1.2rem; } + // Correctly inherit ion-text-wrap onto labels. ion-item.ion-text-wrap ion-label { white-space: normal !important;