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(examples): react widgets get started #8889

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

chrisgervang
Copy link
Collaborator

Supports #8877

Change List

  • Add a react get-started example for widgets

Signed-off-by: Chris Gervang <chris@gervang.com>
@coveralls
Copy link

Coverage Status

coverage: 89.821%. remained the same
when pulling a29515c on chr/react-widgets-get-started
into b5a6313 on master.

new FullscreenWidget({style: widgetTheme})
]}
>
<GeoJsonLayer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated: should we move get-started to TypeScript? Maybe pure-js can be reserved for JS examples, but react projects are more likely to be using bundlers/plugins/dev frameworks that already support TS.

It's known that JSX layers do not work with TS, though

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the fiber renderer works with TSX? visgl/deck.gl-community#35

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a value in using JSX layers when the stars of the show, the Widgets, are not expressed as JSX?

Copy link
Collaborator Author

@chrisgervang chrisgervang Aug 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This got me thinking, if I'm writing a react app and making a custom widget then I'd probably like to write a widget in react. I think we could show how React Portals offer a pretty seamless interface for this.

import '@deck.gl/widgets/stylesheet.css';

/* global window */
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I wasn't aware that there was a standardized way to query for dark mode. Seems like something that could be built into the widget theming system as a default? PreferredTheme or something like that? Though maybe it is better for exposition to show it here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the exposition here since apps implement their themes in so many different ways. Maybe they don't want the "Glass" version, maybe they let the user override theme in a setting, etc..

new FullscreenWidget({style: widgetTheme})
]}
>
<GeoJsonLayer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a value in using JSX layers when the stars of the show, the Widgets, are not expressed as JSX?

@coveralls
Copy link

coveralls commented Jul 30, 2024

Coverage Status

coverage: 89.207%. remained the same
when pulling 59c48df on chr/react-widgets-get-started
into 5a90f5f on master.

Signed-off-by: Chris Gervang <chris@gervang.com>
Signed-off-by: Chris Gervang <chris@gervang.com>
Signed-off-by: Chris Gervang <chris@gervang.com>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pessimistress if this too complex for get-started then maybe I can write a custom widget developer guide. I think it'd be common for a react user to want to implement their own widget, and we could document a basic pattern they could use.

Signed-off-by: Chris Gervang <chris@gervang.com>
Signed-off-by: Chris Gervang <chris@gervang.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants