forked from elastic/eui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature Branch] EuiCollapsibleNav (elastic#3019)
* [Feature] Added `EuiCollapsibleNav` component (elastic#2977) * [New Nav Feature] Added `ghost` colored EuiListGroupItem (elastic#3018) * [New Nav Feature] Created `EuiCollapsibleGroup` (elastic#3031) * [New Nav Feature] EuiPinnableListGroup (elastic#3061) * [K8 Nav Feature] Added `home` and `menu` glyphs to EuiIcon (elastic#3109) * [New Nav Feature] Final docs examples and patterns (elastic#3117) * [New Nav Feature] Move collapsible nav toggle button to be part of EuiCollapsibleNav (elastic#3168)
- Loading branch information
1 parent
cf42411
commit abb6392
Showing
64 changed files
with
2,966 additions
and
86 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
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 React, { | ||
useState, | ||
Fragment, | ||
FunctionComponent, | ||
ReactElement, | ||
ReactNode, | ||
useEffect, | ||
} from 'react'; | ||
|
||
import { EuiFocusTrap } from '../../../../src/components/focus_trap'; | ||
import { EuiButton } from '../../../../src/components/button'; | ||
|
||
export const GuideFullScreen: FunctionComponent<{ | ||
children: (setFullScreen: (isFullScreen: boolean) => void) => ReactElement; | ||
buttonText?: ReactNode; | ||
isFullScreen?: boolean; | ||
}> = ({ | ||
children, | ||
isFullScreen = false, | ||
buttonText = 'Show fullscreen demo', | ||
}) => { | ||
const [fullScreen, setFullScreen] = useState(isFullScreen); | ||
|
||
// Watch for fullScreen status and appropriately add/remove body classes for hiding scroll | ||
useEffect(() => { | ||
if (fullScreen) { | ||
document.body.classList.add('guideBody--overflowHidden'); | ||
} | ||
return () => { | ||
document.body.classList.remove('guideBody--overflowHidden'); | ||
}; | ||
}, [fullScreen]); | ||
|
||
return ( | ||
<Fragment> | ||
<EuiButton onClick={() => setFullScreen(true)} iconType="fullScreen"> | ||
{buttonText} | ||
</EuiButton> | ||
|
||
{fullScreen && <EuiFocusTrap>{children(setFullScreen)}</EuiFocusTrap>} | ||
</Fragment> | ||
); | ||
}; |
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,50 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { EuiCollapsibleNav } from '../../../../src/components/collapsible_nav'; | ||
import { EuiButton, EuiButtonToggle } from '../../../../src/components/button'; | ||
import { EuiTitle } from '../../../../src/components/title'; | ||
import { EuiSpacer } from '../../../../src/components/spacer'; | ||
import { EuiText } from '../../../../src/components/text'; | ||
import { EuiCode } from '../../../../src/components/code'; | ||
|
||
export default () => { | ||
const [navIsOpen, setNavIsOpen] = useState(false); | ||
const [navIsDocked, setNavIsDocked] = useState(false); | ||
|
||
return ( | ||
<> | ||
<EuiCollapsibleNav | ||
isOpen={navIsOpen} | ||
button={ | ||
<EuiButton onClick={() => setNavIsOpen(!navIsOpen)}> | ||
Toggle nav | ||
</EuiButton> | ||
} | ||
isDocked={navIsDocked} | ||
onClose={() => setNavIsOpen(false)}> | ||
<div style={{ padding: 16 }}> | ||
<EuiTitle> | ||
<h2>I am some nav</h2> | ||
</EuiTitle> | ||
<EuiSpacer /> | ||
<EuiButtonToggle | ||
label={`Docked: ${navIsDocked ? 'on' : 'off'}`} | ||
fill={navIsDocked} | ||
onChange={() => { | ||
setNavIsDocked(!navIsDocked); | ||
}} | ||
/> | ||
</div> | ||
</EuiCollapsibleNav> | ||
|
||
{navIsDocked && ( | ||
<EuiText size="s" color="subdued"> | ||
<p> | ||
The button gets hidden by default when nav is docked unless you set{' '} | ||
<EuiCode language="js">hideButtonIfDocked = false</EuiCode>. | ||
</p> | ||
</EuiText> | ||
)} | ||
</> | ||
); | ||
}; |
Oops, something went wrong.