Skip to content

Commit

Permalink
[ADD] style option for SplitPane. Its more flexibly now
Browse files Browse the repository at this point in the history
  • Loading branch information
Artkrygin committed Sep 7, 2021
1 parent 8862f56 commit 164b9e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/layouts/SplitPaneLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,13 @@ import SplitPane from 'react-split-pane';
import Pane from 'react-split-pane/lib/Pane';

import { FormsDispatchProps, FormsDispatch } from '../Form';
import { rankWith, uiTypeIs, RankedTester } from '../testers';
import { rankWith, uiTypeIs, RankedTester, optionIs } from '../testers';
import { withLayoutProps } from '../util/ContextToProps';

import { LayoutComponent } from './LayoutComponent';
import { Idx, RenderLayoutProps } from '../util/layout';
import { IViewKindElement } from '../models/uischema';

const divStyle: React.CSSProperties = {
position: 'relative',
width: '300px',
flex: '1 1 auto',
margin: '1px',
};

const renderSplitElements = ({ viewKind, viewKindElement, viewDescr, enabled, Render, form }: RenderLayoutProps) => {
const elements = viewKindElement.elements;
const defaultSize = viewKindElement.options && viewKindElement.options.defaultSize;
Expand All @@ -35,7 +28,7 @@ const renderSplitElements = ({ viewKind, viewKindElement, viewDescr, enabled, Re
const style = el.options && el.options.style;
return (
<Pane key={idx} style={style} initialSize={defaultSize[id]}>
<div style={{ height: '100%', ...style }}>
<div>
<FormsDispatch viewKind={viewKind} viewKindElement={el} viewDescr={viewDescr} enabled={enabled} />
</div>
</Pane>
Expand All @@ -55,6 +48,7 @@ export const SplitPaneLayoutRenderer: React.FC<LayoutComponent> = ({
visible,
}) => {
//const layout = viewKindElement as Layout;
const options = viewKindElement.options || {};
const Render: React.FC<FormsDispatchProps & Idx> = ({ idx, viewKind, viewKindElement, viewDescr, enabled }) => {
return (
<div>
Expand All @@ -64,9 +58,11 @@ export const SplitPaneLayoutRenderer: React.FC<LayoutComponent> = ({
};
return (
<React.Fragment>
<SplitPane split='vertical' style={divStyle} minSize={300}>
{renderSplitElements({ viewKind, viewKindElement, viewDescr, enabled, Render })}
</SplitPane>
<div style={{ position: 'relative', ...options.style }}>
<SplitPane split='vertical' minSize={300}>
{renderSplitElements({ viewKind, viewKindElement, viewDescr, enabled, Render })}
</SplitPane>
</div>
</React.Fragment>
);
};
Expand Down
4 changes: 4 additions & 0 deletions stories/TreeAndFormMktp.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ const viewKinds = [
'@id': 'mktp:_934Jfg7',
'@type': 'aldkg:SplitPaneLayout',
options: {
style: {
width: '100%',
height: '100%',
},
defaultSize: {
'mktp:_85dfg67': '17%',
'mktp:_83jdv8': '40%',
Expand Down

0 comments on commit 164b9e4

Please sign in to comment.