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

Pass some layout props to panel's content container #1974

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions desktop/appcontainer/LoginPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright © 2020 Extremely Heavy Industries Inc.
*/
import {LoginPanelModel} from '@xh/hoist/appcontainer/login/LoginPanelModel';
import {div, filler, form, viewport, vspacer} from '@xh/hoist/cmp/layout';
import {div, filler, form, viewport} from '@xh/hoist/cmp/layout';
import {creates, hoistCmp, XH} from '@xh/hoist/core';
import {button} from '@xh/hoist/desktop/cmp/button';
import {textInput} from '@xh/hoist/desktop/cmp/input';
Expand Down Expand Up @@ -40,9 +40,9 @@ export const loginPanel = hoistCmp.factory({
icon: Icon.login(),
className: 'xh-login',
width: 300,
padding: 10,
mask: loadModel,
items: [
vspacer(10),
form(
textInput({
bind: 'username',
Expand Down
3 changes: 1 addition & 2 deletions desktop/appcontainer/LoginPanel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
border-radius: var(--xh-border-radius-px);

.bp3-input-group {
margin: 0 var(--xh-pad-px) var(--xh-pad-px) var(--xh-pad-px);
margin-bottom: var(--xh-pad-px);
}

&__warning,
&__message {
text-align: center;
margin: 0 var(--xh-pad-px) var(--xh-pad-px) var(--xh-pad-px);
padding: var(--xh-pad-px);
border-radius: var(--xh-border-radius-px);
}
Expand Down
11 changes: 7 additions & 4 deletions desktop/cmp/panel/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ export const [Panel, panel] = hoistCmp.withFactory({
} = nonLayoutProps;

// 1) Pre-process layout
// Block unwanted use of padding props, which will separate the panel's header
// and bottom toolbar from its edges in a confusing way.
layoutProps = omitBy(layoutProps, (v, k) => k.startsWith('padding'));
// Extract content styling props, to pass them on to the content element of the panel,
// and remove them from the panel's wrapper element so that they
// do not have bad effects on the panel's header and bottom toolbar.
const contentStyleFilter = (k) => k.startsWith('padding')|| k.startsWith('overflow') || ['alignItems', 'alignContent', 'justifyContent'].includes(k),
contentStyleProps = omitBy(layoutProps, (v, k) => !contentStyleFilter(k));
layoutProps = omitBy(layoutProps, (v, k) => contentStyleFilter(k));

// Give Panels a default flexing behavior if no dimensions / flex specified.
if (layoutProps.width == null && layoutProps.height == null && layoutProps.flex == null) {
Expand Down Expand Up @@ -106,7 +109,7 @@ export const [Panel, panel] = hoistCmp.withFactory({
style: {display: collapsed ? 'none' : 'flex'},
items: [
parseToolbar(tbar),
...(castArray(children)),
vframe({style: { ...contentStyleProps}, items: castArray(children)}),
parseToolbar(bbar)
]
});
Expand Down
Loading