Skip to content

Conversation

@pappkartoni
Copy link
Collaborator

Using dedicated components for the Places UI Kit components
see #878

@pappkartoni pappkartoni changed the title chore(docs): refacto places-ui-kit example into dedicated components for UI Kit elements chore(docs): refactor places-ui-kit example into dedicated components for UI Kit elements Dec 16, 2025
@pappkartoni pappkartoni marked this pull request as ready for review December 17, 2025 14:42
Copy link
Collaborator

@usefulthink usefulthink left a comment

Choose a reason for hiding this comment

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

Awesome, thanks. Thats exactly the style of API I would imagine for the places ui kit components. A couple of smaller remarks in the code.

@@ -0,0 +1,193 @@
import React, {FunctionComponent, useEffect, useRef} from 'react';

export const ContentConfig = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

To me, the name ContentConfig implies it's the configuration itself, but this seems to be more like a config-preset, or a predefined configuration name.

| DefaultContentItem;

export type PlaceContentConfigProps = {
contentConfig: ContentConfig;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be named preset or similar.

* Required only if type is 'custom'.
* The array lists the content elements to display.
*/
customContent?: Array<ContentItem>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of customContent, this could be called contentItems. And I think it would be better to simplify this a bit. So instead of

customContent={[
  {attribute: 'foo'},
  {attribute: 'bar'},
  {attribute: 'baz', additional: 123}
]}

that would be:

customContent={[
  'foo',
  'bar',
  {type: 'baz',  additional: 123},
]}

So essentially, convert PlaceDetailsContentItem into an enum-like type (like ContentConfig above) for the child-elements without extra options and for those with options, a simple object with type + options. An alternative might be using an array like ['baz', {additional: 123}] for the configuration with options, but I'm not sure if I like that more...

Comment on lines 172 to 176
case ContentConfig.STANDARD:
return <gmp-place-standard-content />;
case ContentConfig.ALL:
return <gmp-place-all-content />;
case ContentConfig.CUSTOM:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the last case can be left away, we should use defaults for the props if possible (so without any props it would be the 'standard' preset). For the custom preset, we can just check if content items are specified.

Comment on lines 48 to 57
/**
* Content config. Defaults to 'standard'
*/
contentConfig: ContentConfig;
/**
* Required only if type is 'custom'.
* The array lists the content elements to display.
*/
customContent?: Array<ContentItem>;

Copy link
Collaborator

@usefulthink usefulthink Jan 23, 2026

Choose a reason for hiding this comment

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

see my remarks in place-content-config.tsx.

useState
} from 'react';
import {createPortal} from 'react-dom';
import {usePropBinding} from '../../../../src/hooks/use-prop-binding';
Copy link
Collaborator

Choose a reason for hiding this comment

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

this could cause problems should someone try to run this example standalone. I think it's better to copy those hooks into the example directory (maybe just like utility-hooks.ts, should be just a couple of lines without further dependencies). We’ll remove them again when the components get merged into the main library.

@usefulthink
Copy link
Collaborator

One more thing, the components can in part be styled using css-variables, should we provide an interface for those as well, so users can style them using className and style={{'--whatever-css-prop': 'value'}} or do we leave that for an external stylesheet of some sort?

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.

2 participants