From 05761eec9ca1834e44b0c42470d353a3a6391580 Mon Sep 17 00:00:00 2001 From: Chris Gervang Date: Thu, 19 Dec 2024 17:17:35 -0800 Subject: [PATCH 1/2] chore(widgets) copy props and use nullish coalescing operator --- modules/widgets/src/compass-widget.tsx | 19 +++++++++++-------- modules/widgets/src/fullscreen-widget.tsx | 15 +++++++++------ modules/widgets/src/zoom-widget.tsx | 21 ++++++++++++--------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/modules/widgets/src/compass-widget.tsx b/modules/widgets/src/compass-widget.tsx index c61fb70fad8..d3510279306 100644 --- a/modules/widgets/src/compass-widget.tsx +++ b/modules/widgets/src/compass-widget.tsx @@ -49,13 +49,16 @@ export class CompassWidget implements Widget { element?: HTMLDivElement; constructor(props: CompassWidgetProps) { - this.id = props.id || 'compass'; - this.viewId = props.viewId || null; - this.placement = props.placement || 'top-left'; - props.transitionDuration = props.transitionDuration || 200; - props.label = props.label || 'Compass'; - props.style = props.style || {}; - this.props = props; + this.id = props.id ?? this.id; + this.viewId = props.viewId ?? this.viewId; + this.placement = props.placement ?? this.placement; + + this.props = { + ...props, + transitionDuration: props.transitionDuration ?? 200, + label: props.label ?? 'Reset Compass', + style: props.style ?? {} + }; } setProps(props: Partial) { @@ -119,7 +122,7 @@ export class CompassWidget implements Widget { this.handleCompassReset(viewport); } }} - label={this.props.label} + title={this.props.label} style={{transform: `rotateX(${rx}deg)`}} > diff --git a/modules/widgets/src/fullscreen-widget.tsx b/modules/widgets/src/fullscreen-widget.tsx index 3c149f0c1a3..48b33d8ff9b 100644 --- a/modules/widgets/src/fullscreen-widget.tsx +++ b/modules/widgets/src/fullscreen-widget.tsx @@ -50,12 +50,15 @@ export class FullscreenWidget implements Widget { fullscreen: boolean = false; constructor(props: FullscreenWidgetProps) { - this.id = props.id || 'fullscreen'; - this.placement = props.placement || 'top-left'; - props.enterLabel = props.enterLabel || 'Enter Fullscreen'; - props.exitLabel = props.exitLabel || 'Exit Fullscreen'; - props.style = props.style || {}; - this.props = props; + this.id = props.id ?? this.id; + this.placement = props.placement ?? this.placement; + + this.props = { + ...props, + enterLabel: props.enterLabel ?? 'Enter Fullscreen', + exitLabel: props.exitLabel ?? 'Exit Fullscreen', + style: props.style ?? {} + }; } onAdd({deck}: {deck: Deck}): HTMLDivElement { diff --git a/modules/widgets/src/zoom-widget.tsx b/modules/widgets/src/zoom-widget.tsx index 28f022db749..3fa7527ebac 100644 --- a/modules/widgets/src/zoom-widget.tsx +++ b/modules/widgets/src/zoom-widget.tsx @@ -57,15 +57,18 @@ export class ZoomWidget implements Widget { element?: HTMLDivElement; constructor(props: ZoomWidgetProps) { - this.id = props.id || 'zoom'; - this.viewId = props.viewId || null; - this.placement = props.placement || 'top-left'; - this.orientation = props.orientation || 'vertical'; - props.transitionDuration = props.transitionDuration || 200; - props.zoomInLabel = props.zoomInLabel || 'Zoom In'; - props.zoomOutLabel = props.zoomOutLabel || 'Zoom Out'; - props.style = props.style || {}; - this.props = props; + this.id = props.id ?? this.id; + this.viewId = props.viewId ?? this.viewId; + this.placement = props.placement ?? this.placement; + this.orientation = props.orientation ?? this.orientation; + + this.props = { + ...props, + transitionDuration: props.transitionDuration ?? 200, + zoomInLabel: props.zoomInLabel ?? 'Zoom In', + zoomOutLabel: props.zoomOutLabel ?? 'Zoom Out', + style: props.style ?? {} + }; } onAdd({deck}: {deck: Deck}): HTMLDivElement { From f2c55efb5660aca069cb3f41829b6f31311abe17 Mon Sep 17 00:00:00 2001 From: Chris Gervang Date: Sun, 22 Dec 2024 11:55:00 -0800 Subject: [PATCH 2/2] Update zoom-widget.tsx --- modules/widgets/src/zoom-widget.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/widgets/src/zoom-widget.tsx b/modules/widgets/src/zoom-widget.tsx index 7d03c2adb59..58bb34548a9 100644 --- a/modules/widgets/src/zoom-widget.tsx +++ b/modules/widgets/src/zoom-widget.tsx @@ -62,7 +62,7 @@ export class ZoomWidget implements Widget { this.props = { ...props, - orientation: props.orientation ?? this.orientation, + orientation: props.orientation ?? 'vertical', transitionDuration: props.transitionDuration ?? 200, zoomInLabel: props.zoomInLabel ?? 'Zoom In', zoomOutLabel: props.zoomOutLabel ?? 'Zoom Out',