-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix resplit context examples and type (#26)
- Loading branch information
1 parent
e7684b8
commit c16b09f
Showing
4 changed files
with
91 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useState } from 'react'; | ||
import { FrValue, Resplit, ResplitPaneProps, useResplitContext } from 'resplit'; | ||
|
||
export const SizeAwarePane = (props: ResplitPaneProps) => { | ||
const { isPaneCollapsed, isPaneMinSize } = useResplitContext(); | ||
const [size, setSize] = useState('0.5fr'); | ||
const [isCollapsed, setIsCollapsed] = useState(false); | ||
const [isMinSize, setIsMinSize] = useState(false); | ||
|
||
const handleResize = (size: FrValue) => { | ||
setSize(size); | ||
setIsCollapsed(isPaneCollapsed(props.order)); | ||
setIsMinSize(isPaneMinSize(props.order)); | ||
}; | ||
|
||
return ( | ||
<Resplit.Pane | ||
{...props} | ||
className="p-6" | ||
initialSize="0.5fr" | ||
minSize="0.3fr" | ||
collapsedSize="0.2fr" | ||
collapsible | ||
onResize={handleResize} | ||
> | ||
<ul> | ||
<li>size: {size}</li> | ||
<li>isMinSize: {isMinSize.toString()}</li> | ||
<li>isCollapsed: {isCollapsed.toString()}</li> | ||
</ul> | ||
</Resplit.Pane> | ||
); | ||
}; | ||
|
||
export const ContextExample = () => { | ||
return ( | ||
<Resplit.Root className="h-full"> | ||
<SizeAwarePane order={0} /> | ||
<Resplit.Splitter order={1} size="5px" className="bg-white" /> | ||
<SizeAwarePane order={2} /> | ||
</Resplit.Root> | ||
); | ||
}; |