grommet / grommet-leaflet

Example of using leafletjs.org maps with react and grommet
ISC License
1 stars 1 forks source link

Complete action items from `grommet-leaflet-core` review #33

Closed taysea closed 1 year ago

taysea commented 1 year ago

Based on initial review of grommet-leaflet-core, the following action items remain:

Deliverables might include:

jcfilben commented 1 year ago

Accessibility notes: (tested in voiceover)

Leaflet's accessibility guide: https://leafletjs.com/examples/accessibility/

Taylor's additions:

Reading through this and given some limitations may be on the leaflet side. My suggestions would be:

jcfilben commented 1 year ago

Cluster theming: Size should be specified outside of kind. This allows for generic sizes that can be used across kinds. Any props defined in a kind will take precedence over the size props. This structure gives us flexibility if down the road we need to support size within kind.

Theme structure:

cluster: {
  default: {
    // this is a kind of cluster
    container: {
      // any box props, will take precedence over box props defined in size
    }
  }
  size: {
    small: {
      container: {
        // any box props
      }
      label: {
        // any text props
      }
    }
  }
}
taysea commented 1 year ago

Capturing a discussion Jessica and I had offline re: theme structure: Should kind objects be nested under another level called kind?

This is different than grommet theme.button. However, the rationale would be that a top-level theme object would refer to a property on a component. Then, the nested objects would align with accepted values for that property.

For example:

cluster: {
   kind: {
      critical: ...
   },
...
}

<Cluster kind="critical" />

Not a strong opinion one way, but wanted to voice it before we publish and commit to a theme structure.

taysea commented 1 year ago

Customizing popup pad and other leaflet popup props

After digging into this, Jessica and I realized that beyond allowing the caller to pass custom box props to their Popup container, we should also support the ability for callers to pass accepted options for leaflet's popup (in terms of grommet-leaflet truly being an extension of leaflet and not to opinionated).

Some ideas we had were to:

  1. Embed react-leaflet's "Popup" inside our "Popup" component. Then, similar to react-leaflet's implementation, callers would need to wrap their popup content in a Popup wrapper that accepted any react-leaflet Popup props plus boxProps which would style the Popup container.
Popup.jsx

const Popup = ({ boxProps, children ...rest}) => {
   return (
      <LeafletPopup {...rest}>
         <Box {...theme.popup} {...boxProps}>
            {children}
         </Box>
     </LeafletPopup>
}

Then the caller's implementation would be something like

<Marker>
   <Popup autoClose={false} boxProps={{ pad: 'medium' }}>
      <MyPopupContent>
   </Popup>
</Marker>

This approach worked for the Markers but did not work for the Clusters which are using ReactDOMServer.renderToString. An error that LeafletPopup can't be used outside of MapContainer is thrown.

So we will need to think on other approaches and what the API surface should like.

jcfilben commented 1 year ago

I created two follow on tickets for the accessibility and popup work. https://github.com/grommet/grommet-leaflet/issues/44 https://github.com/grommet/grommet-leaflet/issues/45