-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial attempt at resizable container callbacks
- Loading branch information
1 parent
634d341
commit 19aee7d
Showing
5 changed files
with
198 additions
and
26 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
src-docs/src/views/resizable_container/resizable_container_callbacks.js
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,103 @@ | ||
import React, { useState } from 'react'; | ||
import { | ||
EuiText, | ||
EuiResizableContainer, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiStat, | ||
EuiPanel, | ||
} from '../../../../src/components'; | ||
import { fake } from 'faker'; | ||
import { useGeneratedHtmlId } from '../../../../src/services'; | ||
|
||
const text = ( | ||
<> | ||
<p>{fake('{{lorem.paragraphs}}')}</p> | ||
<p>{fake('{{lorem.paragraphs}}')}</p> | ||
<p>{fake('{{lorem.paragraphs}}')}</p> | ||
</> | ||
); | ||
|
||
export default () => { | ||
const firstPanelId = useGeneratedHtmlId({ prefix: 'firstPanel' }); | ||
const secondPanelId = useGeneratedHtmlId({ prefix: 'secondPanel' }); | ||
const [resizeTrigger, setResizeTrigger] = useState(); | ||
const [sizes, setSizes] = useState({ | ||
[firstPanelId]: 50, | ||
[secondPanelId]: 50, | ||
}); | ||
|
||
return ( | ||
<EuiFlexGroup direction="column"> | ||
<EuiFlexItem> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title={resizeTrigger ?? ''} | ||
titleSize="m" | ||
description="Trigger" | ||
isLoading={!resizeTrigger} | ||
/> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title={`${Math.round(sizes[firstPanelId])}%`} | ||
titleSize="m" | ||
description="First panel" | ||
isLoading={!resizeTrigger} | ||
/> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title={`${Math.round(sizes[secondPanelId])}%`} | ||
titleSize="m" | ||
description="Second panel" | ||
isLoading={!resizeTrigger} | ||
/> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiResizableContainer | ||
style={{ height: '200px' }} | ||
onPanelWidthChange={(newSizes) => { | ||
setSizes((prevSizes) => ({ ...prevSizes, ...newSizes })); | ||
}} | ||
onResizeStart={(trigger) => setResizeTrigger(trigger)} | ||
onResizeEnd={() => setResizeTrigger(undefined)} | ||
> | ||
{(EuiResizablePanel, EuiResizableButton) => ( | ||
<> | ||
<EuiResizablePanel | ||
id={firstPanelId} | ||
size={sizes[firstPanelId]} | ||
minSize="30%" | ||
> | ||
<EuiText> | ||
<div>{text}</div> | ||
<a href="">Hello world</a> | ||
</EuiText> | ||
</EuiResizablePanel> | ||
|
||
<EuiResizableButton /> | ||
|
||
<EuiResizablePanel | ||
id={secondPanelId} | ||
size={sizes[secondPanelId]} | ||
minSize="200px" | ||
> | ||
<EuiText>{text}</EuiText> | ||
</EuiResizablePanel> | ||
</> | ||
)} | ||
</EuiResizableContainer> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}; |
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