• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / deck.gl / 13478198223

23 Feb 2025 01:02AM UTC coverage: 91.55% (-0.06%) from 91.607%
13478198223

push

github

web-flow
feat(widgets) New ScreenshotWidget (#9454)

Co-authored-by: Chris Gervang <chris@gervang.com>

6693 of 7329 branches covered (91.32%)

Branch coverage included in aggregate %.

49 of 95 new or added lines in 2 files covered. (51.58%)

54161 of 59142 relevant lines covered (91.58%)

14841.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.31
/modules/widgets/src/widget-impl.ts
1
// deck.gl
1✔
2
// SPDX-License-Identifier: MIT
1✔
3
// Copyright (c) vis.gl contributors
1✔
4

1✔
5
/* global document */
1✔
6
import {_deepEqual, _applyStyles, _removeStyles} from '@deck.gl/core';
1✔
7
import type {Deck, Widget} from '@deck.gl/core';
1✔
8

1✔
9
export type WidgetImplProps = {
1✔
10
  id?: string;
1✔
11
  /** CSS inline style overrides. */
1✔
12
  style?: Partial<CSSStyleDeclaration>;
1✔
13
  /** Additional CSS class. */
1✔
14
  className?: string;
1✔
15
};
1✔
16
export abstract class WidgetImpl<PropsT extends WidgetImplProps> implements Widget<PropsT> {
1✔
17
  id: string;
1✔
18
  props: Required<PropsT>;
1✔
19

1✔
20
  deck?: Deck<any>;
1✔
21
  element?: HTMLDivElement;
1✔
22

1✔
23
  static defaultProps: Required<WidgetImplProps> = {
1✔
24
    id: 'widget',
1✔
25
    style: {},
1✔
26
    className: ''
1✔
27
  };
1✔
28

1✔
29
  abstract className: Required<string>;
1✔
30

1✔
31
  constructor(props: Required<PropsT>) {
1✔
NEW
32
    this.id = props.id || 'widget';
×
NEW
33
    this.props = props;
×
NEW
34
  }
×
35

1✔
36
  abstract onRenderHTML(): void;
1✔
37

1✔
38
  onAdd({deck}: {deck: Deck<any>}): HTMLDivElement {
1✔
NEW
39
    this.deck = deck;
×
NEW
40
    const {style, className} = this.props;
×
NEW
41
    const el = this._createRootElement({
×
NEW
42
      widgetClassName: this.className,
×
NEW
43
      className,
×
NEW
44
      style
×
NEW
45
    });
×
NEW
46
    this.element = el;
×
NEW
47
    this.onRenderHTML();
×
NEW
48
    return this.element;
×
NEW
49
  }
×
50

1✔
51
  onRemove() {
1✔
NEW
52
    this.deck = undefined;
×
NEW
53
    this.element = undefined;
×
NEW
54
  }
×
55

1✔
56
  setProps(props: Partial<PropsT>) {
1✔
NEW
57
    const oldProps = this.props;
×
NEW
58
    const el = this.element;
×
NEW
59
    if (el) {
×
NEW
60
      if (oldProps.className !== props.className) {
×
NEW
61
        if (oldProps.className) el.classList.remove(oldProps.className);
×
NEW
62
        if (props.className) el.classList.add(props.className);
×
NEW
63
      }
×
NEW
64

×
NEW
65
      if (!_deepEqual(oldProps.style, props.style, 1)) {
×
NEW
66
        _removeStyles(el, oldProps.style);
×
NEW
67
        _applyStyles(el, props.style);
×
NEW
68
      }
×
NEW
69
    }
×
NEW
70

×
NEW
71
    Object.assign(this.props, props);
×
NEW
72
    this.onRenderHTML();
×
NEW
73
  }
×
74

1✔
75
  _createRootElement(props: {
1✔
NEW
76
    widgetClassName: string;
×
NEW
77
    className?: string;
×
NEW
78
    style?: Partial<CSSStyleDeclaration>;
×
NEW
79
  }) {
×
NEW
80
    const {widgetClassName, className, style} = props;
×
NEW
81
    const element = document.createElement('div');
×
NEW
82
    ['deck-widget', widgetClassName, className]
×
NEW
83
      .filter((cls): cls is string => typeof cls === 'string' && cls.length > 0)
×
NEW
84
      .forEach(className => element.classList.add(className));
×
NEW
85
    _applyStyles(element, style);
×
NEW
86
    return element;
×
NEW
87
  }
×
88
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc