Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

move SplitScreen & SyncableMap into ol-kit #362

Merged
merged 29 commits into from
Dec 23, 2021
Merged

Conversation

stazrad
Copy link
Contributor

@stazrad stazrad commented Nov 19, 2021

Resolves: attach_gh_issue_here

PR Safety Checklist:

  • Added the task to the appropriate release doc under Enhancements or Bug Fixes
  • Bump package.json & package-lock.json version numbers to appropriate release
  • (optional) All external API changes have been documented
  • (optional) Build docs: npm run docs

Quick Description of Changes (+ screenshots for ui changes):


/**
* @component
* @category vmc
Copy link
Contributor Author

Choose a reason for hiding this comment

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

be gone ye

index={i}
total={array.length}
numberOfRows={2}
numberOfColumns={4}>
<Map id={key} onMapInit={this.onMapInit} isMultiMap>
<Map map={map} onMapInit={this.onMapInit} isMultiMap>
{/* <SplitScreen /> */}

Choose a reason for hiding this comment

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

Should this still be here commented out? Is having a SplitScreen on another demo better?

app/index.html Outdated
@@ -25,6 +25,15 @@
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>
</svg>
</a>
<div id="map0"></div>

Choose a reason for hiding this comment

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

Might be nice to call out that these id values are expected to match those in App.js line 27...

