Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Zoom and Compass widgets #8072

Merged
merged 49 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fc6be2c
add(deck) _widget prop
chrisgervang Jul 25, 2023
cd67293
add(widgets) fullscreen widget scaffold
chrisgervang Jul 25, 2023
18835f1
Update modules/widgets/src/fullscreen-widget.ts
chrisgervang Jul 27, 2023
2fa64ad
Update modules/widgets/src/fullscreen-widget.ts
chrisgervang Jul 27, 2023
fceab53
add(deck) _widget prop
chrisgervang Jul 25, 2023
bfa10b6
declarative widgets api
Pessimistress Aug 3, 2023
adfc21a
Add comments
Pessimistress Aug 4, 2023
46be41a
fix test
Pessimistress Aug 4, 2023
f37b35e
simplify widget api
Pessimistress Aug 4, 2023
024d1bc
docs
chrisgervang Aug 8, 2023
3caa7e8
Merge branch 'master' into chr/deck-widgets-prop
chrisgervang Aug 8, 2023
e07fd97
Merge branch 'chr/deck-widgets-prop' into chr/fullscreen-widget
chrisgervang Aug 8, 2023
debbf1e
add(core) export types
chrisgervang Aug 8, 2023
f43cfdd
Merge branch 'chr/deck-widgets-prop' into chr/fullscreen-widget
chrisgervang Aug 8, 2023
ed185ff
add(examples) widgets example
chrisgervang Aug 15, 2023
f135eca
add(widgets) build with preact jsx
chrisgervang Aug 16, 2023
a5cd7b4
add(widget) fullscreen button + styles
chrisgervang Aug 16, 2023
efd612e
add(widget) fullscreen optional container
chrisgervang Aug 16, 2023
2f31eca
add(widget) theming with CSS variables
chrisgervang Aug 17, 2023
004c0aa
Merge branch 'master' into chr/fullscreen-widget
chrisgervang Aug 17, 2023
e02624b
add(widget) applications set theme
chrisgervang Aug 17, 2023
a87c7f9
comments
chrisgervang Aug 21, 2023
ee7a365
spell out widget
chrisgervang Aug 21, 2023
bda7bcd
add(widget) built-in themes
chrisgervang Aug 21, 2023
f9cc7ab
add(widget) add className prop
chrisgervang Aug 22, 2023
8df067a
add(widget) fullscreen and theme docs
chrisgervang Aug 22, 2023
a7aabfe
cleanup
chrisgervang Aug 22, 2023
5e2dac1
Adding Zoom widget
ilyabo Aug 22, 2023
c1e2a13
PR feedback
ilyabo Aug 22, 2023
9577fd3
Button group styling
ilyabo Aug 22, 2023
4e900fe
Adding compass widget
ilyabo Aug 28, 2023
4e3753d
Adding globe viewport rotation
ilyabo Sep 7, 2023
24ce65d
style and className support modifications
chrisgervang Sep 9, 2023
4791fb8
icons, icon variables, onfullscreen handler, pseudo-fullscreen
chrisgervang Sep 9, 2023
a6f6268
docs and style examples
chrisgervang Sep 9, 2023
24bf325
comments
chrisgervang Sep 9, 2023
73afafd
Merge branch 'master' into chr/fullscreen-widget
chrisgervang Sep 9, 2023
61d2f55
types
chrisgervang Sep 9, 2023
61eeaf4
Merge fullscreen widget
ilyabo Sep 12, 2023
33dd198
Merge branch 'master' into ilya/zoom-widget
chrisgervang Mar 16, 2024
92c861d
chore(widgets) fix widgets after merge
chrisgervang Mar 16, 2024
d420e9d
add(widgets) zoom icons and horizontal option
chrisgervang Mar 18, 2024
0767d0d
add(widgets) compass icon, button group component
chrisgervang Mar 19, 2024
54f8ce7
chore(widgets) revert eslint
chrisgervang Mar 19, 2024
25c7bde
Merge branch 'master' into ilya/zoom-widget
chrisgervang Mar 19, 2024
85ef942
add(widgets) test app and simpler getting started
chrisgervang Mar 19, 2024
942be8f
comment
chrisgervang Mar 19, 2024
c4a395f
add(widgets) compass and zoom docs
chrisgervang Mar 19, 2024
6f2d415
add(widgets) compass icon color vars
chrisgervang Mar 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions docs/api-reference/widgets/compass-widget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# CompassWidget

This widget visualizes bearing and pitch. Click it once to reset bearing to 0, click it a second time to reset pitch to 0. Supports Map and Globe view.

## Props

### `id` (String) {#id}

Default: `'fullscreen'`

Unique identifier of the widget.

### `viewId` (String, optional) {#viewid}

Default: `null`

The widget is attached to the view identified by this `viewId`. When assigned, the widget is placed within the specified view, and exclusively interacts with it. Required when using [multiple views](../../developer-guide/views.md#using-multiple-views).

### `placement` (String, optional) {#placement}

Default: `'top-left'`

Widget position within the view relative to the map container. Valid options are `top-left`, `top-right`, `bottom-left`, `bottom-right`, or `fill`.

### `label` (String, optional) {#label}

Tooltip message displayed while hovering a mouse over the widget.

Default: `'Compass'`

### `transitionDuration` (Number, optional) {#transitionduration}

Default: `200`

Bearing and pitch reset transition duration in milliseconds.

### `style` (Object, optional) {#style}

Default: `{}`

Additional CSS styles for the canvas.

### `className` (String, optional) {#classname}

Default: `undefined`

Class name to attach to the widget element. The element has the default class name of `deck-widget deck-fullscreen-widget`.
8 changes: 5 additions & 3 deletions docs/api-reference/widgets/fullscreen-widget.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# FullscreenWidget

This widget enlarges deck.gl to fill the full screen. Click the widget to enter or exit full screen.

## Props

### `id` (String) {#id}
Expand All @@ -12,7 +14,7 @@ Unique identifier of the widget.

Default: `'top-left'`

Widget position within the view relatitive to the map container. Valid options are `top-left`, `top-right`, `bottom-left`, `bottom-right`, or `fill`.
Widget position within the view relative to the map container. Valid options are `top-left`, `top-right`, `bottom-left`, `bottom-right`, or `fill`.

### `container` (HTMLElement, optional) {#container}

Expand All @@ -22,13 +24,13 @@ A [compatible DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Elem

### `enterLabel` (String, optional) {#enterlabel}

Toolip message displayed while hovering a mouse over the widget when out of fullscreen.
Tooltip message displayed while hovering a mouse over the widget when out of fullscreen.

Default: `'Enter Fullscreen'`

### `exitLabel` (String, optional) {#exitlabel}

Toolip message displayed while hovering a mouse over the widget when fullscreen.
Tooltip message displayed while hovering a mouse over the widget when fullscreen.

Default: `'Exit Fullscreen'`

Expand Down
15 changes: 11 additions & 4 deletions docs/api-reference/widgets/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Widgets are UI components around the WebGL2/WebGPU canvas to offer controls and
This module contains the following extensions:

- [FullscreenWidget](./fullscreen-widget.md)
- [ZoomWidget](./zoom-widget.md)
- [CompassWidget](./compass-widget.md)


## Installation

Expand Down Expand Up @@ -44,7 +47,7 @@ Customizing the appearance of widgets can be achieved using CSS variables. This

### Global Theming

Apply to all wigdets with the `.deck-widget` selector.
Apply to all widgets with the `.deck-widget` selector.

```css
.deck-widget {
Expand Down Expand Up @@ -94,7 +97,7 @@ We've provided a set of CSS variables to make styling UI Widgets more convenient
| Name | Type | Default |
| ---- | ---- | ------- |
| `--button-size` | [Dimension](https://developer.mozilla.org/en-US/docs/Web/CSS/dimension) | `28px` |
| `--button-border-radius` | [Dimension](https://developer.mozilla.org/en-US/docs/Web/CSS/dimension) | `12px` |
| `--button-border-radius` | [Dimension](https://developer.mozilla.org/en-US/docs/Web/CSS/dimension) | `8px` |
| `--widget-margin` | [Dimension](https://developer.mozilla.org/en-US/docs/Web/CSS/dimension) | `12px` |

### Color
Expand All @@ -106,14 +109,18 @@ We've provided a set of CSS variables to make styling UI Widgets more convenient
| `--button-inner-stroke` | [Border](https://developer.mozilla.org/en-US/docs/Web/CSS/border) | `unset` |
| `--button-shadow` | [Box Shadow](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow) | `0px 0px 8px 0px rgba(0, 0, 0, 0.25)` |
| `--button-backdrop-filter` | [Backdrop Filter](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter) | `unset` |
| `--button-icon-idle` | [Color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) | `rgba(97, 97, 102, 1)`
| `--button-icon-hover` | [Color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) | `rgba(24, 24, 26, 1)`
| `--button-icon-idle` | [Color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) | `rgba(97, 97, 102, 1)` |
| `--button-icon-hover` | [Color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) | `rgba(24, 24, 26, 1)` |
| `--icon-compass-north-color` | [Color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) | `#F05C44` |
| `--icon-compass-south-color` | [Color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) | `#C2C2CC` |

### Icon
| Name | Type | Default |
| ---- | ---- | ------- |
| `--icon-fullscreen-enter` | [SVG Data Url](https://developer.mozilla.org/en-US/docs/Web/CSS/url#using_a_data_url) | [Material Symbol Fullscreen](https://fonts.google.com/icons?selected=Material+Symbols+Rounded:fullscreen:FILL@0;wght@400;GRAD@0;opsz@40) |
| `--icon-fullscreen-enter` | [SVG Data Url](https://developer.mozilla.org/en-US/docs/Web/CSS/url#using_a_data_url) | [Material Symbol Fullscreen Exit](https://fonts.google.com/icons?selected=Material+Symbols+Rounded:fullscreen_exit:FILL@0;wght@400;GRAD@0;opsz@40) |
| `--icon-zoom-in` | [SVG Data Url](https://developer.mozilla.org/en-US/docs/Web/CSS/url#using_a_data_url) | [Material Symbol Add](https://fonts.google.com/icons?selected=Material+Symbols+Rounded:add:FILL@0;wght@600;GRAD@0;opsz@40) |
| `--icon-zoom-out` | [SVG Data Url](https://developer.mozilla.org/en-US/docs/Web/CSS/url#using_a_data_url) | [Material Symbol Remove](https://fonts.google.com/icons?selected=Material+Symbols+Rounded:remove:FILL@0;wght@600;GRAD@0;opsz@40) |

#### Replacing Icons

Expand Down
65 changes: 65 additions & 0 deletions docs/api-reference/widgets/zoom-widget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# ZoomWidget

This widget controls the zoom level of a deck.gl view. Click '+' to zoom in by 1, click '-' to zoom out by 1. Supports controlling Map and Globe views.

## Props

### `id` (String) {#id}

Default: `'zoom'`

Unique identifier of the widget.

### `viewId` (String, optional) {#viewid}

Default: `null`

The widget is attached to the view identified by this `viewId`. When assigned, the widget is placed within the specified view, and exclusively interacts with it. Required when using [multiple views](../../developer-guide/views.md#using-multiple-views).

### `placement` (String, optional) {#placement}

Default: `'top-left'`

Widget position within the view relative to the map container. Valid options are `top-left`, `top-right`, `bottom-left`, `bottom-right`, or `fill`.

### `orientation` (String, optional) {#orientation}

Default: `'vertical'`

Widget button orientation. Valid options are `vertical` or `horizontal`.

### `container` (HTMLElement, optional) {#container}

Default: `undefined`

A [compatible DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Compatible_elements) which should be made full screen. By default, the map container element will be made full screen.

### `zoomInLabel` (String, optional) {#zoominlabel}

Tooltip message displayed while hovering a mouse over the zoom in button.

Default: `'Zoom In'`

### `zoomOutLabel` (String, optional) {#zoomoutlabel}

Tooltip message displayed while hovering a mouse over the zoom out button.

Default: `'Zoom Out'`

### `transitionDuration` (Number, optional) {#transitionduration}

Default: `200`

Zoom transition duration in milliseconds.

### `style` (Object, optional) {#style}

Default: `{}`

Additional CSS styles for the canvas.

### `className` (String, optional) {#classname}

Default: `undefined`

Class name to attach to the widget element. The element has the default class name of `deck-widget deck-fullscreen-widget`.
14 changes: 10 additions & 4 deletions examples/get-started/pure-js/widgets/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import {Deck} from '@deck.gl/core';
import {GeoJsonLayer, ArcLayer} from '@deck.gl/layers';
import {FullscreenWidget, DarkGlassTheme, LightGlassTheme} from '@deck.gl/widgets';
import {
CompassWidget,
ZoomWidget,
FullscreenWidget,
DarkGlassTheme,
LightGlassTheme
} from '@deck.gl/widgets';
import '@deck.gl/widgets/stylesheet.css';

const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)");
Expand Down Expand Up @@ -64,8 +70,8 @@ new Deck({
})
],
widgets: [
new FullscreenWidget({}),
new FullscreenWidget({id: 'themed', style: widgetTheme}),
new FullscreenWidget({id: 'purple', className: 'purple'})
new ZoomWidget({style: widgetTheme}),
new CompassWidget({style: widgetTheme}),
new FullscreenWidget({style: widgetTheme})
]
});
15 changes: 0 additions & 15 deletions examples/get-started/pure-js/widgets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@
<title>deck.gl Example</title>
<style>
body {margin: 0; width: 100vw; height: 100vh; overflow: hidden;}

@media screen and (max-width: 600px) {
.deck-widget {
/* mobile */
--button-size: 48px;
--button-corner-radius: 12px;
}
}

.purple {
--button-background: hsl(240, 40%, 40%);
--button-stroke: hsla(240, 40%, 40%, 0.3);
--button-icon-hover: rgb(236, 236, 236);
--button-icon-idle: rgb(174, 174, 202);
}
</style>
</head>
<body></body>
Expand Down
6 changes: 3 additions & 3 deletions examples/get-started/pure-js/widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"build": "vite build"
},
"dependencies": {
"@deck.gl/core": "^9.0.0-beta.2",
"@deck.gl/layers": "^9.0.0-beta.2",
"@deck.gl/widgets": "^9.0.0-beta.2"
"@deck.gl/core": "^9.0.0-beta",
"@deck.gl/layers": "^9.0.0-beta",
"@deck.gl/widgets": "^9.0.0-beta"
},
"devDependencies": {
"vite": "^4.0.0"
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/lib/widget-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface Widget<PropsT = any> {
props: PropsT;
/**
* The view id that this widget is being attached to. Default `null`.
* If assigned, this widget will only respond to events occured inside the specific view that matches this id.
* If assigned, this widget will only respond to events occurred inside the specific view that matches this id.
*/
viewId?: string | null;
/** Widget positioning within the view. Default 'top-left'. */
Expand Down
Loading
Loading