Skip to content

Commit

Permalink
Added getPaneCount method to pane manager
Browse files Browse the repository at this point in the history
  • Loading branch information
antonio-goncalves-unp committed Apr 18, 2023
1 parent 844189c commit 5cee42d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Added getPaneCount method to pane manager

## [1.1.0] - 2023-04-14
- Added compressedPanes and decompressPanes methods to the paneManager
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,18 @@ Wrapper component which will provide the "paneManagerControls" object containing

Object containing several methods to control the behaviour of the Pane manager

| Name | Type | Description |
| ----------- | -------- |-----------------------------------------------------------------------|
| addPane | (pane:Pane)=>void | Used to add a new pane |
| closeLastPane | ()=>void | Close the last pane |
| closePane | (index: number)=>void | Close a specific pane |
| setSidePane | (sidePane: SidePane)=>void | Add a side pane to the last pane |
| closeSidePane | ()=>void | Close side pane |
| updateLastPaneProps | (props:object)=>void | Update props sent to the last pane, this update will re fire a render of the pane content |
| updateSidePaneProps | (props:object)=>void | Update props sent to the side pane, this update will re fire a render of the side pane content |
| compressPanes | ()=>void | Forces all panes to collapses until the meet the "minPaneDistance" regarding its distance |
| decompressPanes | ()=>void | Set panes distance to their default distance |

| Name | Type | Description |
|---------------------|----------------------------|------------------------------------------------------------------------------------------------|
| addPane | (pane:Pane)=>void | Used to add a new pane |
| closeLastPane | ()=>void | Close the last pane |
| closePane | (index: number)=>void | Close a specific pane |
| setSidePane | (sidePane: SidePane)=>void | Add a side pane to the last pane |
| closeSidePane | ()=>void | Close side pane |
| updateLastPaneProps | (props:object)=>void | Update props sent to the last pane, this update will re fire a render of the pane content |
| updateSidePaneProps | (props:object)=>void | Update props sent to the side pane, this update will re fire a render of the side pane content |
| compressPanes | ()=>void | Forces all panes to collapses until the meet the "minPaneDistance" regarding its distance |
| decompressPanes | ()=>void | Set panes distance to their default distance |
| getPaneCount | ()=>number or null | Number of panes stacked on the pane manager |
### Pane

Object describing a pane
Expand Down
17 changes: 10 additions & 7 deletions src/PaneManager/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ interface PaneManagerState {



interface PaneManagerProps {
export interface PaneManagerProps {
minPaneDistance: number,
maxPaneDistance: number,
children: PaneManagerContent,
paneWidth:number,
timeoutMS: number,
baseZIndex: number,
paneStartPadding: number,
children: PaneManagerContent,
baseZIndex: number,
paneClassName?: string,
paneBackgroundClassName?:string,
paneContentClassName?: string,
Expand All @@ -80,7 +80,8 @@ export interface PaneManagerControls {
updateLastPaneProps: (props:object)=>void,
updateSidePaneProps: (props:object)=>void,
compressPanes:()=>void,
decompressPanes:()=>void
decompressPanes:()=>void,
getPaneCount:()=>number | null

}

Expand All @@ -99,7 +100,6 @@ class PaneManager extends React.Component<PaneManagerProps, PaneManagerState>{
private resizeObserver: ResizeObserver;



constructor(props: PaneManagerProps | Readonly<PaneManagerProps>) {
super(props);
//@ts-ignore
Expand All @@ -126,6 +126,7 @@ class PaneManager extends React.Component<PaneManagerProps, PaneManagerState>{




this.resizeObserver = new ResizeObserver(lodash.debounce(this.setPaneDistance,200))

}
Expand Down Expand Up @@ -361,7 +362,8 @@ class PaneManager extends React.Component<PaneManagerProps, PaneManagerState>{
updateLastPaneProps: this.updateLastPaneProps,
updateSidePaneProps: this.updateSidePaneProps,
compressPanes:this.compressPanes,
decompressPanes:this.decompressPanes
decompressPanes:this.decompressPanes,
getPaneCount:()=>this.state.panes.length
},pane.props)
))}
</SlidingPane>
Expand Down Expand Up @@ -438,7 +440,8 @@ class PaneManager extends React.Component<PaneManagerProps, PaneManagerState>{
updateLastPaneProps: this.updateLastPaneProps,
updateSidePaneProps: this.updateSidePaneProps,
compressPanes:this.compressPanes,
decompressPanes:this.decompressPanes
decompressPanes:this.decompressPanes,
getPaneCount:()=>this.state.panes.length
})}
{this.renderPanes()}
</div
Expand Down
6 changes: 4 additions & 2 deletions src/SlidingPane/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ export class SlidingPane extends React.Component<CustomSlidingPaneProps, CustomS
compressPanes:()=>{},
decompressPanes:()=>{},
updateSidePaneProps:this.updateSidePaneProps,
updateLastPaneProps:(props)=>undefined
updateLastPaneProps:(props)=>undefined,
getPaneCount:()=>null
},sidePane?.props)

}}
Expand Down Expand Up @@ -174,7 +175,8 @@ export class SlidingPane extends React.Component<CustomSlidingPaneProps, CustomS
compressPanes:()=>{},
decompressPanes:()=>{},
updateSidePaneProps:this.updateSidePaneProps,
updateLastPaneProps:(props)=>undefined
updateLastPaneProps:(props)=>undefined,
getPaneCount:()=>null
})}

</div>
Expand Down

0 comments on commit 5cee42d

Please sign in to comment.