src/Map/Map.js Outdated
@@ -58,7 +58,7 @@ class Map extends React.Component {

// if no map was passed, create the map
this.map = !this.passedMap ? createMap({ target: this.target }) : passedMap

console.log('<Map> did mount', this.passedMap, !this.passedMap.getTargetElement())

Choose a reason for hiding this comment

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

ugh.debug?

onClick={toggleSyncMap.bind(this, index)}>
{disabled
? <LockIcon className={'zmdi zmdi-lock'}/>
: <div>{translations['_ol_kit.MapDisplayElement.map']} {mapNumber}</div>

Choose a reason for hiding this comment

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

I know this is way outside the scope of this change, but is there a story/practice/guidance for doing the localized number rendering here? Does falling back the browser's localized number formatting make sense in the context of translations or is there some better way of ensuring that the selected translation's language matched the number formatting of the mapNumber?


MapDisplayElement.defaultProps = {
translations: {
'_ol_kit.MapDisplayElement.map': 'Map'

Choose a reason for hiding this comment

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

... e.g. above... is there support for positional parameters and such in these translations?

import DragBarIcon from './svgIcons/DragBarIcon'

const Slider = ({ initialPosition, onDrag, innerRef }) => {
const limit = window.innerWidth * 0.2

Choose a reason for hiding this comment

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

Should we be using window here or some parent container (so we are able to contain the map set inside another container)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

valid- look into this

const { right } = maps[0]?.getTargetElement()?.getBoundingClientRect()

if (right === window.innerWidth && !startPosition) {
this.setState({ startPosition: window.innerWidth / 2 })

Choose a reason for hiding this comment

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

Could/should the initial split be settable? Right now it's forced to 50/50...

syncedMaps.map(map => {
const thisView = map.getView()

if (thisView !== view && !thisView.getAnimating()) {

Choose a reason for hiding this comment

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

Can thisView be null/undefined? Do we need to early exit?


addMap = () => {
const { onMapAdded, maps, visibleMapCount } = this.props
const nextMapIdx = visibleMapCount

Choose a reason for hiding this comment

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

Do we need to handle the case where visibleMapCount is zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we dont support a zero map workflow

}
<MapDisplayContainer disabled={disabled}>
{visibleState.map((visible, i) => {
const grow = i === 0 && visibleMapCount === 3
Copy link

@IDisposable IDisposable Nov 19, 2021

Choose a reason for hiding this comment

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

What's the meaning of 3 here? It this trying to force a new row every two or something? Looks like we're trying to put a slider between every other map... so I'm wondering if this should really be some visibleMapCount % 4 === 3 math?

}
})}
</MapDisplayContainer>
{startPosition && visibleMapCount === 2 &&

Choose a reason for hiding this comment

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

What about when visibleMapCount gets beyond 3 (e.g. 4 or other even numbers thereafter)? Should the be visibleMapCount % 2 === 0 math?

}
}

export function coordDiff (coord1, coord2, view) {

Choose a reason for hiding this comment

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

This might be better refactored to take the projection directly instead of a view that we only use to call getProjection from... more general-purpose that way and have less property-envy

}

export function targetDestination (startCoord, distance, bearing, view) {
const projection = view.getProjection()

Choose a reason for hiding this comment

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

Copy link

@IDisposable IDisposable left a comment

Choose a reason for hiding this comment

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

Looks pretty great, sorry for my intrusive queries... just learning more here.

@stazrad
Copy link
Contributor Author

stazrad commented Nov 19, 2021

@IDisposable i pushed this up with a dont merge tag just to understand the diff for now- but i'll checkout these comments during code review. thanks for reviewing 🙏

@@ -27,7 +27,7 @@ export default class SafeParent extends React.Component {
if (current) {
const parentContextKey = keys.find(key => current.closest(`#${key}`) || current.closest(`#${key} ~ *`)) // search the dom, starting at the placeholder ref created in the initial render and moving up; searching first for the map div itself and then siblings of the map div to handle how the map component currently handles children.

if (!parentContextKey) ugh.error(`Could not find parent <Map> for component: "${Component.name}" during context lookup (tip: make sure portals render as children of their map.getTarget() parent)`) // eslint-disable-line max-len
if (!parentContextKey && Component.name !== 'Map') ugh.error(`Could not find parent <Map> for component: "${Component.name}" during context lookup (tip: make sure portals render as children of their map.getTarget() parent)`) // eslint-disable-line max-len
Copy link
Contributor Author

@stazrad stazrad Dec 3, 2021

Choose a reason for hiding this comment

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

fix this to check explicitProps.isMultiMap since component name may change when bundled

const visibleMapCount = visibleState.filter(_=>_).length
// TODO also check for index against total to see if its on a row with 1 or 2 collumns
const columns = numberOfColumns ||
(visibleMapCount === 1 || visibleMapCount === 3) && (index !== 0) ? 1 : 2

Choose a reason for hiding this comment

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

(visibleMapCount & 1 === 1) && (index !== 0) ? 1 : 2 would work for ANY odd number of visible maps

const { contextProps, translations } = this.props
const { maps } = this.state
const map = maps[0]
// console.log('getContextValue', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

commented code needs to be removed.

src/Map/Map.js Outdated
@@ -161,6 +166,7 @@ class Map extends React.Component {
<StyledMap
id={this.target}
fullScreen={fullScreen}
show={true}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this can be dropped

latitude
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should not be deleted

...config,
synced,
visible,
view: map.getView()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this causing white map bug?

// this is the first map, set the view in state
this.syncedView = map.getView()
} else {
map.setView(this.syncedView)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this may also be the cause of white map?

? <LockIcon className={'zmdi zmdi-lock'}/>
: <div>{translations['_ol_kit.MapDisplayElement.map']} {mapNumber}</div>
}
</PrimaryButton>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

map0 should always be synced (disabled?)

@@ -17,7 +17,8 @@ export const Card = styled(({ ...props }) => <MaterialCard {...props} />)({
opacity: 0.9,
'&:hover': {
opacity: '1'
}
},
zIndex: 1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this might be the same problem with LayerPanel hiding

// SplitScreen
'_ol_kit.SplitScreen.disabled': 'Disabled',
'_ol_kit.SplitScreen.addMap': 'Add Map',
'_ol_kit.SplitScreen.removeMap': 'Remove Map'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@akuma1 add these to velocity

@stazrad stazrad added ready to ship 🚀 All systems go- merge + ship! and removed don't merge labels Dec 23, 2021
Copy link
Collaborator

@akuma1 akuma1 left a comment

Choose a reason for hiding this comment

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

👍

@stazrad stazrad merged commit 7e6b209 into master Dec 23, 2021
@stazrad stazrad deleted the multi-map-controls branch December 23, 2021 20:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ready to ship 🚀 All systems go- merge + ship!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants