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

Introduces MapProvider, mappify and MapComponent #195

Merged
merged 8 commits into from Nov 9, 2017

Conversation

KaiVolland
Copy link
Member

This introduces the HOCs MapProvider the MappifiedComponent (mappify) and the MapComponent.

Short explanation:

  • The MapProvider adds a map to the context of the application.
  • The mappfiy function grabs the map from the context and adds it as prop to the according component.
  • The MapComponent just returns a div containing an OlMap.

It also includes an example of how to use these three new Components together.

We should check/modify our examples and tests to make use of the MapProvider.

Thx @dnlkoch and @ahennr for your support.

Copy link
Member

@marcjansen marcjansen left a comment

Choose a reason for hiding this comment

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

Very nice, everyone. Only minor questions... and if possibke add tests. Feel free to merge once the docs are right / tests are included.

*/
static propTypes = {
/**
* The children of this group. Typically a set of `ToggleButton`s.
Copy link
Member

Choose a reason for hiding this comment

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

docs are copy and pasted, I guess

*/
map: PropTypes.oneOfType([
PropTypes.instanceOf(OlMap),
PropTypes.func
Copy link
Member

Choose a reason for hiding this comment

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

I assume there is no way of actually telling apart any func from a true Promise, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe if we fix your following comment.

ready: true
});
} else {
props.map().then((map) => {
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, surprised aboit the invocation of map here. or are we expecting a function that returns a Promise? This might be me not understanding Promises... if so just ignore this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently yes. But this makes no sense at all... I gonna check this.

*
* Wrapped components will be checked against the activeModules array of
* the state: If the wrapped component (identified by it's name) is included
* in the state, it will be rendered, if not, it wont.
Copy link
Member

Choose a reason for hiding this comment

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

Are these docs correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

No.

/**
* The wrapper class for the given component.
*
* @class The VisibleComponent
Copy link
Member

Choose a reason for hiding this comment

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

docs again

} = this.props;

if (map) {
mapDiv = <div className="map" id="map" {...passThroughProps} />;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the hardcoded id?

Copy link
Member Author

@KaiVolland KaiVolland Nov 8, 2017

Choose a reason for hiding this comment

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

This could be also passed as a prop and default could by id

@KaiVolland
Copy link
Member Author

KaiVolland commented Nov 8, 2017

@marcjansen Thx for the catches. Gonna fix these soon.

Copy link
Member

@dnlkoch dnlkoch left a comment

Choose a reason for hiding this comment

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

Great! Really great!

I just added some minor notes.


/**
* The map can be either an OlMap or a Promise that resolves with an OlMap
* if your map is created asynchronusly.
Copy link
Member

@dnlkoch dnlkoch Nov 9, 2017

Choose a reason for hiding this comment

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

asynchronusly -> asynchronously

map: PropTypes.oneOfType([
PropTypes.instanceOf(OlMap),
PropTypes.instanceOf(Promise)
])
Copy link
Member

Choose a reason for hiding this comment

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

The prop map should be marked as required.

/**
* Returns the wrapped instance. Only applicable if withRef is set to true.
*
* @return {Element} The wrappend instance.
Copy link
Member

Choose a reason for hiding this comment

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

wrappend --> wrapped

/**
* Class representating a map.
*
* @class The Map.
Copy link
Member

Choose a reason for hiding this comment

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

Map -> MapComponent

* @method componentDidMount
*/
componentDidMount() {
this.props.map.setTarget('map');
Copy link
Member

Choose a reason for hiding this comment

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

Please make use of prop mapDivId here.

mapDiv = <div
className="map"
id={mapDivId}
{...passThroughProps}
Copy link
Member

Choose a reason for hiding this comment

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

Please add the possibility to pass children to the div element.

Copy link
Member Author

Choose a reason for hiding this comment

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

Solved.

@KaiVolland KaiVolland merged commit aee8252 into terrestris:master Nov 9, 2017
@KaiVolland KaiVolland mentioned this pull request Nov 29, 2017
56 tasks
@KaiVolland KaiVolland deleted the mapprovider branch April 3, 2018 08:29
hblitza pushed a commit that referenced this pull request Oct 19, 2022
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.

None yet

3 participants