Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Commit

Permalink
Add UD Split pane.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll committed Jun 24, 2019
1 parent 3474a45 commit 1b645f5
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/UniversalDashboard/Controls/src/splitpane.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function New-UDSplitPane {
param(
[Parameter()]
[string]$Id = (New-Guid).ToString(),
[Parameter(Mandatory)]
[ScriptBlock]$Content,
[Parameter()]
[ValidateSet("vertical", "horizontal")]
[string]$Direction = "vertical",
[Parameter()]
[int]$MinimumSize,
[Parameter()]
[int]$DefaultSize
)

$Children = & $Content

if ($Children.Length -ne 2) {
throw "Split pane requires exactly two components in Content"
}

$Options = @{
content = $Children
id = $Id
split = $Direction
type = "ud-splitpane"
}

if ($PSCmdlet.MyInvocation.BoundParameters.ContainsKey("MinimumSize")) {
$Options["minSize"] = $MinimumSize
}

if ($PSCmdlet.MyInvocation.BoundParameters.ContainsKey("DefaultSize")) {
$Options["defaultSize"] = $DefaultSize
}

$Options
}
18 changes: 18 additions & 0 deletions src/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"react-redux": "5.0.7",
"react-router-dom": "4.3.1",
"react-spinkit": "^3.0.0",
"react-split-pane": "^0.1.87",
"react-treebeard": "^2.1.0",
"redux-thunk": "2.3.0",
"tslib": "^1.9.3",
Expand Down
3 changes: 3 additions & 0 deletions src/client/src/app/services/render-service.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const UdDateTimeComponent = React.lazy(() => import('./../basics/datetime.jsx' /
const UdElementComponent = React.lazy(() => import('./../ud-element.jsx' /* webpackChunkName: "ud-element" */))
const UdIcon = React.lazy(() => import( './../ud-icon.jsx' /* webpackChunkName: "ud-icon" */))

import UDSplitPane from './../ud-splitpane';
UniversalDashboard.register("ud-splitpane", UDSplitPane);

export function internalRenderComponent(component, history) {
if (!component) return null;

Expand Down
16 changes: 16 additions & 0 deletions src/client/src/app/ud-splitpane.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import SplitPane from 'react-split-pane';

export default class UDSplitPane extends React.Component {
render() {
var { content } = this.props;

if (content.length !== 2) {
throw "Split pane supports exactly two components."
}

var children = this.content.map(x => UniversalDashboard.renderComponent(x));

return <SplitPane {...props}>{children}</SplitPane>
}
}

0 comments on commit 1b645f5

Please sign in to comment.