Skip to content

Commit e3533e0

Browse files
chore(widgets) props should be types rather than interfaces (#9333)
* chore(widgets) props should be types rather than interfaces * exports types in main Co-authored-by: felixpalmer <felixpalmer@gmail.com> --------- Co-authored-by: felixpalmer <felixpalmer@gmail.com>
1 parent 401416f commit e3533e0

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

docs/api-reference/core/widget.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You may find many ready-to-use widgets in the `@deck.gl/widgets` module.
1212
A widget is expected to implement the `Widget` interface. Here is a custom widget that shows a spinner while layers are loading:
1313

1414
```ts
15-
import {Widget} from '@deck.gl/core';
15+
import {Deck, Widget} from '@deck.gl/core';
1616

1717
class LoadingIndicator implements Widget {
1818
element?: HTMLDivElement;
@@ -39,12 +39,14 @@ class LoadingIndicator implements Widget {
3939
}
4040
}
4141

42-
deckgl.addWidget(new LoadingIndicator({size: 48}));
42+
new Deck({
43+
widgets: [new LoadingIndicator({size: 48})]
44+
});
4345
```
4446

4547
## Widget Interface
4648

47-
When a widget instance is added to Deck, the user can optionally specify a `viewId` that it is attached to (default `null`). If assigned, this widget will only respond to events occured inside the specific view that matches this id.
49+
When a widget instance is added to Deck, the user can optionally specify a `viewId` that it is attached to (default `null`). If assigned, this widget will only respond to events occurred inside the specific view that matches this id.
4850

4951
### Members
5052

docs/api-reference/widgets/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ new FullscreenWidget({});
3030

3131
```html
3232
<script src="https://unpkg.com/deck.gl@^9.0.0/dist.min.js"></script>
33-
<link src="https://unpkg.com/deck.gl@^9.0.0/dist/stylesheet.css" rel='stylesheet' />
33+
<link href="https://unpkg.com/deck.gl@^9.0.0/dist/stylesheet.css" rel='stylesheet' />
3434
<!-- or -->
3535
<script src="https://unpkg.com/@deck.gl/core@^9.0.0/dist.min.js"></script>
3636
<script src="https://unpkg.com/@deck.gl/widgets@^9.0.0/dist.min.js"></script>
37-
<link src="https://unpkg.com/@deck.gl/widgets@^9.0.0/dist/stylesheet.css" rel='stylesheet' />
37+
<link href="https://unpkg.com/@deck.gl/widgets@^9.0.0/dist/stylesheet.css" rel='stylesheet' />
3838
```
3939

4040
```js

modules/main/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,5 @@ export type {
195195
export type {MVTLayerProps, QuadkeyLayerProps, TileLayerProps} from '@deck.gl/geo-layers';
196196

197197
export type {DeckGLProps, DeckGLRef, DeckGLContextValue} from '@deck.gl/react';
198+
199+
export type {FullscreenWidgetProps, ZoomWidgetProps, CompassWidgetProps} from '@deck.gl/widgets';

modules/widgets/src/compass-widget.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ import {
1414
import type {Deck, Viewport, Widget, WidgetPlacement} from '@deck.gl/core';
1515
import {render} from 'preact';
1616

17-
interface CompassWidgetProps {
17+
export type CompassWidgetProps = {
1818
id?: string;
19+
/**
20+
* Widget positioning within the view. Default 'top-left'.
21+
*/
1922
placement?: WidgetPlacement;
2023
/**
2124
* View to attach to and interact with. Required when using multiple views.
@@ -37,7 +40,7 @@ interface CompassWidgetProps {
3740
* Additional CSS class.
3841
*/
3942
className?: string;
40-
}
43+
};
4144

4245
export class CompassWidget implements Widget<CompassWidgetProps> {
4346
id = 'compass';

modules/widgets/src/fullscreen-widget.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ import type {Deck, Widget, WidgetPlacement} from '@deck.gl/core';
1212
import {render} from 'preact';
1313
import {IconButton} from './components';
1414

15-
interface FullscreenWidgetProps {
15+
export type FullscreenWidgetProps = {
1616
id?: string;
17+
/**
18+
* Widget positioning within the view. Default 'top-left'.
19+
*/
1720
placement?: WidgetPlacement;
1821
/**
1922
* A [compatible DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Compatible_elements) which should be made full screen.
@@ -37,7 +40,7 @@ interface FullscreenWidgetProps {
3740
* Additional CSS class.
3841
*/
3942
className?: string;
40-
}
43+
};
4144

4245
export class FullscreenWidget implements Widget<FullscreenWidgetProps> {
4346
id = 'fullscreen';

modules/widgets/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ export {FullscreenWidget} from './fullscreen-widget';
66
export {CompassWidget} from './compass-widget';
77
export {ZoomWidget} from './zoom-widget';
88

9+
export type {FullscreenWidgetProps} from './fullscreen-widget';
10+
export type {CompassWidgetProps} from './compass-widget';
11+
export type {ZoomWidgetProps} from './zoom-widget';
12+
913
export * from './themes';

modules/widgets/src/zoom-widget.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ import type {Deck, Viewport, Widget, WidgetPlacement} from '@deck.gl/core';
1313
import {render} from 'preact';
1414
import {ButtonGroup, GroupedIconButton} from './components';
1515

16-
interface ZoomWidgetProps {
16+
export type ZoomWidgetProps = {
1717
id?: string;
18+
/**
19+
* Widget positioning within the view. Default 'top-left'.
20+
*/
1821
placement?: WidgetPlacement;
1922
/**
2023
* View to attach to and interact with. Required when using multiple views.
@@ -44,7 +47,7 @@ interface ZoomWidgetProps {
4447
* Additional CSS class.
4548
*/
4649
className?: string;
47-
}
50+
};
4851

4952
export class ZoomWidget implements Widget<ZoomWidgetProps> {
5053
id = 'zoom';

0 commit comments

Comments
 (0)