-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EuiResizableContainer] Allow dynamic
direction
(#4557)
* dynamic isHorizontal; prevent reregistry errors * revert me * required param * remove useMemo * docs; CL * Revert "revert me" This reverts commit 55f82af. * docs section * useIsWithinBreakpoints export
- Loading branch information
1 parent
95efcbb
commit 48ddc80
Showing
8 changed files
with
164 additions
and
17 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
89 changes: 89 additions & 0 deletions
89
src-docs/src/views/resizable_container/resizable_panel_collapsible_responsive.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,89 @@ | ||
import React, { useState } from 'react'; | ||
import { | ||
EuiText, | ||
EuiResizableContainer, | ||
EuiListGroup, | ||
EuiListGroupItem, | ||
EuiPanel, | ||
EuiTitle, | ||
EuiSpacer, | ||
EuiPage, | ||
} from '../../../../src/components'; | ||
import { useIsWithinBreakpoints } from '../../../../src/services'; | ||
import { fake } from 'faker'; | ||
|
||
const texts = []; | ||
|
||
for (let i = 0; i < 4; i++) { | ||
texts.push(<p>{fake('{{lorem.paragraph}}')}</p>); | ||
} | ||
|
||
export default () => { | ||
const items = [ | ||
{ | ||
id: 1, | ||
label: 'First item', | ||
text: texts[0], | ||
active: true, | ||
}, | ||
{ | ||
id: 2, | ||
label: 'Second item', | ||
text: texts[1], | ||
}, | ||
{ | ||
id: 3, | ||
label: 'Third item', | ||
text: texts[2], | ||
}, | ||
{ | ||
id: 4, | ||
label: 'Forth item', | ||
text: texts[3], | ||
}, | ||
]; | ||
|
||
const [itemSelected, setItemSelected] = useState(items[0]); | ||
const itemElements = items.map((item, index) => ( | ||
<EuiListGroupItem | ||
key={index} | ||
onClick={() => setItemSelected(item)} | ||
label={item.label} | ||
size="s" | ||
/> | ||
)); | ||
|
||
const isMobile = useIsWithinBreakpoints(['xs', 's']); | ||
const style = isMobile ? { height: '100%' } : { minHeight: '100%' }; | ||
|
||
return ( | ||
<EuiPage paddingSize="none"> | ||
<EuiResizableContainer | ||
direction={isMobile ? 'vertical' : 'horizontal'} | ||
style={{ height: '400px' }}> | ||
{(EuiResizablePanel, EuiResizableButton) => ( | ||
<> | ||
<EuiResizablePanel | ||
mode="collapsible" | ||
initialSize={20} | ||
minSize="10%"> | ||
<EuiListGroup flush>{itemElements}</EuiListGroup> | ||
</EuiResizablePanel> | ||
|
||
<EuiResizableButton /> | ||
|
||
<EuiResizablePanel mode="main" initialSize={80} minSize="50px"> | ||
<EuiPanel paddingSize="l" style={style}> | ||
<EuiTitle> | ||
<p>{itemSelected.label}</p> | ||
</EuiTitle> | ||
<EuiSpacer /> | ||
<EuiText>{itemSelected.text}</EuiText> | ||
</EuiPanel> | ||
</EuiResizablePanel> | ||
</> | ||
)} | ||
</EuiResizableContainer> | ||
</EuiPage> | ||
); | ||
}; |
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
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