Add Option to Magnify Any Block

This commit is contained in:
Atanas Yonkov
2023-03-22 13:27:19 +02:00
parent 24cbb818b7
commit e9411d4855
10 changed files with 38 additions and 3 deletions
@@ -1,5 +1,6 @@
import { PageBlock, PageBlockInput, Registry } from './base'
import { Button } from './types'
import { Apply } from '../../../cast'
const kind = 'Automation'
@@ -12,11 +13,13 @@ interface Options {
//
// Default behaviour is to add new buttons automatically.
sealed: boolean;
magnifyOption: string;
}
const defaults: Readonly<Options> = Object.freeze({
buttons: [],
sealed: false,
magnifyOption: '',
})
export class PageBlockAutomation extends PageBlock {
@@ -32,6 +35,8 @@ export class PageBlockAutomation extends PageBlock {
applyOptions (o?: Partial<Options>): void {
if (!o) return
Apply(this.options, o, String, 'magnifyOption')
if (o.buttons) {
this.options.buttons = o.buttons.map(b => new Button(b))
}
@@ -16,6 +16,7 @@ interface Options {
zoomMax: number;
bounds: Bounds | null;
lockBounds: boolean;
magnifyOption: string;
}
const defaults: Readonly<Options> = Object.freeze({
@@ -27,6 +28,7 @@ const defaults: Readonly<Options> = Object.freeze({
zoomMax: 18,
bounds: null,
lockBounds: false,
magnifyOption: '',
})
export class PageBlockGeometry extends PageBlock {
@@ -49,6 +51,7 @@ export class PageBlockGeometry extends PageBlock {
this.options.center = (o.center || [])
this.options.bounds = (o.bounds || null)
Apply(this.options, o, String, 'magnifyOption')
Apply(this.options, o, Number, 'zoomStarting', 'zoomMin', 'zoomMax')
Apply(this.options, o, Boolean, 'lockBounds')
}
@@ -42,12 +42,14 @@ interface Options {
metrics: Array<Metric>;
refreshRate: number;
showRefresh: boolean;
magnifyOption: string;
}
const defaults: Readonly<Options> = Object.freeze({
metrics: [],
refreshRate: 0,
showRefresh: false,
magnifyOption: '',
})
export class PageBlockMetric extends PageBlock {
@@ -64,6 +66,7 @@ export class PageBlockMetric extends PageBlock {
if (!o) return
Apply(this.options, o, Number, 'refreshRate')
Apply(this.options, o, Boolean, 'showRefresh')
Apply(this.options, o, String, 'magnifyOption')
if (o.metrics) {
this.options.metrics = o.metrics
}
@@ -1,5 +1,6 @@
import { PageBlock, PageBlockInput, Registry } from '../base'
import NavigationItem, { NavigationItemInput } from './navigation-item'
import { Apply } from '../../../../cast'
const kind = 'Navigation'
@@ -12,6 +13,7 @@ interface DisplayOptions {
interface Options {
display: DisplayOptions;
navigationItems: NavigationItem[];
magnifyOption: string;
}
const defaults: Readonly<Options> = Object.freeze({
@@ -21,6 +23,7 @@ const defaults: Readonly<Options> = Object.freeze({
fillJustify: 'justify',
},
navigationItems: [],
magnifyOption: '',
})
export class PageBlockNavigation extends PageBlock {
@@ -41,6 +44,8 @@ export class PageBlockNavigation extends PageBlock {
if (o.display) {
this.options.display = o.display
}
Apply(this.options, o, String, 'magnifyOption')
}
static makeNavigationItem (item?: NavigationItemInput): NavigationItem {
+3 -1
View File
@@ -6,11 +6,13 @@ const kind = 'Nylas'
interface Options {
kind: string,
componentID: string;
magnifyOption: string;
}
const defaults: Readonly<Options> = Object.freeze({
kind: 'Composer', // Default kind of nylas component
componentID: '',
magnifyOption: '',
})
export class PageBlockNylas extends PageBlock {
@@ -26,7 +28,7 @@ export class PageBlockNylas extends PageBlock {
applyOptions (o?: Partial<Options>): void {
if (!o) return
Apply(this.options, o, String, 'kind', 'componentID')
Apply(this.options, o, String, 'kind', 'componentID', 'magnifyOption')
}
}
@@ -35,6 +35,7 @@ interface Options {
display: DisplayOptions;
refreshRate: number;
showRefresh: boolean;
magnifyOption: string;
}
const defaults: Readonly<Options> = Object.freeze({
@@ -72,6 +73,7 @@ const defaults: Readonly<Options> = Object.freeze({
},
refreshRate: 0,
showRefresh: false,
magnifyOption: '',
})
export class PageBlockProgress extends PageBlock {
@@ -89,6 +91,7 @@ export class PageBlockProgress extends PageBlock {
Apply(this.options, o, Number, 'refreshRate')
Apply(this.options, o, Boolean, 'showRefresh')
Apply(this.options, o, String, 'magnifyOption')
if (o.value) {
this.options.value = { ...this.options.value, ...o.value }
@@ -12,6 +12,7 @@ interface Options {
group: string;
refreshRate: number;
showRefresh: boolean;
magnifyOption: string;
}
const defaults: Readonly<Options> = Object.freeze({
@@ -24,6 +25,7 @@ const defaults: Readonly<Options> = Object.freeze({
group: '',
refreshRate: 0,
showRefresh: false,
magnifyOption: '',
})
export class PageBlockRecordOrganizer extends PageBlock {
@@ -40,7 +42,7 @@ export class PageBlockRecordOrganizer extends PageBlock {
if (!o) return
Apply(this.options, o, CortezaID, 'moduleID')
Apply(this.options, o, String, 'labelField', 'descriptionField', 'filter', 'positionField', 'groupField', 'group')
Apply(this.options, o, String, 'labelField', 'descriptionField', 'filter', 'positionField', 'groupField', 'group', 'magnifyOption')
Apply(this.options, o, Number, 'refreshRate')
Apply(this.options, o, Boolean, 'showRefresh')
}
@@ -1,4 +1,5 @@
import { PageBlock, PageBlockInput, Registry } from './base'
import { Apply } from '../../../cast'
const kind = 'Record'
@@ -10,11 +11,13 @@ interface FieldCondition {
interface Options {
fields: unknown[];
fieldConditions: FieldCondition[];
magnifyOption: string;
}
const defaults: Readonly<Options> = Object.freeze({
fields: [],
fieldConditions: [],
magnifyOption: '',
})
export class PageBlockRecord extends PageBlock {
@@ -30,6 +33,8 @@ export class PageBlockRecord extends PageBlock {
applyOptions (o?: Partial<Options>): void {
if (!o) return
Apply(this.options, o, String, 'magnifyOption')
if (o.fields) {
this.options.fields = o.fields
}
@@ -9,6 +9,7 @@ interface Options {
profileUrl: string;
showRefresh: boolean;
refreshRate: number;
magnifyOption: string;
}
const defaults: Readonly<Options> = Object.freeze({
@@ -18,6 +19,7 @@ const defaults: Readonly<Options> = Object.freeze({
profileUrl: '',
showRefresh: false,
refreshRate: 0,
magnifyOption: '',
})
export class PageBlockSocialFeed extends PageBlock {
@@ -34,7 +36,7 @@ export class PageBlockSocialFeed extends PageBlock {
if (!o) return
Apply(this.options, o, CortezaID, 'moduleID')
Apply(this.options, o, String, 'profileSourceField', 'profileUrl')
Apply(this.options, o, String, 'profileSourceField', 'profileUrl', 'magnifyOption')
Apply(this.options, o, Number, 'refreshRate')
Apply(this.options, o, Boolean, 'showRefresh')
@@ -1,4 +1,5 @@
import { PageBlock, PageBlockInput, Registry } from './base'
import { Apply } from '../../../cast'
const kind = 'Tabs'
@@ -18,6 +19,7 @@ interface Tab {
interface Options {
style: Style;
tabs: Tab[];
magnifyOption: string;
}
const defaults: Readonly<Options> = Object.freeze({
@@ -29,6 +31,7 @@ const defaults: Readonly<Options> = Object.freeze({
position: 'start',
},
tabs: [],
magnifyOption: '',
})
export class PageBlockTab extends PageBlock {
@@ -44,6 +47,8 @@ export class PageBlockTab extends PageBlock {
applyOptions (o?: Partial<Options>): void {
if (!o) return
Apply(this.options, o, String, 'magnifyOption')
if (o.tabs) {
this.options.tabs = o.tabs
}