-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
An other way to open menu #308
Conversation
Thanks, I like the idea! I believe it should be restricted to desktop though? |
components/PluginsContainer.jsx
Outdated
isAppMenuCompact = (pluginsConfig)=> { | ||
const pluginTopBar = pluginsConfig.find((pluginConf) => pluginConf.name === "TopBar"); | ||
return pluginTopBar && pluginTopBar.cfg.appMenuCompact; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than having this logic in the plugin container, I'd introduce an action setRightMargin
or similar in actions/map
, which sets state.map.rightMargin
, and is then honoured by the various components for positioning (Buttons, WindowManager, MapCopyright). The problem with this approach is that, besides not taking mobile mode into account, it will break right-docked windows with splitscreen=true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @manisandro, I think it is a better way to add an setRightMargin action.
Thanks for your advice.
I'm sorry but I think I didn't manage to set splitscreen=true. How/where to do that ? Or wich behavior in the interface ?
I only have right-docked windows.
Have a good day
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gwenandres , the ResizeableWindow
component has a splitScreenWhenDocked
prop. But the actual plugin rendering the window needs to set it, if it is useful for the component (i.e. AttributeTable, HeightProfile set splitScreenWhenDocked
). For testing, you can just set it for a plugin which renders a right-dockable window.
97b0e1a
to
f75338e
Compare
} else { | ||
document.removeEventListener('click', this.checkCloseMenu); | ||
document.removeEventListener('keydown', this.onKeyPress, true); | ||
document.removeEventListener('mousemove', this.onMouseMove, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just debugged an issue related to these event listeners. If they remain active, they will break arrow-pan of the map and i.e. enter-submit of input fields. So it is undesirable to have these event listeners active unless there really is an open menu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will remove these changes
actions/windows.js
Outdated
return { | ||
type: SET_SPLIT_SCREEN, | ||
windowId: windowId, | ||
side: side, | ||
size: size | ||
size: size, | ||
menuMargins: menuMargins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is any advantage in passing the menuMargins
here, since it is identical to the state value. Just use menuMargins
in the reducer. You can move the const mapMargins = {...}
block in the reducer to a separate funtion which you call both as a result of SET_SPLIT_SCREEN
and SET_MENU_MARGIN
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry I don't understand how to move the const mapMargins = {...}
block to a separate function. mapMargin Values in SET_SPLIT_SCREEN
and SET_MENU_MARGIN
are different...
} else { | ||
document.addEventListener('click', this.checkCloseMenu); | ||
document.addEventListener('keydown', this.onKeyPress, true); | ||
document.addEventListener('mousemove', this.onMouseMove, true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please enclose the entire block between 174 and 181 in
if (!this.props.keepMenuOpen) {
...
}
components/AppMenu.jsx
Outdated
@@ -302,6 +305,12 @@ class AppMenu extends React.Component { | |||
mousetrap(el).bind(this.props.appMenuShortcut, this.toggleMenu); | |||
} | |||
}; | |||
storeRigthMargin = (el) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rigth -> Right
@@ -302,6 +305,12 @@ class AppMenu extends React.Component { | |||
mousetrap(el).bind(this.props.appMenuShortcut, this.toggleMenu); | |||
} | |||
}; | |||
storeRigthMargin = (el) => { | |||
if (this.props.menuCompact && el?.clientWidth > 0) { | |||
const rightmargin = el.clientWidth - MiscUtils.convertEmToPx(11.5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is 11.5em?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
11.5em is the right margin used in CSS to hide a part of menu :
https://github.com/qgis/qwc2/pull/308/files#diff-9af8fe3b349e7d4c7e12d7406c0dc4898315de424adb8a5410a783c774ac807bR60
const style = {display: this.props.visible ? 'initial' : 'none'}; | ||
const style = { | ||
display: this.props.visible ? 'initial' : 'none', | ||
right: 'calc(0.25em + ' + this.props.menuMargins.right + 'px)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is 0.25em? Shouldn't this be part of the menuMargin, if necessary? Else with a zero menuMargin, it will still have a 0.25em right offset.
You'll also want to honour the left margin, since you support it in the reducer state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add 0.25em as it is done for MapCopyright :
https://github.com/qgis/qwc2/blob/master/plugins/MapCopyright.jsx#L57
I found it aesthetically pleasing when everything wasn't aligned (stuck) with the right edge; even without compact menu.
I hope to honor the left margin but I can't do this right now. Should I remove left margin from reducer state ?
@@ -80,6 +81,7 @@ class SideBar extends React.Component { | |||
const render = visible || this.state.render || this.props.renderWhenHidden; | |||
const style = { | |||
width: this.props.width, | |||
right: visible ? 'calc(0.25em + ' + this.props.menuMargins.right + 'px)' : 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question regarding 0.25em as above
Also note that the SideBar can be left-aligned, so you also want honour that case.
reducers/map.js
Outdated
@@ -27,6 +27,7 @@ const defaultState = { | |||
resolutions: [0], | |||
topbarHeight: 0, | |||
bottombarHeight: 0, | |||
rightMargin: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a leftover
bottom: 0, | ||
left: action.left, | ||
top: 0 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong - why reset the top and bottom map margin to zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I correct that
I've merged this manually and added a bunch of fixes, please check out if the latest master works for you. Thanks! |
Hello,
with @sylvainbeo we propose a new way to open main menu.
If you add
appMenuCompact
inTopBar
cfg, main menu is open in compact mode.On hover you will have all details .
I hope we can propose this for everyone.
Have a good day